{F: rooto:"YARD::CodeObjects::RootObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[o:$YARD::CodeObjects::ModuleObject;IC;[8o:#YARD::CodeObjects::ClassObject;IC;[o:$YARD::CodeObjects::MethodObject:@module_functionF: @scope: class:@visibility: public: @pathI""Bug::Float.make_call_receiver:EF:@parameters[[I" procarg;T0: @files[[I"ext/-test-/proc/receiver.c;Ti:@current_file_has_commentsT: @name:make_call_receiver:@source_type0: @tags[:@docstrings{:@docstringIC:YARD::Docstring" ;T;[:@ref_tags[: @allI";T:@unresolved_reference0: @object@ :@namespace@ : @sourceI"static VALUE bug_proc_make_call_receiver(VALUE self, VALUE procarg) { return rb_proc_new(bug_proc_call_receiver, procarg); };T:@signatureI"static VALUE;T:@explicitTo; ; F; ;;;;I"Bug::Float.make_call_super;F;[[I" procarg;T0;[[I"ext/-test-/proc/super.c;Ti;T;:make_call_super;0;[;{;IC;" ;T;[;[;@;0; @;!@ ;"I"static VALUE bug_proc_make_call_super(VALUE self, VALUE procarg) { return rb_proc_new(bug_proc_call_super, procarg); };T;#I"static VALUE;T;$T: @owner@ :@class_mixinsIC;[;&@ :@instance_mixinsIC;[;&@ :@attributesIC:SymbolHash{;IC;*{:@symbolize_valueT: instanceIC;*{;+T;+T: @aliases{: @groups[;[[I"ext/-test-/float/init.c;Ti;F;: Float;: ruby;;;[;{;IC;" ;T;[;[;@;0; @ ;!@;I"Bug::Float;F:@superclasso:YARD::CodeObjects::Proxy :@orignamespace0:@origname0: @imethod0;: Object;!@: @objo; ;IC;[Do; ; F; ;,;;;I"Object#rb_fatal;F;[[I"msg;T0;[[I" ext/-test-/fatal/rb_fatal.c;Ti;T;: rb_fatal;0;[;{;IC;" ;T;[;[;@;0; @>;!@<;"I"static VALUE ruby_fatal(VALUE obj, VALUE msg) { const char *cmsg = NULL; (void)obj; cmsg = RSTRING_PTR(msg); rb_fatal("%s", cmsg); return 0; /* never reached */ };T;#I"static VALUE;T;$To:&YARD::CodeObjects::ConstantObject;[[I"7ext/-test-/wait_for_single_fd/wait_for_single_fd.c;Ti[;F;:RB_WAITFD_IN;:c;;;[;{;IC;" ;T;[;[;@;0; @M;!@<;I"Object::RB_WAITFD_IN;F: @valueI"INT2NUM(RB_WAITFD_IN);To;9;[[@Pi\;F;:RB_WAITFD_OUT;;;;;;[;{;IC;" ;T;[;[;@;0; @X;!@<;I"Object::RB_WAITFD_OUT;F;nil responds true to nil?. Object.new.nil? #=> false nil.nil? #=> true;T;[o:YARD::Tags::OverloadTag :@tag_nameI" overload;F: @text0;;G: @types0;#I" nil?;T;IC;";T;[o:YARD::Tags::Tag ;II" return;F;JI";T;0;K[I" Boolean;T; @z;[;I"@return [Boolean];T;0; @z;@F:@ref_tag_recurse_counti: @summary0;[; @z;[;I"Only the object nil responds true to nil?. Object.new.nil? #=> false nil.nil? #=> true @overload nil? @return [Boolean];T;0; @z;@F;Ao;B;CT;Di{;Ei;Mi;!@<;"I"#==, but typically overridden by descendants to provide meaningful semantics in +case+ statements. ;T;[o;H ;II" overload;F;J0;;O;K0;#I"===(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;I"Case Equality -- For class Object, effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in +case+ statements. @overload ===(other) @return [Boolean];T;0; @;@F;Ao;B;CT;Dix;Ei;!@<;"I"VALUE rb_equal(VALUE obj1, VALUE obj2) { VALUE result; if (obj1 == obj2) return Qtrue; result = rb_equal_opt(obj1, obj2); if (result == Qundef) { result = rb_funcall(obj1, id_eq, 1, obj2); } if (RTEST(result)) return Qtrue; return Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#=~;F;[[I" obj2;T0;[[@i;T;:=~;0;[;{;IC;"qThis method is deprecated. This is not only unuseful but also troublesome because it may hide a type error. ;T;[o;H ;II" overload;F;J0;;P;K0;#I"=~(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;I"This method is deprecated. This is not only unuseful but also troublesome because it may hide a type error. @overload =~(other) @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"static VALUE rb_obj_match(VALUE obj1, VALUE obj2) { rb_warning("deprecated Object#=~ is called on %"PRIsVALUE "; it always returns nil", rb_obj_class(obj1)); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#!~;F;[[I" obj2;T0;[[@i;T;:!~;0;[;{;IC;"\Returns true if two objects do not match (using the =~ method), otherwise false. ;T;[o;H ;II" overload;F;J0;;Q;K0;#I"!~(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;I"Returns true if two objects do not match (using the =~ method), otherwise false. @overload !~(other) @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"static VALUE rb_obj_not_match(VALUE obj1, VALUE obj2) { VALUE result = rb_funcall(obj1, id_match, 1, obj2); return RTEST(result) ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#eql?;F;[[I" obj2;T0;[[@i;T;: eql?;0;[;{;IC;"Equality --- At the Object level, == returns true only if +obj+ and +other+ are the same object. Typically, this method is overridden in descendant classes to provide class-specific meaning. Unlike ==, the equal? method should never be overridden by subclasses as it is used to determine object identity (that is, a.equal?(b) if and only if a is the same object as b): obj = "a" other = obj.dup obj == other #=> true obj.equal? other #=> false obj.equal? obj #=> true The eql? method returns true if +obj+ and +other+ refer to the same hash key. This is used by Hash to test members for equality. For 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;H ;II" overload;F;J0;:==;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @o;H ;II" overload;F;J0;: equal?;K0;#I"equal?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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 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;Ao;B;CT;Di;Ei;Mi;!@<;"I"}MJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { if (obj1 == obj2) return Qtrue; return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"Object#hash;F;[;[[@i;T;: hash;0;[;{;IC;" ;T;[;[;@;0; @+;!@<;"I""VALUE rb_obj_hash(VALUE obj);;T;#I""VALUE rb_obj_hash(VALUE obj);;T;$To; ; F; ;,;;;I"Object#<=>;F;[[I" obj2;T0;[[@i;T;:<=>;0;[;{;IC;"Returns 0 if +obj+ and +other+ are the same object or obj == other, otherwise nil. The <=> is used by various methods to compare objects, for example Enumerable#sort, Enumerable#max etc. Your implementation of <=> should return one of the following values: -1, 0, 1 or nil. -1 means self is smaller than other. 0 means self is equal to other. 1 means self is bigger than other. Nil means the two values could not be compared. When you define <=>, you can include Comparable to gain the methods <=, <, ==, >=, > and between?. ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI"nil;T; @7;[;I"@return [0, nil];T;0; @7;@F;Mi;N0;[[I" other;T0; @7;[;I"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?. @overload <=>(other) @return [0, nil];T;0; @7;@F;Ao;B;CT;Di;Ei;!@<;"I"static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2) { if (obj1 == obj2 || rb_equal(obj1, obj2)) return INT2FIX(0); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#class;F;[;[[@i;T;;;0;[;{;IC;"Returns the class of obj. This method must always be called with an explicit receiver, as class is also a reserved word in Ruby. 1.class #=> Integer self.class #=> Object ;T;[o;H ;II" overload;F;J0;;;K0;#I" class;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Class;T; @W;[;I"@return [Class];T;0; @W;@F;Mi;N0;[; @W;[;I"Returns the class of obj. This method must always be called with an explicit receiver, as class is also a reserved word in Ruby. 1.class #=> Integer self.class #=> Object @overload class @return [Class];T;0; @W;@F;Ao;B;CT;Di;Ei;!@<;"I"OVALUE rb_obj_class(VALUE obj) { return rb_class_real(CLASS_OF(obj)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#singleton_class;F;[;[[@i-;T;:singleton_class;0;[;{;IC;"Returns the singleton class of obj. This method creates a new singleton class if obj does not have one. If obj is nil, true, or false, it returns NilClass, TrueClass, or FalseClass, respectively. If obj is an Integer, a Float or a Symbol, it raises a TypeError. Object.new.singleton_class #=> #> String.singleton_class #=> # nil.singleton_class #=> NilClass ;T;[o;H ;II" overload;F;J0;;W;K0;#I"singleton_class;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Class;T; @r;[;I"@return [Class];T;0; @r;@F;Mi;N0;[; @r;[;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; @r;@F;Ao;B;CT;Di;Ei*;!@<;"I"[static VALUE rb_obj_singleton_class(VALUE obj) { return rb_singleton_class(obj); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#clone;F;[[I" *args;T0;[[@i;T;: clone;0;[;{;IC;"Produces a shallow copy of obj---the instance variables of obj are copied, but not the objects they reference. clone copies the frozen (unless :freeze keyword argument is given with a false value) and tainted state of obj. See also the discussion under Object#dup. class Klass attr_accessor :str end s1 = Klass.new #=> # s1.str = "Hello" #=> "Hello" s2 = s1.clone #=> # s2.str[1,4] = "i" #=> "i" s1.inspect #=> "#" s2.inspect #=> "#" This method may have class-specific behavior. If so, that behavior will be documented under the #+initialize_copy+ method of the class. ;T;[o;H ;II" overload;F;J0;;X;K0;#I"clone(freeze: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" freeze:;TI" true;T; @;[;I"KProduces a shallow copy of obj---the instance variables of obj are copied, but not the objects they reference. clone copies the frozen (unless :freeze keyword argument is given with a false value) and tainted state of obj. See also the discussion under Object#dup. class Klass attr_accessor :str end s1 = Klass.new #=> # s1.str = "Hello" #=> "Hello" s2 = s1.clone #=> # s2.str[1,4] = "i" #=> "i" s1.inspect #=> "#" s2.inspect #=> "#" This method may have class-specific behavior. If so, that behavior will be documented under the #+initialize_copy+ method of the class. @overload clone(freeze: true) @return [Object];T;0; @;@F;Ao;B;CT;Dit;Ei;!@<;"I"static VALUE rb_obj_clone2(int argc, VALUE *argv, VALUE obj) { int kwfreeze = freeze_opt(argc, argv); if (!special_object_p(obj)) return mutable_obj_clone(obj, kwfreeze); return immutable_obj_clone(obj, kwfreeze); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#dup;F;[;[[@i ;T;:dup;0;[;{;IC;"Produces a shallow copy of obj---the instance variables of obj are copied, but not the objects they reference. dup copies the tainted state of obj. 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;H ;II" overload;F;J0;;Y;K0;#I"dup;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"@Produces a shallow copy of obj---the instance variables of obj are copied, but not the objects they reference. dup copies the tainted state of obj. 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;Ao;B;CT;Di;Ei ;!@<;"I"VALUE rb_obj_dup(VALUE obj) { VALUE dup; if (special_object_p(obj)) { return obj; } dup = rb_obj_alloc(rb_obj_class(obj)); init_copy(dup, obj); rb_funcall(dup, id_init_dup, 1, obj); return dup; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#itself;F;[;[[@i';T;: itself;0;[;{;IC;"mReturns the receiver. string = "my string" string.itself.object_id == string.object_id #=> true ;T;[o;H ;II" overload;F;J0;;Z;K0;#I" itself;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"Returns the receiver. string = "my string" string.itself.object_id == string.object_id #=> true @overload itself @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei$;!@<;"I">static VALUE rb_obj_itself(VALUE obj) { return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#yield_self;F;[;[[@iQ;T;:yield_self;0;[;{;IC;"Yields self to the block and returns the result of the block. 3.next.then {|x| x**x }.to_s #=> "256" "my string".yield_self {|s| s.upcase } #=> "MY STRING" Good usage for +yield_self+ is value piping in method chains: require 'open-uri' require 'json' construct_url(arguments). yield_self {|url| open(url).read }. yield_self {|response| JSON.parse(response) } When called without block, the method returns +Enumerator+, which can be used, for example, for conditional circuit-breaking: # meets condition, no-op 1.yield_self.detect(&:odd?) # => 1 # does not meet condition, drop value 2.yield_self.detect(&:odd?) # => nil ;T;[o;H ;II" overload;F;J0;: then;K0;#I" then;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"x;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I" @yield [x] @return [Object];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;[;K0;#I"yield_self;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"x;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I" @yield [x] @return [Object];T;0; @;@F;Mi;N0;[; @;[;I""Yields self to the block and returns the result of the block. 3.next.then {|x| x**x }.to_s #=> "256" "my string".yield_self {|s| s.upcase } #=> "MY STRING" Good usage for +yield_self+ is value piping in method chains: require 'open-uri' require 'json' construct_url(arguments). yield_self {|url| open(url).read }. yield_self {|response| JSON.parse(response) } When called without block, the method returns +Enumerator+, which can be used, for example, for conditional circuit-breaking: # meets condition, no-op 1.yield_self.detect(&:odd?) # => 1 # does not meet condition, drop value 2.yield_self.detect(&:odd?) # => nil @overload then @yield [x] @return [Object] @overload yield_self @yield [x] @return [Object];T;0; @;@F;Ao;B;CT;Di3;EiQ;!@<;"I"static VALUE rb_obj_yield_self(VALUE obj) { RETURN_SIZED_ENUMERATOR(obj, 0, 0, rb_obj_size); return rb_yield_values2(1, &obj); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#then;F;[;[[@iQ;T;;\;0;[;{;IC;"Yields self to the block and returns the result of the block. 3.next.then {|x| x**x }.to_s #=> "256" "my string".yield_self {|s| s.upcase } #=> "MY STRING" Good usage for +yield_self+ is value piping in method chains: require 'open-uri' require 'json' construct_url(arguments). yield_self {|url| open(url).read }. yield_self {|response| JSON.parse(response) } When called without block, the method returns +Enumerator+, which can be used, for example, for conditional circuit-breaking: # meets condition, no-op 1.yield_self.detect(&:odd?) # => 1 # does not meet condition, drop value 2.yield_self.detect(&:odd?) # => nil ;T;[o;H ;II" overload;F;J0;;\;K0;#I" then;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"x;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I" @yield [x] @return [Object];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;[;K0;#I"yield_self;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"x;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I" @yield [x] @return [Object];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di3;EiQ;!@<;"I"static VALUE rb_obj_yield_self(VALUE obj) { RETURN_SIZED_ENUMERATOR(obj, 0, 0, rb_obj_size); return rb_yield_values2(1, &obj); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#initialize_copy;F;[[I" orig;T0;[[@i`;T;:initialize_copy;0;[;{;IC;" :nodoc: ;T;[;[;I":nodoc: ;T;0; @F;@F;Ao;B;CT;DiX;EiZ;!@<;"I"6VALUE rb_obj_init_copy(VALUE obj, VALUE orig) { if (obj == orig) return obj; rb_check_frozen(obj); rb_check_trusted(obj); if (TYPE(obj) != TYPE(orig) || rb_obj_class(obj) != rb_obj_class(orig)) { rb_raise(rb_eTypeError, "initialize_copy should take same class object"); } return obj; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#initialize_dup;F;[[I" orig;T0;[[@iu;T;:initialize_dup;0;[;{;IC;"! :nodoc: ;T;[;[;I"! :nodoc: ;T;0; @V;@F;Ao;B;CT;Dil;Eio;!@<;"I"wVALUE rb_obj_init_dup_clone(VALUE obj, VALUE orig) { rb_funcall(obj, id_init_copy, 1, orig); return obj; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#initialize_clone;F;[[I" orig;T0;[[@iu;T;:initialize_clone;0;[;{;IC;"! :nodoc: ;T;[;[;@b;0; @f;@F;Ao;B;CT;Dil;Eio;!@<;"I"wVALUE rb_obj_init_dup_clone(VALUE obj, VALUE orig) { rb_funcall(obj, id_init_copy, 1, orig); return obj; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#taint;F;[;[[@i;T;: taint;0;[;{;IC;"Mark the object as tainted. Objects that are marked as tainted will be restricted from various built-in methods. This is to prevent insecure data, such as command-line arguments or strings read from Kernel#gets, from inadvertently compromising the user's system. To check whether an object is tainted, use #tainted?. You should only untaint a tainted object if your code has inspected it and determined that it is safe. To do so use #untaint. ;T;[o;H ;II" overload;F;J0;;`;K0;#I" taint;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @u;[;I"@return [Object];T;0; @u;@F;Mi;N0;[; @u;[;I"Mark the object as tainted. Objects that are marked as tainted will be restricted from various built-in methods. This is to prevent insecure data, such as command-line arguments or strings read from Kernel#gets, from inadvertently compromising the user's system. To check whether an object is tainted, use #tainted?. You should only untaint a tainted object if your code has inspected it and determined that it is safe. To do so use #untaint. @overload taint @return [Object];T;0; @u;@F;Ao;B;CT;Di;Ei;!@<;"I"VALUE rb_obj_taint(VALUE obj) { if (!OBJ_TAINTED(obj) && OBJ_TAINTABLE(obj)) { rb_check_frozen(obj); OBJ_TAINT(obj); } return obj; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#tainted?;F;[;[[@i;T;: tainted?;0;[;{;IC;"MReturns true if the object is tainted. See #taint for more information.;T;[o;H ;II" overload;F;J0;;a;K0;#I" tainted?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"wReturns true if the object is tainted. See #taint for more information. @overload tainted? @return [Boolean];T;0; @;@F;Ao;B;CT;Di|;Ei;Mi;!@<;"I"dVALUE rb_obj_tainted(VALUE obj) { if (OBJ_TAINTED(obj)) return Qtrue; return Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#untaint;F;[;[[@i;T;: untaint;0;[;{;IC;"PRemoves the tainted mark from the object. See #taint for more information. ;T;[o;H ;II" overload;F;J0;;b;K0;#I" untaint;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"xRemoves the tainted mark from the object. See #taint for more information. @overload untaint @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"VALUE rb_obj_untaint(VALUE obj) { if (OBJ_TAINTED(obj)) { rb_check_frozen(obj); FL_UNSET(obj, FL_TAINT); } return obj; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#untrust;F;[;[[@i;T;: untrust;0;[;{;IC;"4Deprecated method that is equivalent to #taint. ;T;[o;H ;II" overload;F;J0;;c;K0;#I" untrust;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"\Deprecated method that is equivalent to #taint. @overload untrust @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"VALUE rb_obj_untrust(VALUE obj) { rb_warning("untrust is deprecated and its behavior is same as taint"); return rb_obj_taint(obj); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#untrusted?;F;[;[[@i;T;:untrusted?;0;[;{;IC;"7Deprecated method that is equivalent to #tainted?.;T;[o;H ;II" overload;F;J0;;d;K0;#I"untrusted?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"cDeprecated method that is equivalent to #tainted?. @overload untrusted? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@<;"I"VALUE rb_obj_untrusted(VALUE obj) { rb_warning("untrusted? is deprecated and its behavior is same as tainted?"); return rb_obj_tainted(obj); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#trust;F;[;[[@i;T;: trust;0;[;{;IC;"6Deprecated method that is equivalent to #untaint. ;T;[o;H ;II" overload;F;J0;;e;K0;#I" trust;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"\Deprecated method that is equivalent to #untaint. @overload trust @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"VALUE rb_obj_trust(VALUE obj) { rb_warning("trust is deprecated and its behavior is same as untaint"); return rb_obj_untaint(obj); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#freeze;F;[;[[@iE;T;: freeze;0;[;{;IC;"Prevents further modifications to obj. A RuntimeError will be raised if modification is attempted. There is no way to unfreeze a frozen object. See also Object#frozen?. This method returns self. a = [ "a", "b", "c" ] a.freeze a << "z" produces: prog.rb:3:in `<<': can't modify frozen Array (FrozenError) from prog.rb:3 Objects of the following classes are always frozen: Integer, Float, Symbol. ;T;[o;H ;II" overload;F;J0;;f;K0;#I" freeze;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"Prevents further modifications to obj. A RuntimeError will be raised if modification is attempted. There is no way to unfreeze a frozen object. See also Object#frozen?. This method returns self. a = [ "a", "b", "c" ] a.freeze a << "z" produces: prog.rb:3:in `<<': can't modify frozen Array (FrozenError) from prog.rb:3 Objects of the following classes are always frozen: Integer, Float, Symbol. @overload freeze @return [Object];T;0; @;@F;Ao;B;CT;Di(;Ei>;!@<;"I"VALUE rb_obj_freeze(VALUE obj) { if (!OBJ_FROZEN(obj)) { OBJ_FREEZE(obj); if (SPECIAL_CONST_P(obj)) { rb_bug("special consts should be frozen."); } } return obj; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#frozen?;F;[;[[@ib;T;: frozen?;0;[;{;IC;"}Returns the freeze status of obj. a = [ "a", "b", "c" ] a.freeze #=> ["a", "b", "c"] a.frozen? #=> true;T;[o;H ;II" overload;F;J0;;g;K0;#I" frozen?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @2;[;I"@return [Boolean];T;0; @2;@F;Mi;N0;[; @2;[;I"Returns the freeze status of obj. a = [ "a", "b", "c" ] a.freeze #=> ["a", "b", "c"] a.frozen? #=> true @overload frozen? @return [Boolean];T;0; @2;@F;Ao;B;CT;DiQ;EiZ;Mi;!@<;"I"VVALUE rb_obj_frozen_p(VALUE obj) { return OBJ_FROZEN(obj) ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#to_s;F;[;[[@i;T;: to_s;0;[;{;IC;"Returns a string representing obj. The default to_s prints the object's class and an encoding of the object id. As a special case, the top-level object that is the initial execution context of Ruby programs returns ``main''. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @M;[;I"@return [String];T;0; @M;@F;Mi;N0;[; @M;[;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; @M;@F;Ao;B;CT;Di|;Ei;!@<;"I"VALUE rb_any_to_s(VALUE obj) { VALUE str; VALUE cname = rb_class_name(CLASS_OF(obj)); str = rb_sprintf("#<%"PRIsVALUE":%p>", cname, (void*)obj); OBJ_INFECT(str, obj); return str; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#inspect;F;[;[[@i;T;: inspect;0;[;{;IC;"=Returns a string containing a human-readable representation of obj. The default inspect shows the object's class name, an encoding of the object id, 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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @h;[;I"@return [String];T;0; @h;@F;Mi;N0;[; @h;[;I"dReturns a string containing a human-readable representation of obj. The default inspect shows the object's class name, an encoding of the object id, 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; @h;@F;Ao;B;CT;Di;Ei;!@<;"I"static VALUE rb_obj_inspect(VALUE obj) { if (rb_ivar_count(obj) > 0) { VALUE str; VALUE c = rb_class_name(CLASS_OF(obj)); str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void*)obj); return rb_exec_recursive(inspect_obj, obj, str); } else { return rb_any_to_s(obj); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#methods;F;[[@0;[[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;H ;II" overload;F;J0;;j;K0;#I"methods(regular=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" regular;TI" true;T; @;[;I"_Returns a list of the names of public and protected methods of obj. This will include all the methods accessible in obj's ancestors. If the optional parameter is false, it returns an array of obj's public and protected singleton methods, the array will not include methods in modules included in obj. class Klass def klass_method() end end k = Klass.new k.methods[0..9] #=> [:klass_method, :nil?, :===, # :==~, :!, :eql? # :hash, :<=>, :class, :singleton_class] k.methods.length #=> 56 k.methods(false) #=> [] def k.singleton_method; end k.methods(false) #=> [:singleton_method] module M123; def m123; end end k.extend M123 k.methods(false) #=> [:singleton_method] @overload methods(regular=true) @return [Array];T;0; @;@F;Ao;B;CT;Di ;Ei';!@<;"I"VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj) { rb_check_arity(argc, 0, 1); if (argc > 0 && !RTEST(argv[0])) { return rb_obj_singleton_methods(argc, argv, obj); } return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_i); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#singleton_methods;F;[[@0;[[@i;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;H ;II" overload;F;J0;;k;K0;#I" singleton_methods(all=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dia;Ei;!@<;"I"VALUE rb_obj_singleton_methods(int argc, const VALUE *argv, VALUE obj) { VALUE ary, klass, origin; struct method_entry_arg me_arg; struct rb_id_table *mtbl; int recur = TRUE; if (rb_check_arity(argc, 0, 1)) recur = RTEST(argv[0]); 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_new(); st_foreach(me_arg.list, ins_methods_i, ary); st_free_table(me_arg.list); return ary; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#protected_methods;F;[[@0;[[@i=;T;:protected_methods;0;[;{;IC;"Returns the list of protected methods accessible to obj. If the all parameter is set to false, only those methods in the receiver will be listed. ;T;[o;H ;II" overload;F;J0;;l;K0;#I" protected_methods(all=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di4;Ei:;!@<;"I"VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj) { return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_prot_i); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#private_methods;F;[[@0;[[@iL;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;H ;II" overload;F;J0;;m;K0;#I"private_methods(all=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiC;EiI;!@<;"I"VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj) { return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_priv_i); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#public_methods;F;[[@0;[[@i[;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;H ;II" overload;F;J0;;n;K0;#I"public_methods(all=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiR;EiX;!@<;"I"VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj) { return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_pub_i); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#instance_variables;F;[;[[I"variable.c;Ti;T;:instance_variables;0;[;{;IC;"Returns an array of instance variable names for the receiver. Note that simply defining an accessor does not create the corresponding instance variable. class Fred attr_accessor :a1 def initialize @iv = 3 end end Fred.new.instance_variables #=> [:@iv] ;T;[o;H ;II" overload;F;J0;;o;K0;#I"instance_variables;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@<;"I"VALUE rb_obj_instance_variables(VALUE obj) { VALUE ary; ary = rb_ary_new(); rb_ivar_foreach(obj, ivar_i, ary); return ary; };T;#I" VALUE;T;$To; ; F; ;,;;;I"!Object#instance_variable_get;F;[[I"iv;T0;[[@i ;T;:instance_variable_get;0;[;{;IC;"!Returns the value of the given instance variable, or nil if the instance variable is not set. The @ part of the variable name should be included for regular instance variables. Throws a NameError exception if the supplied symbol is not valid as an instance variable name. String arguments are converted to symbols. class Fred def initialize(p1, p2) @a, @b = p1, p2 end end fred = Fred.new('cat', 99) fred.instance_variable_get(:@a) #=> "cat" fred.instance_variable_get("@b") #=> 99 ;T;[o;H ;II" overload;F;J0;;p;K0;#I""instance_variable_get(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;;[;I"@return [Object];T;0; @;;@F;Mi;N0;[[I" symbol;T0; @;o;H ;II" overload;F;J0;;p;K0;#I""instance_variable_get(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;;[;I"@return [Object];T;0; @;;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@<;"I"static VALUE rb_obj_ivar_get(VALUE obj, VALUE iv) { ID id = id_for_var(obj, iv, an, instance); if (!id) { return Qnil; } return rb_ivar_get(obj, id); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!Object#instance_variable_set;F;[[I"iv;T0[I"val;T0;[[@i ;T;:instance_variable_set;0;[;{;IC;"zSets the instance variable named by symbol to the given object, thereby frustrating the efforts of the class's author to attempt to provide proper encapsulation. 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;H ;II" overload;F;J0;;q;K0;#I"'instance_variable_set(symbol, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @i;[;I"@return [Object];T;0; @i;@F;Mi;N0;[[I" symbol;T0[I"obj;T0; @io;H ;II" overload;F;J0;;q;K0;#I"'instance_variable_set(string, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @i;[;I"@return [Object];T;0; @i;@F;Mi;N0;[[I" string;T0[I"obj;T0; @i;[;I"Sets the instance variable named by symbol to the given object, thereby frustrating the efforts of the class's author to attempt to provide proper encapsulation. 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; @i;@F;Ao;B;CT;Di ;Ei ;!@<;"I"static VALUE rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val) { ID id = id_for_var(obj, iv, an, instance); if (!id) id = rb_intern_str(iv); return rb_ivar_set(obj, id, val); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&Object#instance_variable_defined?;F;[[I"iv;T0;[[@i ;T;:instance_variable_defined?;0;[;{;IC;"Returns true if the given instance variable is defined in obj. String arguments are converted to symbols. class Fred def initialize(p1, p2) @a, @b = p1, p2 end end fred = Fred.new('cat', 99) fred.instance_variable_defined?(:@a) #=> true fred.instance_variable_defined?("@b") #=> true fred.instance_variable_defined?("@c") #=> false;T;[o;H ;II" overload;F;J0;;r;K0;#I"'instance_variable_defined?(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" symbol;T0; @o;H ;II" overload;F;J0;;r;K0;#I"'instance_variable_defined?(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;Mi;!@<;"I"static VALUE rb_obj_ivar_defined(VALUE obj, VALUE iv) { ID id = id_for_var(obj, iv, an, instance); if (!id) { return Qfalse; } return rb_ivar_defined(obj, id); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"$Object#remove_instance_variable;F;[[I" name;T0;[[@$i;T;:remove_instance_variable;0;[;{;IC;"lRemoves the named instance variable from obj, returning that variable's value. String arguments are converted to symbols. class Dummy attr_reader :var def initialize @var = 99 end def remove remove_instance_variable(:@var) end end d = Dummy.new d.var #=> 99 d.remove #=> 99 d.var #=> nil ;T;[o;H ;II" overload;F;J0;;s;K0;#I"%remove_instance_variable(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" symbol;T0; @o;H ;II" overload;F;J0;;s;K0;#I"%remove_instance_variable(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@<;"I"TVALUE 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; st_data_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) break; if (!st_lookup(iv_index_tbl, (st_data_t)id, &index)) break; if (ROBJECT_NUMIV(obj) <= index) break; val = ROBJECT_IVPTR(obj)[index]; if (val != Qundef) { ROBJECT_IVPTR(obj)[index] = Qundef; return val; } break; case T_CLASS: case T_MODULE: n = id; if (RCLASS_IV_TBL(obj) && st_delete(RCLASS_IV_TBL(obj), &n, &v)) { return (VALUE)v; } break; default: if (FL_TEST(obj, FL_EXIVAR)) { if (generic_ivar_remove(obj, id, &val)) { return val; } } break; } not_defined: rb_name_err_raise("instance variable %1$s not defined", obj, name); UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#instance_of?;F;[[I"c;T0;[[@i0;T;:instance_of?;0;[;{;IC;"Returns true if obj is an instance of the given class. See also Object#kind_of?. class A; end class B < A; end class C < B; end b = B.new b.instance_of? A #=> false b.instance_of? B #=> true b.instance_of? C #=> false;T;[o;H ;II" overload;F;J0;;t;K0;#I"instance_of?(class);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"PReturns 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;Ao;B;CT;Di;Ei';Mi;!@<;"I"VALUE rb_obj_is_instance_of(VALUE obj, VALUE c) { c = class_or_module_required(c); if (rb_obj_class(obj) == c) return Qtrue; return Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#kind_of?;F;[[I"c;T0;[[@i\;T;: kind_of?;0;[;{;IC;" Returns true if class is the class of obj, or if class is one of the superclasses of obj or modules included in obj. module M; end class A include M end class B < A; end class C < B; end b = B.new b.is_a? A #=> true b.is_a? B #=> true b.is_a? C #=> false b.is_a? M #=> true b.kind_of? A #=> true b.kind_of? B #=> true b.kind_of? C #=> false b.kind_of? M #=> true;T;[o;H ;II" overload;F;J0;: is_a?;K0;#I"is_a?(class);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;u;K0;#I"kind_of?(class);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"gReturns true if class is the class of obj, or if class is one of the superclasses of obj or modules included in obj. module M; end class A include M end class B < A; end class C < B; end b = B.new b.is_a? A #=> true b.is_a? B #=> true b.is_a? C #=> false b.is_a? M #=> true b.kind_of? A #=> true b.kind_of? B #=> true b.kind_of? C #=> false b.kind_of? M #=> true @overload is_a?(class) @return [Boolean] @overload kind_of?(class) @return [Boolean];T;0; @;@F;Ao;B;CT;Di9;EiT;Mi;!@<;"I"VALUE rb_obj_is_kind_of(VALUE obj, VALUE c) { VALUE cl = CLASS_OF(obj); c = class_or_module_required(c); return class_search_ancestor(cl, RCLASS_ORIGIN(c)) ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#is_a?;F;[[I"c;T0;[[@i\;T;;v;0;[;{;IC;" Returns true if class is the class of obj, or if class is one of the superclasses of obj or modules included in obj. module M; end class A include M end class B < A; end class C < B; end b = B.new b.is_a? A #=> true b.is_a? B #=> true b.is_a? C #=> false b.is_a? M #=> true b.kind_of? A #=> true b.kind_of? B #=> true b.kind_of? C #=> false b.kind_of? M #=> true;T;[o;H ;II" overload;F;J0;;v;K0;#I"is_a?(class);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @@;[;I"@return [Boolean];T;0; @@;@F;Mi;N0;[; @@o;H ;II" overload;F;J0;;u;K0;#I"kind_of?(class);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @@;[;I"@return [Boolean];T;0; @@;@F;Mi;N0;[; @@;[;@<;0; @@;@F;Ao;B;CT;Di9;EiT;Mi;!@<;"I"VALUE rb_obj_is_kind_of(VALUE obj, VALUE c) { VALUE cl = CLASS_OF(obj); c = class_or_module_required(c); return class_search_ancestor(cl, RCLASS_ORIGIN(c)) ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#tap;F;[;[[@i;T;:tap;0;[;{;IC;"Yields self to the block, and then returns self. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. (1..10) .tap {|x| puts "original: #{x}" } .to_a .tap {|x| puts "array: #{x}" } .select {|x| x.even? } .tap {|x| puts "evens: #{x}" } .map {|x| x*x } .tap {|x| puts "squares: #{x}" } ;T;[o;H ;II" overload;F;J0;;w;K0;#I"tap;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"x;T; @io;L ;II" return;F;JI";T;0;K[I" Object;T; @i;[;I" @yield [x] @return [Object];T;0; @i;@F;Mi;N0;[; @i;[;I"Yields self to the block, and then returns self. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. (1..10) .tap {|x| puts "original: #{x}" } .to_a .tap {|x| puts "array: #{x}" } .select {|x| x.even? } .tap {|x| puts "evens: #{x}" } .map {|x| x*x } .tap {|x| puts "squares: #{x}" } @overload tap @yield [x] @return [Object];T;0; @i;@F;Ao;B;CT;Diy;Ei;!@<;"I"GVALUE rb_obj_tap(VALUE obj) { rb_yield(obj); return obj; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#display;F;[[@0;[[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;H ;II" overload;F;J0;;x;K0;#I"display(port=$>);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" port;TI"$>;T; @;[;I"*Prints obj on the given port (default $>). Equivalent to: def display(port=$>) port.write self nil end For example: 1.display "cat".display [ 4, 5, 6 ].display puts produces: 1cat[4, 5, 6] @overload display(port=$>) @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"static VALUE rb_obj_display(int argc, VALUE *argv, VALUE self) { VALUE out; out = (!rb_check_arity(argc, 0, 1) ? rb_stdout : argv[0]); rb_io_write(out, self); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#method;F;[[I"vid;T0;[[I" proc.c;Ti;T;: method;0;[;{;IC;"Looks up the named method as a receiver in obj, returning a Method object (or raising NameError). The Method object acts as a closure in obj's object instance, so instance variables and the value of self remain available. class Demo def initialize(n) @iv = n end def hello() "Hello, @iv = #{@iv}" end end k = Demo.new(99) m = k.method(:hello) m.call #=> "Hello, @iv = 99" l = Demo.new('Fred') m = l.method("hello") m.call #=> "Hello, @iv = Fred" Note that Method implements to_proc method, which means it can be used with iterators. [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout out = File.open('test.txt', 'w') [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file require 'date' %w[2017-03-01 2017-03-02].collect(&Date.method(:parse)) #=> [#, #] ;T;[o;H ;II" overload;F;J0;;y;K0;#I"method(sym);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"sym;T0; @;[;I"6Looks 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;Ao;B;CT;Di;Ei;!@<;"I"ZVALUE rb_obj_method(VALUE obj, VALUE vid) { return obj_method(obj, vid, FALSE); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#public_method;F;[[I"vid;T0;[[@i;T;:public_method;0;[;{;IC;"6Similar to _method_, searches public method only. ;T;[o;H ;II" overload;F;J0;;z;K0;#I"public_method(sym);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"sym;T0; @;[;I"USimilar to _method_, searches public method only. @overload public_method(sym);T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"`VALUE rb_obj_public_method(VALUE obj, VALUE vid) { return obj_method(obj, vid, TRUE); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#singleton_method;F;[[I"vid;T0;[[@i;T;:singleton_method;0;[;{;IC;"^Similar to _method_, searches singleton method only. class Demo def initialize(n) @iv = n end def hello() "Hello, @iv = #{@iv}" end end k = Demo.new(99) def k.hi "Hi, @iv = #{@iv}" end m = k.singleton_method(:hi) m.call #=> "Hi, @iv = 99" m = k.singleton_method(:hello) #=> NameError ;T;[o;H ;II" overload;F;J0;;{;K0;#I"singleton_method(sym);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@<;"I"VALUE rb_obj_singleton_method(VALUE obj, VALUE vid) { const rb_method_entry_t *me; VALUE klass = rb_singleton_class_get(obj); ID id = rb_check_id(&vid); if (NIL_P(klass) || NIL_P(klass = RCLASS_ORIGIN(klass))) { undef: rb_name_err_raise("undefined singleton method `%1$s' for `%2$s'", obj, vid); } if (!id) { if (respond_to_missing_p(klass, obj, vid, FALSE)) { id = rb_intern_str(vid); return mnew_missing(klass, obj, id, rb_cMethod); } goto undef; } me = rb_method_entry_at(klass, id); if (UNDEFINED_METHOD_ENTRY_P(me) || UNDEFINED_REFINED_METHOD_P(me->def)) { vid = ID2SYM(id); goto undef; } return mnew_from_me(me, klass, klass, obj, id, rb_cMethod, FALSE); };T;#I" VALUE;T;$To; ; F; ;,;;;I"#Object#define_singleton_method;F;[[@0;[[@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. 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!" ;T;[o;H ;II" overload;F;J0;;|;K0;#I",define_singleton_method(symbol, method);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" symbol;T0[I" method;T0; @o;H ;II" overload;F;J0;;|;K0;#I"$define_singleton_method(symbol);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[[I" symbol;T0; @;[;I"eDefines 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. 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!" @overload define_singleton_method(symbol, method) @overload define_singleton_method(symbol) @yield [];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"static VALUE rb_obj_define_method(int argc, VALUE *argv, VALUE obj) { VALUE klass = rb_singleton_class(obj); return rb_mod_define_method(argc, argv, klass); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#send;F;[[@0;[[I"vm_eval.c;Ti;T;: send;0;[;{;IC;"Invokes the method identified by _symbol_, passing it any arguments specified. You can use __send__ if the name +send+ clashes with an existing method in _obj_. When the method is identified by a string, the string is converted to a symbol. class Klass def hello(*args) "Hello " + args.join(' ') end end k = Klass.new k.send :hello, "gentle", "readers" #=> "Hello gentle readers" ;T;[ o;H ;II" overload;F;J0;;};K0;#I"send(symbol [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I"symbol[, args...];T0; @ o;H ;II" overload;F;J0;: __send__;K0;#I"!__send__(symbol [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I"symbol[, args...];T0; @ o;H ;II" overload;F;J0;;};K0;#I"send(string [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I"string[, args...];T0; @ o;H ;II" overload;F;J0;;~;K0;#I"!__send__(string [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I"string[, args...];T0; @ ;[;I" Invokes the method identified by _symbol_, passing it any arguments specified. You can use __send__ if the name +send+ clashes with an existing method in _obj_. When the method is identified by a string, the string is converted to a symbol. 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;Ao;B;CT;Di;Ei;!@<;"I"sVALUE rb_f_send(int argc, VALUE *argv, VALUE recv) { return send_internal(argc, argv, recv, CALL_FCALL); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Object#public_send;F;[[@0;[[@&i;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;H ;II" overload;F;J0;;;K0;#I"$public_send(symbol [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @l;[;I"@return [Object];T;0; @l;@F;Mi;N0;[[I"symbol[, args...];T0; @lo;H ;II" overload;F;J0;;;K0;#I"$public_send(string [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @l;[;I"@return [Object];T;0; @l;@F;Mi;N0;[[I"string[, args...];T0; @l;[;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; @l;@F;Ao;B;CT;Di;Ei;!@<;"I"}static VALUE rb_f_public_send(int argc, VALUE *argv, VALUE recv) { return send_internal(argc, argv, recv, CALL_PUBLIC); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#to_enum;F;[[@0;[[I"enumerator.c;Ti8;T;: to_enum;0;[;{;IC;"6Creates a new Enumerator which will enumerate by calling +method+ on +obj+, passing +args+ if any. If a block is given, it will be used to calculate the size of the enumerator without the need to iterate it (see Enumerator#size). === Examples str = "xyz" enum = str.enum_for(:each_byte) enum.each { |b| puts b } # => 120 # => 121 # => 122 # protect an array from being modified by some_method a = [1, 2, 3] some_method(a.to_enum) It is typical to call to_enum when defining methods for a generic Enumerable, in case no block is passed. Here is such an example, with parameter passing and a sizing block: module Enumerable # a generic method to repeat the values of any enumerable def repeat(n) raise ArgumentError, "#{n} is negative!" if n < 0 unless block_given? return to_enum(__method__, n) do # __method__ is :repeat here sz = size # Call size and multiply by n... sz * n if sz # but return nil if size itself is nil end end each do |*val| n.times { yield *val } end end end %i[hello world].repeat(2) { |w| puts w } # => Prints 'hello', 'hello', 'world', 'world' enum = (1..14).repeat(3) # => returns an Enumerator when called without a block enum.first(4) # => [1, 1, 1, 2] enum.size # => 42 ;T;[ o;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;: enum_for;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"(@yield [*args] @return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;|;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"(@yield [*args] @return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @;[;I"\Creates a new Enumerator which will enumerate by calling +method+ on +obj+, passing +args+ if any. If a block is given, it will be used to calculate the size of the enumerator without the need to iterate it (see Enumerator#size). === Examples str = "xyz" enum = str.enum_for(:each_byte) enum.each { |b| puts b } # => 120 # => 121 # => 122 # protect an array from being modified by some_method a = [1, 2, 3] some_method(a.to_enum) It is typical to call to_enum when defining methods for a generic Enumerable, in case no block is passed. Here is such an example, with parameter passing and a sizing block: module Enumerable # a generic method to repeat the values of any enumerable def repeat(n) raise ArgumentError, "#{n} is negative!" if n < 0 unless block_given? return to_enum(__method__, n) do # __method__ is :repeat here sz = size # Call size and multiply by n... sz * n if sz # but return nil if size itself is nil end end each do |*val| n.times { yield *val } end end end %i[hello world].repeat(2) { |w| puts w } # => Prints 'hello', 'hello', 'world', 'world' enum = (1..14).repeat(3) # => returns an Enumerator when called without a block enum.first(4) # => [1, 1, 1, 2] enum.size # => 42 @overload to_enum(method = :each, *args) @return [Enumerator] @overload enum_for(method = :each, *args) @return [Enumerator] @overload to_enum(method = :each, *args) @yield [*args] @return [Enumerator] @overload enum_for(method = :each, *args) @yield [*args] @return [Enumerator];T;0; @;@F;Ao;B;CT;Di;Ei;;!@<;"I"Qstatic VALUE obj_to_enum(int argc, VALUE *argv, VALUE obj) { VALUE enumerator, meth = sym_each; if (argc > 0) { --argc; meth = *argv++; } enumerator = rb_enumeratorize_with_size(obj, meth, argc, argv, 0); if (rb_block_given_p()) { enumerator_ptr(enumerator)->size = rb_block_proc(); } return enumerator; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#enum_for;F;[[@0;[[@i8;T;;|;0;[;{;IC;"6Creates a new Enumerator which will enumerate by calling +method+ on +obj+, passing +args+ if any. If a block is given, it will be used to calculate the size of the enumerator without the need to iterate it (see Enumerator#size). === Examples str = "xyz" enum = str.enum_for(:each_byte) enum.each { |b| puts b } # => 120 # => 121 # => 122 # protect an array from being modified by some_method a = [1, 2, 3] some_method(a.to_enum) It is typical to call to_enum when defining methods for a generic Enumerable, in case no block is passed. Here is such an example, with parameter passing and a sizing block: module Enumerable # a generic method to repeat the values of any enumerable def repeat(n) raise ArgumentError, "#{n} is negative!" if n < 0 unless block_given? return to_enum(__method__, n) do # __method__ is :repeat here sz = size # Call size and multiply by n... sz * n if sz # but return nil if size itself is nil end end each do |*val| n.times { yield *val } end end end %i[hello world].repeat(2) { |w| puts w } # => Prints 'hello', 'hello', 'world', 'world' enum = (1..14).repeat(3) # => returns an Enumerator when called without a block enum.first(4) # => [1, 1, 1, 2] enum.size # => 42 ;T;[ o;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;|;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"(@yield [*args] @return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;|;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"(@yield [*args] @return [Enumerator];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;;!@<;"I"Qstatic VALUE obj_to_enum(int argc, VALUE *argv, VALUE obj) { VALUE enumerator, meth = sym_each; if (argc > 0) { --argc; meth = *argv++; } enumerator = rb_enumeratorize_with_size(obj, meth, argc, argv, 0); if (rb_block_given_p()) { enumerator_ptr(enumerator)->size = rb_block_proc(); } return enumerator; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#assert_Qundef;F;[[I"obj;T0[I"msg;T0;[[I" parse.c;TiD[I"ext/ripper/ripper.c;TiE;T;:assert_Qundef;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @[;@F;Ao;B;CT;DiD;EiD;!@<;"I"static VALUE ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg) { StringValue(msg); if (obj == Qundef) { rb_raise(rb_eArgError, "%"PRIsVALUE, msg); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#rawVALUE;F;[[I"obj;T0;[[@diD[@fi E;T;: rawVALUE;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @p;@F;Ao;B;CT;Di E;Ei E;!@<;"I"Tstatic VALUE ripper_value(VALUE self, VALUE obj) { return ULONG2NUM(obj); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#validate_object;F;[[I"x;T0;[[@diC[@fiC;T;:validate_object;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;DiC;EiC;!@<;"I"Ustatic VALUE ripper_validate_object(VALUE self, VALUE x) { if (x == Qfalse) return x; if (x == Qtrue) return x; if (x == Qnil) return x; if (x == Qundef) rb_raise(rb_eArgError, "Qundef given"); if (FIXNUM_P(x)) return x; if (SYMBOL_P(x)) return x; if (!rb_is_pointer_to_heap(x)) rb_raise(rb_eArgError, "invalid pointer: %p", x); switch (BUILTIN_TYPE(x)) { case T_STRING: case T_OBJECT: case T_ARRAY: case T_BIGNUM: case T_FLOAT: case T_COMPLEX: case T_RATIONAL: return x; case T_NODE: if (nd_type(x) != NODE_RIPPER) { rb_raise(rb_eArgError, "NODE given: %p", x); } return ((NODE *)x)->nd_rval; default: rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)", x, rb_obj_classname(x)); } return x; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#respond_to?;F;[[@0;[[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;H ;II" overload;F;J0;;;K0;#I"+respond_to?(symbol, include_all=false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"include_all;TI" false;T; @o;H ;II" overload;F;J0;;;K0;#I"+respond_to?(string, include_all=false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@<;"I"static VALUE obj_respond_to(int argc, VALUE *argv, VALUE obj) { VALUE mid, priv; ID id; rb_execution_context_t *ec = GET_EC(); rb_scan_args(argc, argv, "11", &mid, &priv); if (!(id = rb_check_id(&mid))) { VALUE ret = basic_obj_respond_to_missing(ec, CLASS_OF(obj), obj, rb_to_symbol(mid), priv); if (ret == Qundef) ret = Qfalse; return ret; } if (basic_obj_respond_to(ec, obj, id, !RTEST(priv))) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#respond_to_missing?;F;[[I"mid;T0[I" priv;T0;[[@i;;T;:respond_to_missing?;0;[;{;IC;"DO NOT USE THIS DIRECTLY. Hook method to return whether the _obj_ can respond to _id_ method or not. When the method name parameter is given as a string, the string is converted to a symbol. See #respond_to?, and the example of BasicObject.;T;[o;H ;II" overload;F;J0;;;K0;#I"-respond_to_missing?(symbol, include_all);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"include_all;T0; @o;H ;II" overload;F;J0;;;K0;#I"-respond_to_missing?(string, include_all);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di,;Ei:;Mi;!@<;"I"astatic VALUE obj_respond_to_missing(VALUE obj, VALUE mid, VALUE priv) { return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#extend;F;[[@0;[[I" eval.c;Ti;T;: extend;0;[;{;IC;"sAdds to _obj_ the instance methods from each module given as a parameter. module Mod def hello "Hello from Mod.\n" end end class Klass def hello "Hello from Klass.\n" end end k = Klass.new k.hello #=> "Hello from Klass.\n" k.extend(Mod) #=> # k.hello #=> "Hello from Mod.\n" ;T;[o;H ;II" overload;F;J0;;;K0;#I"extend(module, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"Adds to _obj_ the instance methods from each module given as a parameter. module Mod def hello "Hello from Mod.\n" end end class Klass def hello "Hello from Klass.\n" end end k = Klass.new k.hello #=> "Hello from Klass.\n" k.extend(Mod) #=> # k.hello #=> "Hello from Mod.\n" @overload extend(module, ...) @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@<;"I"static VALUE rb_obj_extend(int argc, VALUE *argv, VALUE obj) { int i; ID id_extend_object, id_extended; CONST_ID(id_extend_object, "extend_object"); CONST_ID(id_extended, "extended"); rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); for (i = 0; i < argc; i++) Check_Type(argv[i], T_MODULE); while (argc--) { rb_funcall(argv[argc], id_extend_object, 1, obj); rb_funcall(argv[argc], id_extended, 1, obj); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Object#object_id;F;[;[[I" gc.c;Ti ;T;:object_id;0;[;{;IC;"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. 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" 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. 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;Ao;B;CT;Di ;Ei ;!@<;"I"HVALUE 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 */ if (STATIC_SYM_P(obj)) { return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG; } else if (FLONUM_P(obj)) { #if SIZEOF_LONG == SIZEOF_VOIDP return LONG2NUM((SIGNED_VALUE)obj); #else return LL2NUM((SIGNED_VALUE)obj); #endif } else if (SPECIAL_CONST_P(obj)) { return LONG2NUM((SIGNED_VALUE)obj); } return nonspecial_obj_id(obj); };T;#I" VALUE;T;$To;9;[[I"numeric.c;Ti;F;: Fixnum;;;;;;[;{;IC;"#An obsolete class, use Integer ;T;[;[;I"#An obsolete class, use Integer;T;0; @&;@F;Ao;B;CT;Di;Ei;!@<;I"Object::Fixnum;F;produces: goodbye cruel world ;T;[o;H ;II" overload;F;J0;;;K0;#I" at_exit;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @7o;L ;II" return;F;JI";T;0;K[I" Proc;T; @7;[;I"@yield [] @return [Proc];T;0; @7;@F;Mi;N0;[; @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; @7;@F;Ao;B;CT;Di;Ei(;!@5;"I"static VALUE rb_f_at_exit(void) { 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; ; F; ;,;;;I"Kernel#srand;F;[[@0;[[I" random.c;TiF;T;: srand;0;[;{;IC;"zSeeds the system pseudo-random number generator, Random::DEFAULT, 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;H ;II" overload;F;J0;;;K0;#I"$srand(number = Random.new_seed);T;IC;";T;[;[;I";T;0; @V;@F;Mi;N0;[[I" number;TI"Random.new_seed;T; @V;[;I"Seeds the system pseudo-random number generator, Random::DEFAULT, 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; @V;@F;Ao;B;CT;Di/;EiB;!@5;"I"7static VALUE rb_f_srand(int argc, VALUE *argv, VALUE obj) { VALUE seed, old; rb_random_t *r = &default_rand; if (rb_check_arity(argc, 0, 1) == 0) { seed = random_seed(); } else { seed = rb_to_int(argv[0]); } old = r->seed; r->seed = rand_init(&r->mt, seed); return old; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#rand;F;[[@0;[[@\i;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;H ;II" overload;F;J0;;;K0;#I"rand(max=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @q;[;I"@return [Numeric];T;0; @q;@F;Mi;N0;[[I"max;TI"0;T; @q;[;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; @q;@F;Ao;B;CT;Di;Ei;!@5;"I"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(Qnil, rnd, vmax); if (v != Qfalse) return v; vmax = rb_to_int(vmax); if (vmax != INT2FIX(0)) { v = rand_int(Qnil, rnd, vmax, 0); if (!NIL_P(v)) return v; } } return DBL2NUM(genrand_real(&rnd->mt)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#Complex;F;[[@0;[[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;H ;II" overload;F;J0;;;K0;#I"&Complex(x[, y], exception: false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I" x[, y];T0[I"exception:;TI" false;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: false) @return [Numeric];T;0; @;@F;Ao;B;CT;Di;Ei;!@5;"I"static VALUE nucomp_f_complex(int argc, VALUE *argv, VALUE klass) { VALUE a1, a2, opts = Qnil; int raise = TRUE; if (rb_scan_args(argc, argv, "11:", &a1, &a2, &opts) == 1) { a2 = Qundef; } if (!NIL_P(opts)) { static ID kwds[1]; VALUE exception; if (!kwds[0]) { kwds[0] = idException; } rb_get_kwargs(opts, kwds, 0, 1, &exception); raise = (exception != Qfalse); } return nucomp_convert(rb_cComplex, a1, a2, raise); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#trap;F;[[@0;[[I" signal.c;Ti~;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;H ;II" overload;F;J0;;;K0;#I"trap( signal, command );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" signal;T0[I" command;T0; @o;H ;II" overload;F;J0;;;K0;#I"trap( signal );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I";T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I" @yield [ ] @return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di_;Ei~;!@5;"I"static VALUE sig_trap(int argc, VALUE *argv) { 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 (OBJ_TAINTED(cmd)) { rb_raise(rb_eSecurityError, "Insecure: tainted signal trap"); } return trap(sig, func, cmd); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#set_trace_func;F;[[I" trace;T0;[[I"vm_trace.c;Ti ;T;:set_trace_func;0;[;{;IC;"+Establishes _proc_ as the handler for tracing, or disables tracing if the parameter is +nil+. *Note:* this method is obsolete, please use TracePoint instead. _proc_ takes up to six parameters: * an event name * a filename * a line number * an object id * a binding * the name of a class _proc_ is invoked whenever an event occurs. Events are: +c-call+:: call a C-language routine +c-return+:: return from a C-language routine +call+:: call a Ruby method +class+:: start a class or module definition +end+:: finish a class or module definition +line+:: execute code on a new line +raise+:: raise an exception +return+:: return from a Ruby method Tracing is disabled within the context of _proc_. class Test def test a = 1 b = 2 end end set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } t = Test.new t.test line prog.rb:11 false c-call prog.rb:11 new Class c-call prog.rb:11 initialize Object c-return prog.rb:11 initialize Object c-return prog.rb:11 new Class line prog.rb:12 false call prog.rb:2 test Test line prog.rb:3 test Test line prog.rb:4 test Test return prog.rb:4 test Test ;T;[o;H ;II" overload;F;J0;;;K0;#I"set_trace_func(proc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @;[;I"@return [Proc];T;0; @;@F;Mi;N0;[[I" proc;T0; @o;H ;II" overload;F;J0;;;K0;#I"set_trace_func(nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"nil;T0; @;[;I"Establishes _proc_ as the handler for tracing, or disables tracing if the parameter is +nil+. *Note:* this method is obsolete, please use TracePoint instead. _proc_ takes up to six parameters: * an event name * a filename * a line number * an object id * a binding * the name of a class _proc_ is invoked whenever an event occurs. Events are: +c-call+:: call a C-language routine +c-return+:: return from a C-language routine +call+:: call a Ruby method +class+:: start a class or module definition +end+:: finish a class or module definition +line+:: execute code on a new line +raise+:: raise an exception +return+:: return from a Ruby method Tracing is disabled within the context of _proc_. class Test def test a = 1 b = 2 end end set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } t = Test.new t.test line prog.rb:11 false c-call prog.rb:11 new Class c-call prog.rb:11 initialize Object c-return prog.rb:11 initialize Object c-return prog.rb:11 new Class line prog.rb:12 false call prog.rb:2 test Test line prog.rb:3 test Test line prog.rb:4 test Test return prog.rb:4 test Test @overload set_trace_func(proc) @return [Proc] @overload set_trace_func(nil) @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@5;"I"Cstatic VALUE set_trace_func(VALUE obj, VALUE trace) { rb_remove_event_hook(call_trace_func); if (NIL_P(trace)) { return Qnil; } if (!rb_obj_is_proc(trace)) { rb_raise(rb_eTypeError, "trace_func needs to be Proc"); } rb_add_event_hook(call_trace_func, RUBY_EVENT_ALL, trace); return trace; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#Rational;F;[[@0;[[I"rational.c;Ti7;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;H ;II" overload;F;J0;;;K0;#I"$Rational(x, y, exception: true);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"x;T0[I"y;T0[I"exception:;TI" true;T; @ o;H ;II" overload;F;J0;;;K0;#I"#Rational(arg, exception: true);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"arg;T0[I"exception:;TI" true;T; @ ;[;I"JReturns +x/y+ or +arg+ as a Rational. Rational(2, 3) #=> (2/3) Rational(5) #=> (5/1) Rational(0.5) #=> (1/2) Rational(0.3) #=> (5404319552844595/18014398509481984) Rational("2/3") #=> (2/3) Rational("0.3") #=> (3/10) Rational("10 cents") #=> ArgumentError Rational(nil) #=> TypeError Rational(1, nil) #=> TypeError Rational("10 cents", exception: false) #=> nil Syntax of the string form: string form = extra spaces , rational , extra spaces ; rational = [ sign ] , unsigned rational ; unsigned rational = numerator | numerator , "/" , denominator ; numerator = integer part | fractional part | integer part , fractional part ; denominator = digits ; integer part = digits ; fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; sign = "-" | "+" ; digits = digit , { digit | "_" , digit } ; digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; extra spaces = ? \s* ? ; See also String#to_r. @overload Rational(x, y, exception: true) @overload Rational(arg, exception: true);T;0; @ ;@F;Ao;B;CT;Di;Ei4;!@5;"I"static VALUE nurat_f_rational(int argc, VALUE *argv, VALUE klass) { VALUE a1, a2, opts = Qnil; int raise = TRUE; if (rb_scan_args(argc, argv, "11:", &a1, &a2, &opts) == 1) { a2 = Qundef; } if (!NIL_P(opts)) { static ID kwds[1]; VALUE exception; if (!kwds[0]) { kwds[0] = idException; } rb_get_kwargs(opts, kwds, 0, 1, &exception); raise = (exception != Qfalse); } return nurat_convert(rb_cRational, a1, a2, raise); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#sprintf;F;[[@0;[[I"sprintf.c;Ti;T;: sprintf;0;[;{;IC;"F,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" ;T;[o;H ;II" overload;F;J0;: format;K0;#I",format(format_string [, arguments...] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @B ;[;I"@return [String];T;0; @B ;@F;Mi;N0;[[I""format_string[, arguments...];T0; @B o;H ;II" overload;F;J0;;;K0;#I"-sprintf(format_string [, arguments...] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @B ;[;I"@return [String];T;0; @B ;@F;Mi;N0;[[I""format_string[, arguments...];T0; @B ;[;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; @B ;@F;Ao;B;CT;Di;Ei;!@5;"I"tVALUE rb_f_sprintf(int argc, const VALUE *argv) { return rb_str_format(argc - 1, argv + 1, GETNTHARG(0)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#format;F;[[@0;[[@H i;T;;;0;[;{;IC;"F,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" ;T;[o;H ;II" overload;F;J0;;;K0;#I",format(format_string [, arguments...] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @p ;[;I"@return [String];T;0; @p ;@F;Mi;N0;[[I""format_string[, arguments...];T0; @p o;H ;II" overload;F;J0;;;K0;#I"-sprintf(format_string [, arguments...] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @p ;[;I"@return [String];T;0; @p ;@F;Mi;N0;[[I""format_string[, arguments...];T0; @p ;[;@l ;0; @p ;@F;Ao;B;CT;Di;Ei;!@5;"I"tVALUE rb_f_sprintf(int argc, const VALUE *argv) { return rb_str_format(argc - 1, argv + 1, GETNTHARG(0)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#Integer;F;[[@0;[[@i ;T;: Integer;0;[;{;IC;"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 be strictly conformed to numeric representation. 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(nil) #=> TypeError: can't convert nil into Integer Integer("x") #=> ArgumentError: invalid value for Integer(): "x" Integer("x", exception: false) #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"*Integer(arg, base=0, exception: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[[I"arg;T0[I" base;TI"0;T[I"exception:;TI" true;T; @ ;[;I"4Converts 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 be strictly conformed to numeric representation. 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(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];T;0; @ ;@F;Ao;B;CT;Di ;Ei ;!@5;"I"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; ; F; ;,;;;I"Kernel#Float;F;[[@0;[[@i+;T;;/;0;[;{;IC;"Returns arg converted to a float. Numeric types are converted directly, and with exception to string and nil the rest are converted using arg.to_f. Converting a string with invalid characters will result in a ArgumentError. Converting nil generates a TypeError. Exceptions can be suppressed by passing exception: false. Float(1) #=> 1.0 Float("123.456") #=> 123.456 Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring" Float(nil) #=> TypeError: can't convert nil into Float Float("123.0_badstring", exception: false) #=> nil ;T;[o;H ;II" overload;F;J0;;/;K0;#I" Float(arg, exception: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @ ;[;I"@return [Float];T;0; @ ;@F;Mi;N0;[[I"arg;T0[I"exception:;TI" true;T; @ ;[;I"Returns arg converted to a float. Numeric types are converted directly, and with exception to string and nil the rest are converted using arg.to_f. Converting a string with invalid characters will result in a ArgumentError. Converting nil generates a TypeError. Exceptions can be suppressed by passing exception: false. Float(1) #=> 1.0 Float("123.456") #=> 123.456 Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring" Float(nil) #=> TypeError: can't convert nil into Float Float("123.0_badstring", exception: false) #=> nil @overload Float(arg, exception: true) @return [Float];T;0; @ ;@F;Ao;B;CT;Di;Ei(;!@5;"I"static VALUE rb_f_float(int argc, VALUE *argv, VALUE obj) { VALUE arg = Qnil, opts = Qnil; rb_scan_args(argc, argv, "1:", &arg, &opts); return rb_convert_to_float(arg, opts_exception_p(opts)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#String;F;[[I"arg;T0;[[@i;T;: String;0;[;{;IC;"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" ;T;[o;H ;II" overload;F;J0;;;K0;#I"String(arg);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@5;"I"Rstatic VALUE rb_f_string(VALUE obj, VALUE arg) { return rb_String(arg); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#Array;F;[[I"arg;T0;[[@i;T;: Array;0;[;{;IC;"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] ;T;[o;H ;II" overload;F;J0;;;K0;#I"Array(arg);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"arg;T0; @ ;[;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;Ao;B;CT;Di;Ei;!@5;"I"Pstatic VALUE rb_f_array(VALUE obj, VALUE arg) { return rb_Array(arg); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#Hash;F;[[I"arg;T0;[[@i;T;: Hash;0;[;{;IC;"/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 ;T;[o;H ;II" overload;F;J0;;;K0;#I"Hash(arg);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @ ;[;I"@return [Hash];T;0; @ ;@F;Mi;N0;[[I"arg;T0; @ ;[;I"VConverts 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; @ ;@F;Ao;B;CT;Di ;Ei;!@5;"I"Nstatic VALUE rb_f_hash(VALUE obj, VALUE arg) { return rb_Hash(arg); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#syscall;F;[[@0;[[@i&;T;: syscall;0;[;{;IC;"Calls the operating system function identified by _num_ and returns the result of the function or raises SystemCallError if it failed. Arguments for the function can follow _num_. They must be either +String+ objects or +Integer+ objects. A +String+ object is passed as a pointer to the byte sequence. An +Integer+ object is passed as an integer whose bit size is same as a pointer. Up to nine parameters may be passed. The function identified by _num_ is system dependent. On some Unix systems, the numbers may be obtained from a header file called syscall.h. syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box produces: hello Calling +syscall+ on a platform which does not have any way to an arbitrary system function just fails with NotImplementedError. *Note:* +syscall+ is essentially unsafe and unportable. Feel free to shoot your foot. The DL (Fiddle) library is preferred for safer and a bit more portable programming. ;T;[o;H ;II" overload;F;J0;;;K0;#I"syscall(num [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @> ;[;I"@return [Integer];T;0; @> ;@F;Mi;N0;[[I"num[, args...];T0; @> ;[;I"Calls the operating system function identified by _num_ and returns the result of the function or raises SystemCallError if it failed. Arguments for the function can follow _num_. They must be either +String+ objects or +Integer+ objects. A +String+ object is passed as a pointer to the byte sequence. An +Integer+ object is passed as an integer whose bit size is same as a pointer. Up to nine parameters may be passed. The function identified by _num_ is system dependent. On some Unix systems, the numbers may be obtained from a header file called syscall.h. syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box produces: hello Calling +syscall+ on a platform which does not have any way to an arbitrary system function just fails with NotImplementedError. *Note:* +syscall+ is essentially unsafe and unportable. Feel free to shoot your foot. The DL (Fiddle) library is preferred for safer and a bit more portable programming. @overload syscall(num [, args...]) @return [Integer];T;0; @> ;@F;Ao;B;CT;Di&;Ei&;!@5;"I"# static VALUE rb_f_syscall(int argc, VALUE *argv) { 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_warning("We plan to remove a syscall function at future release. DL(Fiddle) provides safer alternative."); } if (argc == 0) rb_raise(rb_eArgError, "too few arguments for syscall"); if (argc > numberof(arg)) rb_raise(rb_eArgError, "too many arguments for syscall"); num = NUM2SYSCALLID(argv[0]); ++argv; for (i = argc - 1; i--; ) { VALUE v = rb_check_string_type(argv[i]); if (!NIL_P(v)) { SafeStringValue(v); rb_str_modify(v); arg[i] = (VALUE)StringValueCStr(v); } else { arg[i] = (VALUE)NUM2LONG(argv[i]); } } switch (argc) { case 1: retval = SYSCALL(num); break; case 2: retval = SYSCALL(num, arg[0]); break; case 3: retval = SYSCALL(num, arg[0],arg[1]); break; case 4: retval = SYSCALL(num, arg[0],arg[1],arg[2]); break; case 5: retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3]); break; case 6: retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4]); break; case 7: retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4],arg[5]); break; case 8: retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6]); break; } if (retval == -1) rb_sys_fail(0); return RETVAL2NUM(retval); #undef SYSCALL #undef NUM2SYSCALLID #undef RETVAL2NUM };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#open;F;[[@0;[[@i ;T;: open;0;[;{;IC;" Creates an IO object connected to the given stream, file, or subprocess. If +path+ does not start with a pipe character (|), treat it as the name of a file to open using the specified mode (defaulting to "r"). The +mode+ is either a string or an integer. If it is an integer, it must be bitwise-or of open(2) flags, such as File::RDWR or File::EXCL. If it is a string, it is either "fmode", "fmode:ext_enc", or "fmode:ext_enc:int_enc". See the documentation of IO.new for full documentation of the +mode+ string directives. If a file is being created, its initial permissions may be set using the +perm+ parameter. See File.new and the open(2) and chmod(2) man pages for a description of permissions. If a block is specified, it will be invoked with the IO object as a parameter, and the IO will be automatically closed when the block terminates. The call returns the value of the block. If +path+ starts with a pipe character ("|"), a subprocess is created, connected to the caller by a pair of pipes. The returned IO object may be used to write to the standard input and read from the standard output of this subprocess. If the command following the pipe is a single minus sign ("|-"), Ruby forks, and this subprocess is connected to the parent. If the command is not "-", the subprocess runs the command. When the subprocess is Ruby (opened via "|-"), the +open+ call returns +nil+. If a block is associated with the open call, that block will run twice --- once in the parent and once in the child. The block parameter will be an IO object in the parent and +nil+ in the child. The parent's +IO+ object will be connected to the child's $stdin and $stdout. The subprocess will be terminated at the end of the block. === Examples Reading from "testfile": open("testfile") do |f| print f.gets end Produces: This is line one Open a subprocess and read its output: cmd = open("|date") print cmd.gets cmd.close Produces: Wed Apr 9 08:56:31 CDT 2003 Open a subprocess running the same Ruby program: f = open("|-", "w+") if f.nil? puts "in Child" exit else puts "Got: #{f.gets}" end Produces: Got: in Child Open a subprocess using a block to receive the IO object: open "|-" do |f| if f then # parent process puts "Got: #{f.gets}" else # child process puts "in Child" end end Produces: Got: in Child ;T;[o;H ;II" overload;F;J0;;;K0;#I")open(path [, mode [, perm]] [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;TI"nil;T; @\ ;[;I"@return [IO, nil];T;0; @\ ;@F;Mi;N0;[[I"!path[, mode [, perm]][, opt];T0; @\ o;H ;II" overload;F;J0;;;K0;#I")open(path [, mode [, perm]] [, opt]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"io;T; @\ o;L ;II" return;F;JI";T;0;K[I" Object;T; @\ ;[;I"!@yield [io] @return [Object];T;0; @\ ;@F;Mi;N0;[[I"!path[, mode [, perm]][, opt];T0; @\ ;[;I"\ Creates an IO object connected to the given stream, file, or subprocess. If +path+ does not start with a pipe character (|), treat it as the name of a file to open using the specified mode (defaulting to "r"). The +mode+ is either a string or an integer. If it is an integer, it must be bitwise-or of open(2) flags, such as File::RDWR or File::EXCL. If it is a string, it is either "fmode", "fmode:ext_enc", or "fmode:ext_enc:int_enc". See the documentation of IO.new for full documentation of the +mode+ string directives. If a file is being created, its initial permissions may be set using the +perm+ parameter. See File.new and the open(2) and chmod(2) man pages for a description of permissions. If a block is specified, it will be invoked with the IO object as a parameter, and the IO will be automatically closed when the block terminates. The call returns the value of the block. If +path+ starts with a pipe character ("|"), a subprocess is created, connected to the caller by a pair of pipes. The returned IO object may be used to write to the standard input and read from the standard output of this subprocess. If the command following the pipe is a single minus sign ("|-"), Ruby forks, and this subprocess is connected to the parent. If the command is not "-", the subprocess runs the command. When the subprocess is Ruby (opened via "|-"), the +open+ call returns +nil+. If a block is associated with the open call, that block will run twice --- once in the parent and once in the child. The block parameter will be an IO object in the parent and +nil+ in the child. The parent's +IO+ object will be connected to the child's $stdin and $stdout. The subprocess will be terminated at the end of the block. === Examples Reading from "testfile": open("testfile") do |f| print f.gets end Produces: This is line one Open a subprocess and read its output: cmd = open("|date") print cmd.gets cmd.close Produces: Wed Apr 9 08:56:31 CDT 2003 Open a subprocess running the same Ruby program: f = open("|-", "w+") if f.nil? puts "in Child" exit else puts "Got: #{f.gets}" end Produces: Got: in Child Open a subprocess using a block to receive the IO object: open "|-" do |f| if f then # parent process puts "Got: #{f.gets}" else # child process puts "in Child" end end Produces: Got: in Child @overload open(path [, mode [, perm]] [, opt]) @return [IO, nil] @overload open(path [, mode [, perm]] [, opt]) @yield [io] @return [Object];T;0; @\ ;@F;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_f_open(int argc, VALUE *argv) { 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(argv[0], to_open, argc-1, argv+1); if (rb_block_given_p()) { return rb_ensure(rb_yield, io, io_close, io); } return io; } return rb_io_s_open(argc, argv, rb_cFile); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#printf;F;[[@0;[[@iY;T;: printf;0;[;{;IC;"iEquivalent to: io.write(sprintf(string, obj, ...)) or $stdout.write(sprintf(string, obj, ...)) ;T;[o;H ;II" overload;F;J0;;;K0;#I"$printf(io, string [, obj ... ]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[[I"io;T0[I"string[, obj ... ];T0; @ o;H ;II" overload;F;J0;;;K0;#I" printf(string [, obj ... ]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;DiN;EiW;!@5;"I"static VALUE rb_f_printf(int argc, VALUE *argv) { VALUE out; if (argc == 0) return Qnil; if (RB_TYPE_P(argv[0], T_STRING)) { out = rb_stdout; } else { out = argv[0]; argv++; argc--; } rb_io_write(out, rb_f_sprintf(argc, argv)); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#print;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"print(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@5;"I"vstatic VALUE rb_f_print(int argc, const VALUE *argv) { rb_io_print(argc, argv, rb_stdout); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#putc;F;[[I"ch;T0;[[@i;T;: putc;0;[;{;IC;"Equivalent to: $stdout.putc(int) Refer to the documentation for IO#putc for important information regarding multi-byte characters. ;T;[o;H ;II" overload;F;J0;;;K0;#I"putc(int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_f_putc(VALUE recv, VALUE ch) { if (recv == rb_stdout) { return rb_io_putc(recv, ch); } return rb_funcallv(rb_stdout, rb_intern("putc"), 1, &ch); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#puts;F;[[@0;[[@iZ;T;: puts;0;[;{;IC;".Equivalent to $stdout.puts(obj, ...) ;T;[o;H ;II" overload;F;J0;;;K0;#I"puts(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[[I"obj;T0[I"...;T0; @ ;[;I"YEquivalent to $stdout.puts(obj, ...) @overload puts(obj, ...) @return [nil];T;0; @ ;@F;Ao;B;CT;DiQ;EiW;!@5;"I"static VALUE rb_f_puts(int argc, VALUE *argv, VALUE recv) { if (recv == rb_stdout) { return rb_io_puts(argc, argv, recv); } return rb_funcallv(rb_stdout, rb_intern("puts"), argc, argv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#gets;F;[[@0;[[@ih";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;H ;II" overload;F;J0;;;K0;#I""gets(sep=$/ [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I"sep;TI"$/[, getline_args];T; @ o;H ;II" overload;F;J0;;;K0;#I"!gets(limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I"limit[, getline_args];T0; @ o;H ;II" overload;F;J0;;;K0;#I"&gets(sep, limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I"sep;T0[I"limit[, getline_args];T0; @ ;[;I"Returns (and assigns to $_) the next line from the list of files in +ARGV+ (or $*), or from standard input if no files are present on the command line. Returns +nil+ at end of file. The optional argument specifies the record separator. The separator is included with the contents of each record. A separator of +nil+ reads the entire contents, and a zero-length separator reads the input one paragraph at a time, where paragraphs are divided by two consecutive newlines. If the first argument is an integer, or optional second argument is given, the returning string would not be longer than the given value in bytes. If multiple filenames are present in +ARGV+, gets(nil) will read the contents one file at a time. ARGV << "testfile" print while gets produces: This is line one This is line two This is line three And so on... The style of programming using $_ as an implicit parameter is gradually losing favor in the Ruby community. @overload gets(sep=$/ [, getline_args]) @return [String, nil] @overload gets(limit [, getline_args]) @return [String, nil] @overload gets(sep, limit [, getline_args]) @return [String, nil];T;0; @ ;@F;Ao;B;CT;DiG";Eig";!@5;"I"static VALUE rb_f_gets(int argc, VALUE *argv, VALUE recv) { if (recv == argf) { return argf_gets(argc, argv, argf); } return rb_funcallv(argf, idGets, argc, argv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#readline;F;[[@0;[[@i";T;: readline;0;[;{;IC;"aEquivalent to Kernel::gets, except +readline+ raises +EOFError+ at end of file. ;T;[o;H ;II" overload;F;J0;;;K0;#I"readline(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_ ;[;I"@return [String];T;0; @_ ;@F;Mi;N0;[[I"sep;TI"$/;T; @_ o;H ;II" overload;F;J0;;;K0;#I"readline(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_ ;[;I"@return [String];T;0; @_ ;@F;Mi;N0;[[I" limit;T0; @_ o;H ;II" overload;F;J0;;;K0;#I"readline(sep, limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_ ;[;I"@return [String];T;0; @_ ;@F;Mi;N0;[[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;Ao;B;CT;Di";Ei";!@5;"I"static VALUE rb_f_readline(int argc, VALUE *argv, VALUE recv) { if (recv == argf) { return argf_readline(argc, argv, argf); } return rb_funcallv(argf, rb_intern("readline"), argc, argv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#select;F;[[@0;[[@i%;T;: select;0;[;{;IC;"YCalls 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;H ;II" overload;F;J0;;;K0;#I"Cselect(read_array [, write_array [, error_array [, timeout]]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @ ;[;I"@return [Array, nil];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di$;Ei%;!@5;"I" static VALUE rb_f_select(int argc, VALUE *argv, VALUE obj) { VALUE timeout; struct select_args args; struct timeval timerec; int i; rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout); if (NIL_P(timeout)) { args.timeout = 0; } else { timerec = rb_time_interval(timeout); args.timeout = &timerec; } for (i = 0; i < numberof(args.fdsets); ++i) rb_fd_init(&args.fdsets[i]); return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#readlines;F;[[@0;[[@i";T;:readlines;0;[;{;IC;"zReturns an array containing the lines returned by calling Kernel.gets(sep) until the end of file. ;T;[o;H ;II" overload;F;J0;;;K0;#I"readlines(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"sep;TI"$/;T; @ o;H ;II" overload;F;J0;;;K0;#I"readlines(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I" limit;T0; @ o;H ;II" overload;F;J0;;;K0;#I"readlines(sep, limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di";Ei";!@5;"I"static VALUE rb_f_readlines(int argc, VALUE *argv, VALUE recv) { if (recv == argf) { return argf_readlines(argc, argv, argf); } return rb_funcallv(argf, rb_intern("readlines"), argc, argv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Kernel#`;F;[[I"str;T0;[[@i)#;T;:`;0;[;{;IC;"ZReturns the standard output of running _cmd_ in a subshell. The built-in syntax %x{...} uses this method. Sets $? to the process status. `date` #=> "Wed Apr 9 08:56:30 CDT 2003\n" `ls testdir`.split[1] #=> "main.rb" `echo oops && exit 99` #=> "oops\n" $?.exitstatus #=> 99 ;T;[o;H ;II" overload;F;J0;;;K0;#I" `cmd`;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Returns the standard output of running _cmd_ in a subshell. The built-in syntax %x{...} uses this method. Sets $? to the process status. `date` #=> "Wed Apr 9 08:56:30 CDT 2003\n" `ls testdir`.split[1] #=> "main.rb" `echo oops && exit 99` #=> "oops\n" $?.exitstatus #=> 99 @overload `cmd` @return [String];T;0; @ ;@F;Ao;B;CT;Di#;Ei&#;!@5;"I"static VALUE rb_f_backquote(VALUE obj, VALUE str) { VALUE port; VALUE result; rb_io_t *fptr; SafeStringValue(str); rb_last_status_clear(); port = pipe_open_s(str, "r", FMODE_READABLE|DEFAULT_TEXTMODE, NULL); if (NIL_P(port)) return rb_str_new(0,0); GetOpenFile(port, fptr); result = read_all(fptr, remain_size(fptr), Qnil); rb_io_close(port); RFILE(port)->fptr = NULL; rb_io_fptr_finalize(fptr); rb_gc_force_recycle(port); /* also guards from premature GC */ return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Kernel#p;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" p(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ o;H ;II" overload;F;J0;;;K0;#I"p(obj1, obj2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I" obj1;T0[I" obj2;T0[I"...;T0; @ o;H ;II" overload;F;J0;;;K0;#I"p();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_f_p(int argc, VALUE *argv, VALUE self) { struct rb_f_p_arg arg; arg.argc = argc; arg.argv = argv; return rb_uninterruptible(rb_f_p_internal, (VALUE)&arg); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#load;F;[[@0;[[I" load.c;Ti;T;: load;0;[;{;IC;"Loads and executes the Ruby program in the file _filename_. If the filename does not resolve to an absolute path, the file is searched for in the library directories listed in $:. If the optional _wrap_ parameter is +true+, the loaded script will be executed under an anonymous module, protecting the calling program's global namespace. In no circumstance will any local variables in the loaded file be propagated to the loading environment. ;T;[o;H ;II" overload;F;J0;;;K0;#I"load(filename, wrap=false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @W ;[;I"@return [true];T;0; @W ;@F;Mi;N0;[[I" filename;T0[I" wrap;TI" false;T; @W ;[;I"Loads and executes the Ruby program in the file _filename_. If the filename does not resolve to an absolute path, the file is searched for in the library directories listed in $:. If the optional _wrap_ parameter is +true+, the loaded script will be executed under an anonymous module, protecting the calling program's global namespace. In no circumstance will any local variables in the loaded file be propagated to the loading environment. @overload load(filename, wrap=false) @return [true];T;0; @W ;@F;Ao;B;CT;Di;Ei;!@5;"I"Gstatic VALUE rb_f_load(int argc, VALUE *argv) { VALUE fname, wrap, path, orig_fname; rb_scan_args(argc, argv, "11", &fname, &wrap); orig_fname = rb_get_path_check_to_string(fname, rb_safe_level()); fname = rb_str_encode_ospath(orig_fname); RUBY_DTRACE_HOOK(LOAD_ENTRY, RSTRING_PTR(orig_fname)); path = rb_find_file(fname); if (!path) { if (!rb_file_load_ok(RSTRING_PTR(fname))) load_failed(orig_fname); path = fname; } rb_load_internal(path, RTEST(wrap)); RUBY_DTRACE_HOOK(LOAD_RETURN, RSTRING_PTR(orig_fname)); return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#require;F;[[I" fname;T0;[[@] i2;T;: require;0;[;{;IC;"ELoads the given +name+, returning +true+ if successful and +false+ if the feature is already loaded. If the filename does not resolve to an absolute path, it will be searched for in the directories listed in $LOAD_PATH ($:). 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;H ;II" overload;F;J0;;;K0;#I"require(name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @y ;[;I"@return [Boolean];T;0; @y ;@F;Mi;N0;[[I" name;T0; @y ;[;I"tLoads the given +name+, returning +true+ if successful and +false+ if the feature is already loaded. If the filename does not resolve to an absolute path, it will be searched for in the directories listed in $LOAD_PATH ($:). 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; @y ;@F;Ao;B;CT;Di;Ei/;!@5;"I"gVALUE rb_f_require(VALUE obj, VALUE fname) { return rb_require_safe(fname, rb_safe_level()); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#require_relative;F;[[I" fname;T0;[[@] i@;T;:require_relative;0;[;{;IC;"Ruby tries to load the library named _string_ relative to the requiring file's path. If the file's path cannot be determined a LoadError is raised. If a file is loaded +true+ is returned and false otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I"require_relative(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di8;Ei>;!@5;"I"VALUE rb_f_require_relative(VALUE obj, VALUE fname) { VALUE base = rb_current_realfilepath(); if (NIL_P(base)) { rb_loaderror("cannot infer basepath"); } base = rb_file_dirname(base); return rb_require_safe(rb_file_absolute_path(fname, base), rb_safe_level()); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#autoload;F;[[I"sym;T0[I" file;T0;[[@] i;T;: autoload;0;[;{;IC;"Registers _filename_ to be loaded (using Kernel::require) the first time that _module_ (which may be a String or a symbol) is accessed. autoload(:MyModule, "/usr/local/lib/modules/my_module.rb") ;T;[o;H ;II" overload;F;J0;;;K0;#I"autoload(module, filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_f_autoload(VALUE obj, VALUE sym, VALUE file) { VALUE klass = rb_class_real(rb_vm_cbase()); if (NIL_P(klass)) { rb_raise(rb_eTypeError, "Can not set autoload on singleton class"); } return rb_mod_autoload(klass, sym, file); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#autoload?;F;[[I"sym;T0;[[@] i;T;:autoload?;0;[;{;IC;"Returns _filename_ to be loaded if _name_ is registered as +autoload+. autoload(:B, "b") autoload?(:B) #=> "b";T;[o;H ;II" overload;F;J0;;;K0;#I"autoload?(name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" name;T0; @ ;[;I"Returns _filename_ to be loaded if _name_ is registered as +autoload+. autoload(:B, "b") autoload?(:B) #=> "b" @overload autoload?(name) @return [String, nil];T;0; @ ;@F;Ao;B;CT;Di;Ei;Mi;!@5;"I"static VALUE rb_f_autoload_p(VALUE obj, VALUE sym) { /* 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(klass, sym); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#proc;F;[;[[@i;T;: proc;0;[;{;IC;")Equivalent to Proc.new. ;T;[o;H ;II" overload;F;J0;;;K0;#I" proc;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"...;T; @ o;L ;II" return;F;JI";T;0;K[I" Proc;T; @ ;[;I" @yield [...] @return [Proc];T;0; @ ;@F;Mi;N0;[; @ ;[;I"ZEquivalent to Proc.new. @overload proc @yield [...] @return [Proc];T;0; @ ;@F;Ao;B;CT;Di;Ei ;!@5;"I"HVALUE rb_block_proc(void) { return proc_new(rb_cProc, FALSE); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#lambda;F;[;[[@i;T;: lambda;0;[;{;IC;"~Equivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called. ;T;[o;H ;II" overload;F;J0;;;K0;#I" lambda;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"...;T; @ o;L ;II" return;F;JI";T;0;K[I" Proc;T; @ ;[;I" @yield [...] @return [Proc];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di;Ei;!@5;"I"IVALUE rb_block_lambda(void) { return proc_new(rb_cProc, TRUE); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#binding;F;[;[[@iS;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;H ;II" overload;F;J0;;;K0;#I" binding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Binding;T; @6 ;[;I"@return [Binding];T;0; @6 ;@F;Mi;N0;[; @6 ;[;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; @6 ;@F;Ao;B;CT;DiC;EiP;!@5;"I"Kstatic VALUE rb_f_binding(VALUE self) { return rb_binding_new(); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#eval;F;[[@0;[[@&i];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;H ;II" overload;F;J0;;;K0;#I"4eval(string [, binding [, filename [,lineno]]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @Q ;[;I"@return [Object];T;0; @Q ;@F;Mi;N0;[[I"-string[, binding [, filename [,lineno]]];T0; @Q ;[;I"7Evaluates 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; @Q ;@F;Ao;B;CT;DiK;EiZ;!@5;"I"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; ; F; ;,;;;I"Kernel#local_variables;F;[;[[@&i ;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;H ;II" overload;F;J0;;;K0;#I"local_variables;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @o ;[;I"@return [Array];T;0; @o ;@F;Mi;N0;[; @o ;[;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; @o ;@F;Ao;B;CT;Di;Ei ;!@5;"I"static VALUE rb_f_local_variables(void) { 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; ; F; ;,;;;I"Kernel#iterator?;F;[;[[@&iF;T;:iterator?;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;H ;II" overload;F;J0;:block_given?;K0;#I"block_given?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I"iterator?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[; @ ;[;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] @overload iterator? @return [Boolean];T;0; @ ;@F;Ao;B;CT;Di0;EiC;Mi;!@5;"I"Ostatic VALUE rb_f_block_given_p(void) { 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)); if (cfp != NULL && VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE) { return Qtrue; } else { return Qfalse; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#block_given?;F;[;[[@&iF;T;;;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;H ;II" overload;F;J0;;;K0;#I"block_given?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I"iterator?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di0;EiC;Mi;!@5;"I"Ostatic VALUE rb_f_block_given_p(void) { 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)); if (cfp != NULL && VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE) { return Qtrue; } else { return Qfalse; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#catch;F;[[@0;[[@&i;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;H ;II" overload;F;J0;;;K0;#I"catch([tag]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"tag;T; @ o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I""@yield [tag] @return [Object];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Dio;Ei;!@5;"I"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; ; F; ;,;;;I"Kernel#throw;F;[[@0;[[@&i@;T;: throw;0;[;{;IC;"1Transfers 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;H ;II" overload;F;J0;;;K0;#I"throw(tag [, obj]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"tag[, obj];T0; @ ;[;I"PTransfers 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; @ ;@F;Ao;B;CT;Di4;Ei<;!@5;"I"static VALUE rb_f_throw(int argc, VALUE *argv) { 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; ; F; ;,;;;I"Kernel#loop;F;[;[[@&iP;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;H ;II" overload;F;J0;;;K0;#I" loop;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" loop;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di2;EiM;!@5;"I"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; ; F; ;,;;;I"(Kernel#register_sample_bug_reporter;F;[[I"obj;T0;[[I"+ext/-test-/bug_reporter/bug_reporter.c;Ti;T;:!register_sample_bug_reporter;0;[;{;IC;" ;T;[;[;@;0; @6;!@5;"I"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; ; F; ;,;;;I"Kernel#caller;F;[[@0;[[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;H ;II" overload;F;J0;;;K0;#I" caller(start=1, length=nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @E;[;I"@return [Array, nil];T;0; @E;@F;Mi;N0;[[I" start;TI"1;T[I" length;TI"nil;T; @Eo;H ;II" overload;F;J0;;;K0;#I"caller(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @E;[;I"@return [Array, nil];T;0; @E;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@5;"I"wstatic VALUE rb_f_caller(int argc, VALUE *argv) { return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#caller_locations;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I":caller_locations(start=1, length=nil) -> array or nil;T;IC;";T;[;[;I";T;0; @y;@F;Mi;N0;[[I" start;TI"1;T[I" length;TI"nil;T; @yo;H ;II" overload;F;J0;;;K0;#I".caller_locations(range) -> array or nil;T;IC;";T;[;[;I";T;0; @y;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@5;"I"|static VALUE rb_f_caller_locations(int argc, VALUE *argv) { return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#callcc;F;[;[[I" cont.c;Ti;T;: callcc;0;[;{;IC;"Generates a Continuation object, which it passes to the associated block. You need to require 'continuation' before using this method. Performing a cont.call will cause the #callcc to return (as will falling through the end of the block). The value returned by the #callcc is the value of the block, or the value passed to cont.call. See class Continuation for more details. Also see Kernel#throw for an alternative mechanism for unwinding a call stack. ;T;[o;H ;II" overload;F;J0;;;K0;#I" callcc;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" cont;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"#@yield [cont] @return [Object];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_callcc(VALUE self) { volatile int called; volatile VALUE val = cont_capture(&called); if (called) { return val; } else { return rb_yield(val); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#exec;F;[[@0;[[I"process.c;Ti{ ;T;: exec;0;[;{;IC;"A 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, same as ENV["RUBYSHELL"] (or ENV["COMSPEC"] on Windows NT series), and similar. If the string from the first form (exec("command")) follows these simple rules: * no meta characters * no shell reserved word and no 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;H ;II" overload;F;J0;;;K0;#I"'exec([env,] command... [,options]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[env,][,options];T0; @;[;I"p 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, same as ENV["RUBYSHELL"] (or ENV["COMSPEC"] on Windows NT series), and similar. If the string from the first form (exec("command")) follows these simple rules: * no meta characters * no shell reserved word and no 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; @;@F;Ao;B;CT;Di2 ;Eiw ;!@5;"I"7VALUE rb_f_exec(int argc, const VALUE *argv) { VALUE execarg_obj, fail_str; struct rb_execarg *eargp; #define CHILD_ERRMSG_BUFLEN 80 char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; int err, state; execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE); eargp = rb_execarg_get(execarg_obj); if (mjit_enabled) mjit_finish(FALSE); /* avoid leaking resources, and do not leave files. XXX: JIT-ed handle can leak after exec error is rescued. */ before_exec(); /* stop timer thread before redirects */ rb_protect(rb_execarg_parent_start1, execarg_obj, &state); if (state) { execarg_parent_end(execarg_obj); after_exec(); /* restart timer thread */ rb_jump_tag(state); } fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; err = exec_async_signal_safe(eargp, errmsg, sizeof(errmsg)); after_exec(); /* restart timer thread */ rb_exec_fail(eargp, err, errmsg); RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(err, fail_str); UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#fork;F;[;[;F;: fork;;0;[;{;IC;" ;T;[;[;@;0; @;!@5;$To; ; F; ;,;;;I"Kernel#exit!;F;[[@0;[[@iB;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;H ;II" overload;F;J0;;;K0;#I"exit!(status=false);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di7;Ei>;!@5;"I"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; ; F; ;,;;;I"Kernel#system;F;[[@0;[[@ij;T;: system;0;[;{;IC;"uExecutes _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 $?. 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 * See Kernel.exec for the standard shell. ;T;[o;H ;II" overload;F;J0;;;K0;#I")system([env,] command... [,options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @;[;I"@return [true, false, nil];T;0; @;@F;Mi;N0;[[I"[env,][,options];T0; @;[;I"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 $?. 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 * See Kernel.exec for the standard shell. @overload system([env,] command... [,options]) @return [true, false, nil];T;0; @;@F;Ao;B;CT;DiI;Eig;!@5;"I"`static VALUE rb_f_system(int argc, VALUE *argv) { /* * n.b. using alloca for now to simplify future Thread::Light code * when we need to use malloc for non-native Fiber */ struct waitpid_state *w = alloca(sizeof(struct waitpid_state)); rb_pid_t pid; /* may be different from waitpid_state.pid on exec failure */ VALUE execarg_obj; struct rb_execarg *eargp; int exec_errnum; execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE); eargp = rb_execarg_get(execarg_obj); w->ec = GET_EC(); waitpid_state_init(w, 0, 0); eargp->waitpid_state = w; pid = rb_execarg_spawn(execarg_obj, 0, 0); exec_errnum = pid < 0 ? errno : 0; #if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) if (w->pid > 0) { /* `pid' (not w->pid) may be < 0 here if execve failed in child */ if (WAITPID_USE_SIGCHLD) { rb_ensure(waitpid_sleep, (VALUE)w, waitpid_cleanup, (VALUE)w); } else { waitpid_no_SIGCHLD(w); } rb_last_status_set(w->status, w->ret); } #endif if (w->pid < 0 /* fork failure */ || pid < 0 /* exec failure */) { if (eargp->exception) { int err = exec_errnum ? exec_errnum : w->errnum; VALUE command = eargp->invoke.sh.shell_script; RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(err, command); } else { return Qnil; } } if (w->status == EXIT_SUCCESS) return Qtrue; 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, w->status), ": "); rb_str_append(str, command); RB_GC_GUARD(execarg_obj); rb_exc_raise(rb_exc_new_str(rb_eRuntimeError, str)); } else { return Qfalse; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#spawn;F;[[@0;[[@i;T;: spawn;0;[;{;IC;"a*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;H ;II" overload;F;J0;;;K0;#I"(spawn([env,] command... [,options]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[env,][,options];T0; @o;H ;II" overload;F;J0;;;K0;#I"(spawn([env,] command... [,options]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_f_spawn(int argc, VALUE *argv) { 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; ; F; ;,;;;I"Kernel#sleep;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"sleep([duration]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @A;[;I"@return [Integer];T;0; @A;@F;Mi;N0;[[I"[duration];T0; @A;[;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; @A;@F;Ao;B;CT;Di;Ei;!@5;"I"$static VALUE rb_f_sleep(int argc, VALUE *argv) { time_t beg, end; beg = time(0); if (argc == 0) { rb_thread_sleep_forever(); } else { rb_check_arity(argc, 0, 1); rb_thread_wait_for(rb_time_interval(argv[0])); } end = time(0) - beg; return INT2FIX(end); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#exit;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"exit(status=true);T;IC;";T;[;[;I";T;0; @_;@F;Mi;N0;[[I" status;TI" true;T; @_o;H ;II" overload;F;J0;:Kernel::exit;K0;#I"Kernel::exit(status=true);T;IC;";T;[;[;I";T;0; @_;@F;Mi;N0;[[I" status;TI" true;T; @_o;H ;II" overload;F;J0;:Process::exit;K0;#I"Process::exit(status=true);T;IC;";T;[;[;I";T;0; @_;@F;Mi;N0;[[I" status;TI" true;T; @_;[;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; @_;@F;Ao;B;CT;Di`;Ei;!@5;"I"VALUE rb_f_exit(int argc, const VALUE *argv) { int istatus; if (rb_check_arity(argc, 0, 1) == 1) { istatus = exit_status_code(argv[0]); } else { istatus = EXIT_SUCCESS; } rb_exit(istatus); UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#abort;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I" abort;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:Kernel::abort;K0;#I"Kernel::abort([msg]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" [msg];T0; @o;H ;II" overload;F;J0;;;K0;#I"abort([msg]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" [msg];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@5;"I"VALUE rb_f_abort(int argc, const VALUE *argv) { rb_check_arity(argc, 0, 1); if (argc == 0) { rb_execution_context_t *ec = GET_EC(); VALUE errinfo = ec->errinfo; if (!NIL_P(errinfo)) { rb_ec_error_print(ec, errinfo); } rb_exit(EXIT_FAILURE); } else { VALUE args[2]; args[1] = args[0] = argv[0]; StringValue(args[0]); rb_io_puts(1, args, rb_stderr); args[0] = INT2NUM(EXIT_FAILURE); rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit)); } UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#warn;F;[[@0;[[I" error.c;Ti[;T;: warn;0;[;{;IC;"If warnings have been disabled (for example with the -W0 flag), does nothing. Otherwise, converts each of the messages to strings, appends a newline character to the string if the string does not end in a newline, and calls Warning.warn with the string. warn("warning 1", "warning 2") produces: warning 1 warning 2 If the uplevel keyword argument is given, the string will be prepended with information for the given caller frame in the same format used by the rb_warn C function. # In baz.rb def foo warn("invalid call to foo", uplevel: 1) end def bar foo end bar produces: baz.rb:6: warning: invalid call to foo ;T;[o;H ;II" overload;F;J0;;;K0;#I"warn(msg, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"msg;T0[I"...;T0; @;[;I" If warnings have been disabled (for example with the -W0 flag), does nothing. Otherwise, converts each of the messages to strings, appends a newline character to the string if the string does not end in a newline, and calls Warning.warn with the string. warn("warning 1", "warning 2") produces: warning 1 warning 2 If the uplevel keyword argument is given, the string will be prepended with information for the given caller frame in the same format used by the rb_warn C function. # In baz.rb def foo warn("invalid call to foo", uplevel: 1) end def bar foo end bar produces: baz.rb:6: warning: invalid call to foo @overload warn(msg, ...) @return [nil];T;0; @;@F;Ao;B;CT;Di6;EiX;!@5;"I"static VALUE rb_warn_m(int argc, VALUE *argv, VALUE exc) { VALUE opts, location = Qnil; if (!NIL_P(ruby_verbose) && argc > 0 && (argc = rb_scan_args(argc, argv, "*:", NULL, &opts)) > 0) { VALUE str = argv[0], uplevel = Qnil; if (!NIL_P(opts)) { static ID kwds[1]; if (!kwds[0]) { CONST_ID(kwds[0], "uplevel"); } rb_get_kwargs(opts, kwds, 0, 1, &uplevel); if (uplevel == Qundef) { uplevel = Qnil; } else if (!NIL_P(uplevel)) { VALUE args[2]; long lev = NUM2LONG(uplevel); if (lev < 0) { rb_raise(rb_eArgError, "negative level (%ld)", lev); } args[0] = LONG2NUM(lev + 1); args[1] = INT2FIX(1); location = rb_vm_thread_backtrace_locations(2, args, GET_THREAD()->self); if (!NIL_P(location)) { location = rb_ary_entry(location, 0); } } } if (argc > 1 || !NIL_P(uplevel) || !end_with_asciichar(str, '\n')) { VALUE path; if (NIL_P(uplevel)) { str = rb_str_tmp_new(0); } else if (NIL_P(location) || NIL_P(path = rb_funcall(location, rb_intern("path"), 0))) { str = rb_str_new_cstr("warning: "); } else { str = rb_sprintf("%s:%ld: warning: ", rb_string_value_ptr(&path), NUM2LONG(rb_funcall(location, rb_intern("lineno"), 0))); } RBASIC_SET_CLASS(str, rb_cWarningBuffer); rb_io_puts(argc, argv, str); RBASIC_SET_CLASS(str, rb_cString); } if (exc == rb_mWarning) { rb_must_asciicompat(str); rb_write_error_str(str); } else { rb_write_warning_str(str); } } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#raise;F;[[@0;[[@i;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 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. raise "Failed to create socket" raise ArgumentError, "No parameters", caller The +cause+ of the generated exception 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. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" raise;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"raise(string, cause: $!);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0[I" cause:;TI"$!;T; @o;H ;II" overload;F;J0;;;K0;#I"5raise(exception [, string [, array]], cause: $!);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T; @o;H ;II" overload;F;J0;: fail;K0;#I" fail;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"fail(string, cause: $!);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0[I" cause:;TI"$!;T; @o;H ;II" overload;F;J0;;;K0;#I"4fail(exception [, string [, array]], cause: $!);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T; @;[;I"YWith 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 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. raise "Failed to create socket" raise ArgumentError, "No parameters", caller The +cause+ of the generated exception 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. @overload raise @overload raise(string, cause: $!) @overload raise(exception [, string [, array]], cause: $!) @overload fail @overload fail(string, cause: $!) @overload fail(exception [, string [, array]], cause: $!);T;0; @;@F;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_f_raise(int argc, VALUE *argv) { VALUE err; VALUE opts[raise_max_opt], *const cause = &opts[raise_opt_cause]; argc = extract_raise_opts(argc, argv, opts); if (argc == 0) { if (*cause != Qundef) { rb_raise(rb_eArgError, "only cause is given with no arguments"); } err = get_errinfo(); if (!NIL_P(err)) { argc = 1; argv = &err; } } rb_raise_jump(rb_make_exception(argc, argv), *cause); UNREACHABLE_RETURN(Qnil); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#fail;F;[[@0;[[@i;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 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. raise "Failed to create socket" raise ArgumentError, "No parameters", caller The +cause+ of the generated exception 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. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" raise;T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[; @.o;H ;II" overload;F;J0;;;K0;#I"raise(string, cause: $!);T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[[I" string;T0[I" cause:;TI"$!;T; @.o;H ;II" overload;F;J0;;;K0;#I"5raise(exception [, string [, array]], cause: $!);T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T; @.o;H ;II" overload;F;J0;;;K0;#I" fail;T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[; @.o;H ;II" overload;F;J0;;;K0;#I"fail(string, cause: $!);T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[[I" string;T0[I" cause:;TI"$!;T; @.o;H ;II" overload;F;J0;;;K0;#I"4fail(exception [, string [, array]], cause: $!);T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T; @.;[;@*;0; @.;@F;Ao;B;CT;Di;Ei;!@5;"I"static VALUE rb_f_raise(int argc, VALUE *argv) { VALUE err; VALUE opts[raise_max_opt], *const cause = &opts[raise_opt_cause]; argc = extract_raise_opts(argc, argv, opts); if (argc == 0) { if (*cause != Qundef) { rb_raise(rb_eArgError, "only cause is given with no arguments"); } err = get_errinfo(); if (!NIL_P(err)) { argc = 1; argv = &err; } } rb_raise_jump(rb_make_exception(argc, argv), *cause); UNREACHABLE_RETURN(Qnil); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#global_variables;F;[;[[@$i;T;:global_variables;0;[;{;IC;"{Returns an array of the names of global variables. global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr] ;T;[o;H ;II" overload;F;J0;;;K0;#I"global_variables;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Returns an array of the names of global variables. global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr] @overload global_variables @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@5;"I"sVALUE rb_f_global_variables(void) { VALUE ary = rb_ary_new(); VALUE sym, backref = rb_backref_get(); rb_id_table_foreach(rb_global_tbl, gvar_i, (void *)ary); if (!NIL_P(backref)) { char buf[2]; int i, nmatch = rb_match_count(backref); buf[0] = '$'; for (i = 1; i <= nmatch; ++i) { if (!rb_match_nth_defined(i, backref)) continue; if (i < 10) { /* probably reused, make static ID */ buf[1] = (char)(i + '0'); sym = ID2SYM(rb_intern2(buf, 2)); } else { /* dynamic symbol */ sym = rb_str_intern(rb_sprintf("$%d", i)); } rb_ary_push(ary, sym); } } return ary; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#__method__;F;[;[[@iQ;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;H ;II" overload;F;J0;;;K0;#I"__method__;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"Returns the name at the definition of the current method as a Symbol. If called outside of a method, it returns nil. @overload __method__;T;0; @;@F;Ao;B;CT;DiG;EiM;!@5;"I"static VALUE rb_f_method_name(void) { ID fname = prev_frame_func(); /* need *method* ID */ if (fname) { return ID2SYM(fname); } else { return Qnil; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#__callee__;F;[;[[@ig;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;H ;II" overload;F;J0;;;K0;#I"__callee__;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di^;Eic;!@5;"I"static VALUE rb_f_callee_name(void) { ID fname = prev_frame_callee(); /* need *callee* ID */ if (fname) { return ID2SYM(fname); } else { return Qnil; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#__dir__;F;[;[[@i~;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;H ;II" overload;F;J0;;;K0;#I" __dir__;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Dit;Ei|;!@5;"I"static VALUE f_current_dirname(void) { VALUE base = rb_current_realfilepath(); if (NIL_P(base)) { return Qnil; } base = rb_file_dirname(base); return base; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#trace_var;F;[[@0;[[@$i;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;H ;II" overload;F;J0;;;K0;#I"trace_var(symbol, cmd );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"cmd;T0; @o;H ;II" overload;F;J0;;;K0;#I"trace_var(symbol);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"val;T; @o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@yield [val] @return [nil];T;0; @;@F;Mi;N0;[[I" symbol;T0; @;[;I"}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' @overload trace_var(symbol, cmd ) @return [nil] @overload trace_var(symbol) @yield [val] @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@5;"I"VALUE rb_f_trace_var(int argc, const VALUE *argv) { VALUE var, cmd; struct rb_global_entry *entry; struct trace_var *trace; if (rb_scan_args(argc, argv, "11", &var, &cmd) == 1) { cmd = rb_block_proc(); } if (NIL_P(cmd)) { return rb_f_untrace_var(argc, argv); } entry = rb_global_entry(rb_to_id(var)); if (OBJ_TAINTED(cmd)) { rb_raise(rb_eSecurityError, "Insecure: tainted variable trace"); } trace = ALLOC(struct trace_var); trace->next = entry->var->trace; trace->func = rb_trace_eval; trace->data = cmd; trace->removed = 0; entry->var->trace = trace; return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#untrace_var;F;[[@0;[[@$i;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;H ;II" overload;F;J0;;;K0;#I"!untrace_var(symbol [, cmd] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei ;!@5;"I"VALUE rb_f_untrace_var(int argc, const VALUE *argv) { VALUE var, cmd; ID id; struct rb_global_entry *entry; struct trace_var *trace; VALUE data; rb_scan_args(argc, argv, "11", &var, &cmd); id = rb_check_id(&var); if (!id) { rb_name_error_str(var, "undefined global variable %"PRIsVALUE"", QUOTE(var)); } if (!rb_id_table_lookup(rb_global_tbl, id, &data)) { rb_name_error(id, "undefined global variable %"PRIsVALUE"", QUOTE_ID(id)); } trace = (entry = (struct rb_global_entry *)data)->var->trace; if (NIL_P(cmd)) { VALUE ary = rb_ary_new(); while (trace) { struct trace_var *next = trace->next; rb_ary_push(ary, (VALUE)trace->data); trace->removed = 1; trace = next; } if (!entry->var->block_trace) remove_trace(entry->var); return ary; } else { while (trace) { if (trace->data == cmd) { trace->removed = 1; if (!entry->var->block_trace) remove_trace(entry->var); return rb_ary_new3(1, cmd); } trace = trace->next; } } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Kernel#BigDecimal;F;[[@0;[[I" ext/bigdecimal/bigdecimal.c;Ti ;T;:BigDecimal;0;[;{;IC;"Create a new BigDecimal object. initial:: The initial value, as an Integer, a Float, a Rational, a BigDecimal, or a String. If it is a String, spaces are ignored and unrecognized characters terminate the value. digits:: The number of significant digits, as an Integer. If omitted or 0, the number of significant digits is determined from the initial value. The actual number of significant digits used in computation is usually larger than the specified number. exception:: Whether an exception should be raised on invalid arguments. +true+ by default, if passed +false+, just returns +nil+ for invalid. ==== Exceptions TypeError:: If the +initial+ type is neither Integer, Float, Rational, nor BigDecimal, this exception is raised. TypeError:: If the +digits+ is not an Integer, this exception is raised. ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than Float::DIG + 1, this exception is raised. ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+ value is omitted, this exception is raised. ;T;[o;H ;II" overload;F;J0;;;K0;#I"1BigDecimal(initial, digits, exception: true);T;IC;";T;[;[;I";T;0; @5;@F;Mi;N0;[[I" initial;T0[I" digits;T0[I"exception:;TI" true;T; @5;[;I"Create a new BigDecimal object. initial:: The initial value, as an Integer, a Float, a Rational, a BigDecimal, or a String. If it is a String, spaces are ignored and unrecognized characters terminate the value. digits:: The number of significant digits, as an Integer. If omitted or 0, the number of significant digits is determined from the initial value. The actual number of significant digits used in computation is usually larger than the specified number. exception:: Whether an exception should be raised on invalid arguments. +true+ by default, if passed +false+, just returns +nil+ for invalid. ==== Exceptions TypeError:: If the +initial+ type is neither Integer, Float, Rational, nor BigDecimal, this exception is raised. TypeError:: If the +digits+ is not an Integer, this exception is raised. ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than Float::DIG + 1, this exception is raised. ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+ value is omitted, this exception is raised. @overload BigDecimal(initial, digits, exception: true);T;0; @5;@F;Ao;B;CT;Din ;Ei ;!@5;"I"static VALUE f_BigDecimal(int argc, VALUE *argv, VALUE self) { ENTER(1); Real *pv; VALUE obj; obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0); pv = BigDecimal_new(argc, argv); if (pv == NULL) return Qnil; SAVE(pv); if (ToValue(pv)) pv = VpCopy(NULL, pv); RTYPEDDATA_DATA(obj) = pv; RB_OBJ_FREEZE(obj); return pv->obj = obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#Pathname;F;[[I"str;T0;[[I"ext/pathname/pathname.c;Ti*;T;: Pathname;0;[;{;IC;"Y:call-seq: Pathname(path) -> pathname Creates a new Pathname object from the given string, +path+, and returns pathname object. In order to use this constructor, you must first require the Pathname standard library extension. require 'pathname' Pathname("/home/zzak") #=> # See also Pathname::new for more information. ;T;[;[;I"Z:call-seq: Pathname(path) -> pathname Creates a new Pathname object from the given string, +path+, and returns pathname object. In order to use this constructor, you must first require the Pathname standard library extension. require 'pathname' Pathname("/home/zzak") #=> # See also Pathname::new for more information. ;T;0; @T;@F;Ao;B;CT;Di;Ei(;!@5;"I"ustatic VALUE path_f_pathname(VALUE self, VALUE str) { return rb_class_new_instance(1, &str, rb_cPathname); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Kernel#test;F;[[@0;[[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;H ;II" overload;F;J0;;;K0;#I" test(cmd, file1 [, file2] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @e;[;I"@return [Object];T;0; @e;@F;Mi;N0;[[I"cmd;T0[I"file1[, file2];T0; @e;[;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; @e;@F;Ao;B;CT;DiT;Ei;!@5;"I"c static VALUE rb_f_test(int argc, VALUE *argv) { int cmd; if (argc == 0) rb_check_arity(argc, 2, 3); cmd = NUM2CHR(argv[0]); if (cmd == 0) { 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); } } 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; } } goto unknown; };T;#I"static VALUE;T;$T;&@5;'IC;[;&@5;(IC;[;&@5;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i";T;: Kernel;;0;;;[;{;IC;"FThe 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";T;[;[;I"I 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" ;T;0; @5;@F;Ao;B;CT;Di;Ei ;Mi;!@;I" Kernel;F;&@<;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i[@i%;T;;6;;0;;;[;{;IC;"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).;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). ;T;0; @<;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Object;F;1o; ;IC;[o; ; F; ;,;: private;I"BasicObject#initialize;F;[;[[@iv;T;:initialize;0;[;{;IC;"Not documented ;T;[;[;I"Not documented ;T;0; @;@F;Ao;B;CT;Dir;Eis;!@;"I"9static VALUE rb_obj_dummy(void) { return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BasicObject#==;F;[[I" obj2;T0;[[@i;T;;S;0;[;{;IC;"Equality --- At the Object level, == returns true only if +obj+ and +other+ are the same object. Typically, this method is overridden in descendant classes to provide class-specific meaning. Unlike ==, the equal? method should never be overridden by subclasses as it is used to determine object identity (that is, a.equal?(b) if and only if a is the same object as b): obj = "a" other = obj.dup obj == other #=> true obj.equal? other #=> false obj.equal? obj #=> true The eql? method returns true if +obj+ and +other+ refer to the same hash key. This is used by Hash to test members for equality. For 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;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @o;H ;II" overload;F;J0;;T;K0;#I"equal?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;@';0; @;@F;Ao;B;CT;Di;Ei;!@;"I"}MJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { if (obj1 == obj2) return Qtrue; return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"BasicObject#equal?;F;[[I" obj2;T0;[[@i;T;;T;0;[;{;IC;"Equality --- At the Object level, == returns true only if +obj+ and +other+ are the same object. Typically, this method is overridden in descendant classes to provide class-specific meaning. Unlike ==, the equal? method should never be overridden by subclasses as it is used to determine object identity (that is, a.equal?(b) if and only if a is the same object as b): obj = "a" other = obj.dup obj == other #=> true obj.equal? other #=> false obj.equal? obj #=> true The eql? method returns true if +obj+ and +other+ refer to the same hash key. This is used by Hash to test members for equality. For 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;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @o;H ;II" overload;F;J0;;T;K0;#I"equal?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;@';0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"}MJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { if (obj1 == obj2) return Qtrue; return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"BasicObject#!;F;[;[[@i;T;:!;0;[;{;IC;"Boolean negate. ;T;[o;H ;II" overload;F;J0;;;K0;#I" !obj;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[; @1;[;I":Boolean negate. @overload !obj @return [Boolean];T;0; @1;@F;Ao;B;CT;Di;Ei;!@;"I"_MJIT_FUNC_EXPORTED VALUE rb_obj_not(VALUE obj) { return RTEST(obj) ? Qfalse : Qtrue; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"BasicObject#!=;F;[[I" obj2;T0;[[@i;T;:!=;0;[;{;IC;"@Returns true if two objects are not-equal, otherwise false. ;T;[o;H ;II" overload;F;J0;;;K0;#I"!=(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @L;[;I"@return [Boolean];T;0; @L;@F;Mi;N0;[[I" other;T0; @L;[;I"kReturns true if two objects are not-equal, otherwise false. @overload !=(other) @return [Boolean];T;0; @L;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"'BasicObject#singleton_method_added;F;[;[[@iv;T;:singleton_method_added;0;[;{;IC;"Not documented ;T;[;[;@;0; @k;@F;Ao;B;CT;Dir;Eis;!@;"I"9static VALUE rb_obj_dummy(void) { return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I")BasicObject#singleton_method_removed;F;[;[[@iv;T;:singleton_method_removed;0;[;{;IC;"Not documented ;T;[;[;@;0; @x;@F;Ao;B;CT;Dir;Eis;!@;"I"9static VALUE rb_obj_dummy(void) { return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"+BasicObject#singleton_method_undefined;F;[;[[@iv;T;:singleton_method_undefined;0;[;{;IC;"Not documented ;T;[;[;@;0; @;@F;Ao;B;CT;Dir;Eis;!@;"I"9static VALUE rb_obj_dummy(void) { return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BasicObject#instance_eval;F;[[@0;[[@&i;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;H ;II" overload;F;J0;;;K0;#I"3instance_eval(string [, filename [, lineno]] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I""string[, filename [, lineno]];T0; @o;H ;II" overload;F;J0;;;K0;#I"instance_eval;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I""@yield [obj] @return [Object];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Div;Ei;!@;"I"VALUE rb_obj_instance_eval(int argc, const VALUE *argv, VALUE self) { VALUE klass = singleton_class_for_eval(self); return specific_eval(argc, argv, klass, self); };T;#I" VALUE;T;$To; ; F; ;,;;;I"BasicObject#instance_exec;F;[[@0;[[@&i;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;H ;II" overload;F;J0;;;K0;#I"instance_exec(arg...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" var...;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"%@yield [var...] @return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_obj_instance_exec(int argc, const VALUE *argv, VALUE self) { VALUE klass = singleton_class_for_eval(self); return yield_under(klass, self, argc, argv); };T;#I" VALUE;T;$To; ; F; ;,;;;I"BasicObject#method_missing;F;[[@0;[[@&i;T;:method_missing;0;[;{;IC;"zInvoked 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(methId) str = methId.id2name roman_to_int(str) end end r = Roman.new r.iv #=> 4 r.xxiii #=> 23 r.mm #=> 2000 ;T;[o;H ;II" overload;F;J0;;;K0;#I"&method_missing(symbol [, *args] );T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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(methId) str = methId.id2name roman_to_int(str) end end r = Roman.new r.iv #=> 4 r.xxiii #=> 23 r.mm #=> 2000 @overload method_missing(symbol [, *args] );T;0; @;@F;Ao;B;CT;Di_;Ei|;!@;"I"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; ; F; ;,;;;I"BasicObject#__send__;F;[[@0;[[@&i;T;;~;0;[;{;IC;"Invokes the method identified by _symbol_, passing it any arguments specified. You can use __send__ if the name +send+ clashes with an existing method in _obj_. When the method is identified by a string, the string is converted to a symbol. class Klass def hello(*args) "Hello " + args.join(' ') end end k = Klass.new k.send :hello, "gentle", "readers" #=> "Hello gentle readers" ;T;[ o;H ;II" overload;F;J0;;};K0;#I"send(symbol [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"symbol[, args...];T0; @o;H ;II" overload;F;J0;;~;K0;#I"!__send__(symbol [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"symbol[, args...];T0; @o;H ;II" overload;F;J0;;};K0;#I"send(string [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"string[, args...];T0; @o;H ;II" overload;F;J0;;~;K0;#I"!__send__(string [, args...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"string[, args...];T0; @;[;@h;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"sVALUE rb_f_send(int argc, VALUE *argv, VALUE recv) { return send_internal(argc, argv, recv, CALL_FCALL); };T;#I" VALUE;T;$To; ; F; ;,;;;I"BasicObject#__id__;F;[;[[@i ;T;: __id__;0;[;{;IC;"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. 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; @H;@F;Ao;B;CT;Di ;Ei ;!@;"I"HVALUE 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 */ if (STATIC_SYM_P(obj)) { return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG; } else if (FLONUM_P(obj)) { #if SIZEOF_LONG == SIZEOF_VOIDP return LONG2NUM((SIGNED_VALUE)obj); #else return LL2NUM((SIGNED_VALUE)obj); #endif } else if (SPECIAL_CONST_P(obj)) { return LONG2NUM((SIGNED_VALUE)obj); } return nonspecial_obj_id(obj); };T;#I" VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i[@i$;T;:BasicObject;;0;;;[;{;IC;"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) 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;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) 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 ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;I"BasicObject;F;1o;2 ;30;40;50;: Qnil;!@;70;F;;F;o; ;IC;[ o; ; F; ;,;;;I"Bug::Proc#inspector;F;[;[[I"!ext/-test-/debug/inspector.c;Ti;T;:inspector;0;[;{;IC;" ;T;[;[;I";F;0; @k;@F;N0;!@i;"I"estatic VALUE debug_inspector(VALUE self) { return rb_debug_inspector_open(callback, NULL); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Bug::Proc.inspector;F;@m;@n;T;;;0;@q;{;IC;" ;T;[;[;@;0; @y;Mi;!@i;"@w;#@x;$To; ; F; ;,;;;I"Bug::Proc#profile_frames;F;[[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; @;@F;N0;!@i;"I"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 903 Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink, :chown, :EOFError, :$;, :String, :LOCK_SH, :"setuid?", :$<, :default_proc, :compact, :extend, :Tms, :getwd, :$=, :ThreadGroup, :wait2, :$>] ;T;[o;H ;II" overload;F;J0;;;K0;#I"all_symbols;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @v;[;I"@return [Array];T;0; @v;@F;Mi;N0;[; @v;[;I"Returns an array of all the symbols currently in Ruby's symbol table. Symbol.all_symbols.size #=> 903 Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink, :chown, :EOFError, :$;, :String, :LOCK_SH, :"setuid?", :$<, :default_proc, :compact, :extend, :Tms, :getwd, :$=, :ThreadGroup, :wait2, :$>] @overload all_symbols @return [Array];T;0; @v;@F;Ao;B;CT;DiS;Ei`;!@t;"I"VALUE rb_sym_all_symbols(void) { VALUE ary = rb_ary_new2(global_symbols.str_sym->num_entries); st_foreach(global_symbols.str_sym, symbols_i, ary); return ary; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Symbol#==;F;[;[;F;;S;;0;[;{;IC;" ;T;[;[;@;0; @;!@t;$To; ; F; ;,;;;I"Symbol#===;F;[;[;F;;O;;0;[;{;IC;" ;T;[;[;@;0; @;!@t;$To; ; F; ;,;;;I"Symbol#inspect;F;[;[[I" string.c;Ti);T;;i;0;[;{;IC;"bReturns the representation of sym as a symbol literal. :fred.inspect #=> ":fred" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"Returns the representation of sym as a symbol literal. :fred.inspect #=> ":fred" @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di);Ei);!@t;"I" static VALUE sym_inspect(VALUE sym) { VALUE str = rb_sym2str(sym); const char *ptr; long len; char *dest; if (!rb_str_symname_p(str)) { str = rb_str_inspect(str); len = RSTRING_LEN(str); rb_str_resize(str, len + 1); dest = RSTRING_PTR(str); memmove(dest + 1, dest, len); } else { rb_encoding *enc = STR_ENC_GET(str); RSTRING_GETMEM(str, ptr, len); str = rb_enc_str_new(0, len + 1, enc); dest = RSTRING_PTR(str); memcpy(dest + 1, ptr, len); } dest[0] = ':'; return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#to_s;F;[;[[@i);T;;h;0;[;{;IC;"{Returns the name or string corresponding to sym. :fred.id2name #=> "fred" :ginger.to_s #=> "ginger" ;T;[o;H ;II" overload;F;J0;: id2name;K0;#I" id2name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"Returns the name or string corresponding to sym. :fred.id2name #=> "fred" :ginger.to_s #=> "ginger" @overload id2name @return [String] @overload to_s @return [String];T;0; @;@F;Ao;B;CT;Di);Ei);!@t;"I"]VALUE rb_sym_to_s(VALUE sym) { return str_new_shared(rb_cString, rb_sym2str(sym)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Symbol#id2name;F;[;[[@i);T;;;0;[;{;IC;"{Returns the name or string corresponding to sym. :fred.id2name #=> "fred" :ginger.to_s #=> "ginger" ;T;[o;H ;II" overload;F;J0;;;K0;#I" id2name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di);Ei);!@t;"I"]VALUE rb_sym_to_s(VALUE sym) { return str_new_shared(rb_cString, rb_sym2str(sym)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Symbol#intern;F;[;[[@i);T;: intern;0;[;{;IC;"In general, to_sym returns the Symbol corresponding to an object. As sym is already a symbol, self is returned in this case. ;T;[o;H ;II" overload;F;J0;: to_sym;K0;#I" to_sym;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" intern;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"In general, to_sym returns the Symbol corresponding to an object. As sym is already a symbol, self is returned in this case. @overload to_sym @overload intern;T;0; @;@F;Ao;B;CT;Di);Ei);!@t;"I";static VALUE sym_to_sym(VALUE sym) { return sym; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#to_sym;F;[;[[@i);T;;;0;[;{;IC;"In general, to_sym returns the Symbol corresponding to an object. As sym is already a symbol, self is returned in this case. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_sym;T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[; @-o;H ;II" overload;F;J0;;;K0;#I" intern;T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[; @-;[;@);0; @-;@F;Ao;B;CT;Di);Ei);!@t;"I";static VALUE sym_to_sym(VALUE sym) { return sym; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#to_proc;F;[;[[@i);T;: to_proc;0;[;{;IC;"xReturns a _Proc_ object which responds to the given method by _sym_. (1..3).collect(&:to_s) #=> ["1", "2", "3"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_proc;T;IC;";T;[;[;I";T;0; @J;@F;Mi;N0;[; @J;[;I"Returns a _Proc_ object which responds to the given method by _sym_. (1..3).collect(&:to_s) #=> ["1", "2", "3"] @overload to_proc;T;0; @J;@F;Ao;B;CT;Di);Ei);!@t;"I"(VALUE rb_sym_to_proc(VALUE sym) { };T;#I" VALUE;T;$To; ; F; ;,;;;I"Symbol#succ;F;[;[[@i*;T;: succ;0;[;{;IC;"/Same as sym.to_s.succ.intern. ;T;[o;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[;[;I";T;0; @`;@F;Mi;N0;[; @`;[;I"@Same as sym.to_s.succ.intern. @overload succ;T;0; @`;@F;Ao;B;CT;Di);Ei*;!@t;"I"astatic VALUE sym_succ(VALUE sym) { return rb_str_intern(rb_str_succ(rb_sym2str(sym))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#next;F;[;[[@i*;T;: next;0;[;{;IC;"/Same as sym.to_s.succ.intern. ;T;[o;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[;[;I";T;0; @v;@F;Mi;N0;[; @v;[;@r;0; @v;@F;Ao;B;CT;Di);Ei*;!@t;"I"astatic VALUE sym_succ(VALUE sym) { return rb_str_intern(rb_str_succ(rb_sym2str(sym))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#<=>;F;[[I" other;T0;[[@i*;T;;V;0;[;{;IC;" Compares +symbol+ with +other_symbol+ after calling #to_s on each of the symbols. Returns -1, 0, +1, or +nil+ depending on whether +symbol+ is less than, equal to, or greater than +other_symbol+. +nil+ is returned if the two values are incomparable. See String#<=> for more information. ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(other_symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @;[;I"@return [-1, 0, +1, nil];T;0; @;@F;Mi;N0;[[I"other_symbol;T0; @;[;I"[Compares +symbol+ with +other_symbol+ after calling #to_s on each of the symbols. Returns -1, 0, +1, or +nil+ depending on whether +symbol+ is less than, equal to, or greater than +other_symbol+. +nil+ is returned if the two values are incomparable. See String#<=> for more information. @overload <=>(other_symbol) @return [-1, 0, +1, nil];T;0; @;@F;Ao;B;CT;Di *;Ei*;!@t;"I"static VALUE sym_cmp(VALUE sym, VALUE other) { if (!SYMBOL_P(other)) { return Qnil; } return rb_str_cmp_m(rb_sym2str(sym), rb_sym2str(other)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#casecmp;F;[[I" other;T0;[[@i8*;T;: casecmp;0;[;{;IC;"Case-insensitive version of Symbol#<=>. Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from Symbol#casecmp?. :aBcDeF.casecmp(:abcde) #=> 1 :aBcDeF.casecmp(:abcdef) #=> 0 :aBcDeF.casecmp(:abcdefg) #=> -1 :abcdef.casecmp(:ABCDEF) #=> 0 +nil+ is returned if the two symbols have incompatible encodings, or if +other_symbol+ is not a symbol. :foo.casecmp(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp(:"\u{c4 d6 dc}") #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"casecmp(other_symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @;[;I"@return [-1, 0, +1, nil];T;0; @;@F;Mi;N0;[[I"other_symbol;T0; @;[;I"WCase-insensitive version of Symbol#<=>. Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from Symbol#casecmp?. :aBcDeF.casecmp(:abcde) #=> 1 :aBcDeF.casecmp(:abcdef) #=> 0 :aBcDeF.casecmp(:abcdefg) #=> -1 :abcdef.casecmp(:ABCDEF) #=> 0 +nil+ is returned if the two symbols have incompatible encodings, or if +other_symbol+ is not a symbol. :foo.casecmp(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp(:"\u{c4 d6 dc}") #=> nil @overload casecmp(other_symbol) @return [-1, 0, +1, nil];T;0; @;@F;Ao;B;CT;Di$*;Ei5*;!@t;"I"static VALUE sym_casecmp(VALUE sym, VALUE other) { if (!SYMBOL_P(other)) { return Qnil; } return str_casecmp(rb_sym2str(sym), rb_sym2str(other)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#casecmp?;F;[[I" other;T0;[[@iU*;T;: casecmp?;0;[;{;IC;"!Returns +true+ if +sym+ and +other_symbol+ are equal after Unicode case folding, +false+ if they are not equal. :aBcDeF.casecmp?(:abcde) #=> false :aBcDeF.casecmp?(:abcdef) #=> true :aBcDeF.casecmp?(:abcdefg) #=> false :abcdef.casecmp?(:ABCDEF) #=> true :"\u{e4 f6 fc}".casecmp?(:"\u{c4 d6 dc}") #=> true +nil+ is returned if the two symbols have incompatible encodings, or if +other_symbol+ is not a symbol. :foo.casecmp?(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp?(:"\u{c4 d6 dc}") #=> nil;T;[o;H ;II" overload;F;J0;;;K0;#I"casecmp?(other_symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @;[;I"@return [true, false, nil];T;0; @;@F;Mi;N0;[[I"other_symbol;T0; @;[;I"aReturns +true+ if +sym+ and +other_symbol+ are equal after Unicode case folding, +false+ if they are not equal. :aBcDeF.casecmp?(:abcde) #=> false :aBcDeF.casecmp?(:abcdef) #=> true :aBcDeF.casecmp?(:abcdefg) #=> false :abcdef.casecmp?(:ABCDEF) #=> true :"\u{e4 f6 fc}".casecmp?(:"\u{c4 d6 dc}") #=> true +nil+ is returned if the two symbols have incompatible encodings, or if +other_symbol+ is not a symbol. :foo.casecmp?(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp?(:"\u{c4 d6 dc}") #=> nil @overload casecmp?(other_symbol) @return [true, false, nil];T;0; @;@F;Ao;B;CT;DiA*;EiR*;Mi;!@t;"I"static VALUE sym_casecmp_p(VALUE sym, VALUE other) { if (!SYMBOL_P(other)) { return Qnil; } return str_casecmp_p(rb_sym2str(sym), rb_sym2str(other)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#=~;F;[[I" other;T0;[[@ie*;T;;P;0;[;{;IC;"*Returns sym.to_s =~ obj. ;T;[o;H ;II" overload;F;J0;;P;K0;#I" =~(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"WReturns sym.to_s =~ obj. @overload =~(obj) @return [Integer, nil];T;0; @;@F;Ao;B;CT;Di^*;Eib*;!@t;"I"hstatic VALUE sym_match(VALUE sym, VALUE other) { return rb_str_match(rb_sym2str(sym), other); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#[];F;[[@0;[[@i*;T;:[];0;[;{;IC;"%Returns sym.to_s[]. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" [](idx);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"idx;T0; @o;H ;II" overload;F;J0;;;K0;#I" [](b, n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"b;T0[I"n;T0; @o;H ;II" overload;F;J0;: slice;K0;#I"slice(idx);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"idx;T0; @o;H ;II" overload;F;J0;;;K0;#I"slice(b, n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"b;T0[I"n;T0; @;[;I"Returns sym.to_s[]. @overload [](idx) @return [String] @overload [](b, n) @return [String] @overload slice(idx) @return [String] @overload slice(b, n) @return [String];T;0; @;@F;Ao;B;CT;Di*;Ei*;!@t;"I"wstatic VALUE sym_aref(int argc, VALUE *argv, VALUE sym) { return rb_str_aref_m(argc, argv, rb_sym2str(sym)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#slice;F;[[@0;[[@i*;T;;;0;[;{;IC;"%Returns sym.to_s[]. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" [](idx);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_;[;I"@return [String];T;0; @_;@F;Mi;N0;[[I"idx;T0; @_o;H ;II" overload;F;J0;;;K0;#I" [](b, n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_;[;I"@return [String];T;0; @_;@F;Mi;N0;[[I"b;T0[I"n;T0; @_o;H ;II" overload;F;J0;;;K0;#I"slice(idx);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_;[;I"@return [String];T;0; @_;@F;Mi;N0;[[I"idx;T0; @_o;H ;II" overload;F;J0;;;K0;#I"slice(b, n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_;[;I"@return [String];T;0; @_;@F;Mi;N0;[[I"b;T0[I"n;T0; @_;[;@[;0; @_;@F;Ao;B;CT;Di*;Ei*;!@t;"I"wstatic VALUE sym_aref(int argc, VALUE *argv, VALUE sym) { return rb_str_aref_m(argc, argv, rb_sym2str(sym)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#length;F;[;[[@i*;T;: length;0;[;{;IC;"*Same as sym.to_s.length. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;: size;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"tSame as sym.to_s.length. @overload length @return [Integer] @overload size @return [Integer];T;0; @;@F;Ao;B;CT;Di*;Ei*;!@t;"I"Vstatic VALUE sym_length(VALUE sym) { return rb_str_length(rb_sym2str(sym)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#size;F;[;[[@i*;T;;;0;[;{;IC;"*Same as sym.to_s.length. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di*;Ei*;!@t;"I"Vstatic VALUE sym_length(VALUE sym) { return rb_str_length(rb_sym2str(sym)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#empty?;F;[;[[@i*;T;: empty?;0;[;{;IC;")Returns whether _sym_ is :"" or not.;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"PReturns whether _sym_ is :"" or not. @overload empty? @return [Boolean];T;0; @;@F;Ao;B;CT;Di*;Ei*;Mi;!@t;"I"Tstatic VALUE sym_empty(VALUE sym) { return rb_str_empty(rb_sym2str(sym)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#match;F;[[@0;[[@is*;T;: match;0;[;{;IC;")Returns sym.to_s.match. ;T;[o;H ;II" overload;F;J0;;;K0;#I"match(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"MatchData;TI"nil;T; @;[;I"@return [MatchData, nil];T;0; @;@F;Mi;N0;[[I" pattern;T0; @o;H ;II" overload;F;J0;;;K0;#I"match(pattern, pos);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"MatchData;TI"nil;T; @;[;I"@return [MatchData, nil];T;0; @;@F;Mi;N0;[[I" pattern;T0[I"pos;T0; @;[;I"Returns sym.to_s.match. @overload match(pattern) @return [MatchData, nil] @overload match(pattern, pos) @return [MatchData, nil];T;0; @;@F;Ao;B;CT;Dik*;Eiq*;!@t;"I"{static VALUE sym_match_m(int argc, VALUE *argv, VALUE sym) { return rb_str_match_m(argc, argv, rb_sym2str(sym)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#match?;F;[[@0;[[@i*;T;: match?;0;[;{;IC;"*Returns sym.to_s.match?.;T;[o;H ;II" overload;F;J0;;;K0;#I"match?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @H;[;I"@return [Boolean];T;0; @H;@F;Mi;N0;[[I" pattern;T0; @Ho;H ;II" overload;F;J0;;;K0;#I"match?(pattern, pos);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @H;[;I"@return [Boolean];T;0; @H;@F;Mi;N0;[[I" pattern;T0[I"pos;T0; @H;[;I"Returns sym.to_s.match?. @overload match?(pattern) @return [Boolean] @overload match?(pattern, pos) @return [Boolean];T;0; @H;@F;Ao;B;CT;Diy*;Ei*;Mi;!@t;"I"sstatic VALUE sym_match_m_p(int argc, VALUE *argv, VALUE sym) { return rb_str_match_m_p(argc, argv, sym); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#upcase;F;[[@0;[[@i*;T;: upcase;0;[;{;IC;"1Same as sym.to_s.upcase.intern. ;T;[o;H ;II" overload;F;J0;;;K0;#I" upcase;T;IC;";T;[;[;I";T;0; @w;@F;Mi;N0;[; @wo;H ;II" overload;F;J0;;;K0;#I"upcase([options]);T;IC;";T;[;[;I";T;0; @w;@F;Mi;N0;[[I"[options];T0; @w;[;I"`Same as sym.to_s.upcase.intern. @overload upcase @overload upcase([options]);T;0; @w;@F;Ao;B;CT;Di*;Ei*;!@t;"I"static VALUE sym_upcase(int argc, VALUE *argv, VALUE sym) { return rb_str_intern(rb_str_upcase(argc, argv, rb_sym2str(sym))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#downcase;F;[[@0;[[@i*;T;: downcase;0;[;{;IC;"3Same as sym.to_s.downcase.intern. ;T;[o;H ;II" overload;F;J0;;;K0;#I" downcase;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"downcase([options]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[options];T0; @;[;I"fSame as sym.to_s.downcase.intern. @overload downcase @overload downcase([options]);T;0; @;@F;Ao;B;CT;Di*;Ei*;!@t;"I"static VALUE sym_downcase(int argc, VALUE *argv, VALUE sym) { return rb_str_intern(rb_str_downcase(argc, argv, rb_sym2str(sym))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#capitalize;F;[[@0;[[@i*;T;:capitalize;0;[;{;IC;"5Same as sym.to_s.capitalize.intern. ;T;[o;H ;II" overload;F;J0;;;K0;#I"capitalize;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"capitalize([options]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[options];T0; @;[;I"lSame as sym.to_s.capitalize.intern. @overload capitalize @overload capitalize([options]);T;0; @;@F;Ao;B;CT;Di*;Ei*;!@t;"I"static VALUE sym_capitalize(int argc, VALUE *argv, VALUE sym) { return rb_str_intern(rb_str_capitalize(argc, argv, rb_sym2str(sym))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#swapcase;F;[[@0;[[@i*;T;: swapcase;0;[;{;IC;"3Same as sym.to_s.swapcase.intern. ;T;[o;H ;II" overload;F;J0;;;K0;#I" swapcase;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"swapcase([options]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[options];T0; @;[;I"fSame as sym.to_s.swapcase.intern. @overload swapcase @overload swapcase([options]);T;0; @;@F;Ao;B;CT;Di*;Ei*;!@t;"I"static VALUE sym_swapcase(int argc, VALUE *argv, VALUE sym) { return rb_str_intern(rb_str_swapcase(argc, argv, rb_sym2str(sym))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Symbol#encoding;F;[;[[@i*;T;: encoding;0;[;{;IC;"GReturns the Encoding object that represents the encoding of _sym_. ;T;[o;H ;II" overload;F;J0;;;K0;#I" encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @;[;I"@return [Encoding];T;0; @;@F;Mi;N0;[; @;[;I"qReturns the Encoding object that represents the encoding of _sym_. @overload encoding @return [Encoding];T;0; @;@F;Ao;B;CT;Di*;Ei*;!@t;"I"Zstatic VALUE sym_encoding(VALUE sym) { return rb_obj_encoding(rb_sym2str(sym)); };T;#I"static VALUE;T;$T;&@t;'IC;[;&@t;(IC;[o;2 ;30;40;50;:Comparable;!@;7o; ;IC;[ o; ; F; ;,;;;I"Comparable#==;F;[[I"y;T0;[[I" compar.c;TiO;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;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; @;@F;Ao;B;CT;DiF;EiL;!@;"I"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; if (rb_cmpint(c, x, y) == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Comparable#>;F;[[I"y;T0;[[@"ij;T;:>;0;[;{;IC;"jCompares two objects based on the receiver's <=> method, returning true if it returns 1. ;T;[o;H ;II" overload;F;J0;;;K0;#I" >(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;;[;I"@return [Boolean];T;0; @;;@F;Mi;N0;[[I" other;T0; @;;[;I"Compares two objects based on the receiver's <=> method, returning true if it returns 1. @overload >(other) @return [Boolean];T;0; @;;@F;Ao;B;CT;Dib;Eig;!@;"I"istatic VALUE cmp_gt(VALUE x, VALUE y) { if (cmpint(x, y) > 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Comparable#>=;F;[[I"y;T0;[[@"iy;T;:>=;0;[;{;IC;"oCompares two objects based on the receiver's <=> method, returning true if it returns 0 or 1. ;T;[o;H ;II" overload;F;J0;;;K0;#I">=(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Z;[;I"@return [Boolean];T;0; @Z;@F;Mi;N0;[[I" other;T0; @Z;[;I"Compares two objects based on the receiver's <=> method, returning true if it returns 0 or 1. @overload >=(other) @return [Boolean];T;0; @Z;@F;Ao;B;CT;Diq;Eiv;!@;"I"jstatic VALUE cmp_ge(VALUE x, VALUE y) { if (cmpint(x, y) >= 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Comparable#<;F;[[I"y;T0;[[@"i;T;:<;0;[;{;IC;"kCompares two objects based on the receiver's <=> method, returning true if it returns -1. ;T;[o;H ;II" overload;F;J0;;;K0;#I" <(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @y;[;I"@return [Boolean];T;0; @y;@F;Mi;N0;[[I" other;T0; @y;[;I"Compares two objects based on the receiver's <=> method, returning true if it returns -1. @overload <(other) @return [Boolean];T;0; @y;@F;Ao;B;CT;Di{;Ei;!@;"I"istatic VALUE cmp_lt(VALUE x, VALUE y) { if (cmpint(x, y) < 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Comparable#<=;F;[[I"y;T0;[[@"i;T;:<=;0;[;{;IC;"pCompares two objects based on the receiver's <=> method, returning true if it returns -1 or 0. ;T;[o;H ;II" overload;F;J0;;;K0;#I"<=(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;I"Compares two objects based on the receiver's <=> method, returning true if it returns -1 or 0. @overload <=(other) @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"jstatic VALUE cmp_le(VALUE x, VALUE y) { if (cmpint(x, y) <= 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Comparable#between?;F;[[I"min;T0[I"max;T0;[[@"i;T;: between?;0;[;{;IC;"jReturns false if obj <=> min is less than zero or if anObject <=> 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;H ;II" overload;F;J0;;;K0;#I"between?(min, max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"min;T0[I"max;T0; @;[;I"Returns false if obj <=> min is less than zero or if anObject <=> 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;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Comparable#clamp;F;[[I"min;T0[I"max;T0;[[@"i;T;: clamp;0;[;{;IC;"fReturns 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' ;T;[o;H ;II" overload;F;J0;;;K0;#I"clamp(min, max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"min;T0[I"max;T0; @;[;I"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' @overload clamp(min, max) @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Estatic VALUE cmp_clamp(VALUE x, VALUE min, VALUE max) { int c; if (cmpint(min, max) > 0) { rb_raise(rb_eArgError, "min argument must be smaller than max argument"); } c = cmpint(x, min); if (c == 0) return x; if (c < 0) return min; 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;-{;.[;[[@"i;F;;;;0;;;[;{;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 -1, 0, or +1 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] ;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 -1, 0, or +1 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] ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Comparable;F;F0;&@t;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i.)[@i+;T;;;;0;;;[;{;IC;"******************************************************************** Symbol objects represent names and some strings inside the Ruby interpreter. They are generated using the :name and :"string" literals syntax, and by the various to_sym methods. 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;T;[;[;I"******************************************************************** Symbol objects represent names and some strings inside the Ruby interpreter. They are generated using the :name and :"string" literals syntax, and by the various to_sym methods. 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 ;T;0; @t;@F;Ao;B;CT;Di.);EiL);Mi;!@;I" Symbol;F;1@<;F;o; ;IC;[ o; ; F; ;;;;I""Bug::Regexp.parse_depth_limit;F;[;[[I"*ext/-test-/regexp/parse_depth_limit.c;Ti ;T;:parse_depth_limit;0;[;{;IC;" ;T;[;[;@;0; @ ;!@;"I"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; ; F; ;;;;I"#Bug::Regexp.parse_depth_limit=;F;[[I" depth;T0;[[@%i;T;:parse_depth_limit=;0;[;{;IC;" ;T;[;[;@;0; @-;!@;"I"static VALUE set_parse_depth_limit(VALUE self, VALUE depth) { onig_set_parse_depth_limit(NUM2UINT(depth)); return depth; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Bug::Regexp.zero;F;[[I" length;T0;[[I" ext/-test-/bignum/bigzero.c;Ti;T;: zero;0;[;{;IC;" ;T;[;[;@;0; @;;!@;"I"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; ; F; ;;;;I"Bug::Regexp.negzero;F;[[I" length;T0;[[@Bi;T;: negzero;0;[;{;IC;" ;T;[;[;@;0; @J;!@;"I"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;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/regexp/init.c;Ti;F;: Regexp;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I"Bug::Regexp;F;1o;2 ;30;40;50;;;!@;7o; ;IC;[#o; ; F; ;;;;I"Regexp.compile;F;[;[;F;: compile;;0;[;{;IC;"&Alias for Regexp.new ;T;[;[;I"( Alias for Regexp.new ;T;0; @k;@F;Ao;B;CT;Dia ;Eic ;!@i;$To; ; F; ;;;;I"Regexp.quote;F;[[I"str;T0;[[I" re.c;Ti;T;: quote;0;[;{;IC;" Escapes any characters that would have special meaning in a regular expression. Returns a new escaped string, or self if no characters are escaped. For any string, Regexp.new(Regexp.escape(str))=~str will be true. Regexp.escape('\*?{}.') #=> \\\*\?\{\}\. ;T;[o;H ;II" overload;F;J0;: escape;K0;#I"escape(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @v;[;I"@return [String];T;0; @v;@F;Mi;N0;[[I"str;T0; @vo;H ;II" overload;F;J0;;;K0;#I"quote(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @v;[;I"@return [String];T;0; @v;@F;Mi;N0;[[I"str;T0; @v;[;I"tEscapes any characters that would have special meaning in a regular expression. Returns a new escaped string, or self if no characters are escaped. 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; @v;@F;Ao;B;CT;Di ;Ei;!@i;"I"istatic VALUE rb_reg_s_quote(VALUE c, VALUE str) { return rb_reg_quote(reg_operand(str, TRUE)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Regexp.escape;F;[[I"str;T0;[[@}i;T;;;0;[;{;IC;" Escapes any characters that would have special meaning in a regular expression. Returns a new escaped string, or self if no characters are escaped. For any string, Regexp.new(Regexp.escape(str))=~str will be true. Regexp.escape('\*?{}.') #=> \\\*\?\{\}\. ;T;[o;H ;II" overload;F;J0;;;K0;#I"escape(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"str;T0; @o;H ;II" overload;F;J0;;;K0;#I"quote(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"str;T0; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei;!@i;"I"istatic VALUE rb_reg_s_quote(VALUE c, VALUE str) { return rb_reg_quote(reg_operand(str, TRUE)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Regexp.union;F;[[I" args;T0;[[@}i;T;: union;0;[;{;IC;"4Return 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;H ;II" overload;F;J0;; ;K0;#I"union(pat1, pat2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Regexp;T; @;[;I"@return [Regexp];T;0; @;@F;Mi;N0;[[I" pat1;T0[I" pat2;T0[I"...;T0; @o;H ;II" overload;F;J0;; ;K0;#I"union(pats_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Regexp;T; @;[;I"@return [Regexp];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@i;"I"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; ; F; ;;;;I"Regexp.last_match;F;[[@0;[[@}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;H ;II" overload;F;J0;; ;K0;#I"last_match;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"MatchData;T; @;[;I"@return [MatchData];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I"last_match(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@i;"I";static VALUE rb_reg_s_last_match(int argc, VALUE *argv) { 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; ; F; ;;;;I"Regexp.try_convert;F;[[I"re;T0;[[@}i@;T;:try_convert;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;H ;II" overload;F;J0;; ;K0;#I"try_convert(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @/;[;I"@return [nil];T;0; @/;@F;Mi;N0;[[I"obj;T0; @/;[;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; @/;@F;Ao;B;CT;Di/;Ei>;!@i;"I"fstatic VALUE rb_reg_s_try_convert(VALUE dummy, VALUE re) { return rb_check_regexp_type(re); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#initialize;F;[[@0;[[@}i} ;T;;;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;H ;II" overload;F;J0;:new;K0;#I"new(string, [options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Regexp;T; @N;[;I"@return [Regexp];T;0; @N;@F;Mi;N0;[[I" string;T0[I"[options];T0; @No;H ;II" overload;F;J0;; ;K0;#I"new(regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Regexp;T; @N;[;I"@return [Regexp];T;0; @N;@F;Mi;N0;[[I" regexp;T0; @No;H ;II" overload;F;J0;;;K0;#I"compile(string, [options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Regexp;T; @N;[;I"@return [Regexp];T;0; @N;@F;Mi;N0;[[I" string;T0[I"[options];T0; @No;H ;II" overload;F;J0;;;K0;#I"compile(regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Regexp;T; @N;[;I"@return [Regexp];T;0; @N;@F;Mi;N0;[[I" regexp;T0; @N;[;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; @N;@F;Ao;B;CT;Dig ;Ei} ;!@i;"I"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_warn("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; ; F; ;,;;;I"Regexp#initialize_copy;F;[[I"re;T0;[[@}i;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@i;"I"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; ; F; ;,;;;I"Regexp#hash;F;[;[[@}i ;T;;U;0;[;{;IC;"dProduce a hash based on the text and options of this regular expression. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Produce a hash based on the text and options of this regular expression. See also Object#hash. @overload hash @return [Integer];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@i;"I"nstatic VALUE rb_reg_hash(VALUE re) { st_index_t hashval = reg_hash(re); return ST2FIX(hashval); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#eql?;F;[[I"re2;T0;[[@}i ;T;;R;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;H ;II" overload;F;J0;;S;K0;#I"==(other_rxp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"other_rxp;T0; @o;H ;II" overload;F;J0;;R;K0;#I"eql?(other_rxp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"other_rxp;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;Mi;!@i;"I"Tstatic 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; if (memcmp(RREGEXP_SRC_PTR(re1), RREGEXP_SRC_PTR(re2), RREGEXP_SRC_LEN(re1)) == 0) { return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#==;F;[[I"re2;T0;[[@}i ;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"==(other_rxp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"other_rxp;T0; @o;H ;II" overload;F;J0;;R;K0;#I"eql?(other_rxp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"other_rxp;T0; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei ;!@i;"I"Tstatic 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; if (memcmp(RREGEXP_SRC_PTR(re1), RREGEXP_SRC_PTR(re2), RREGEXP_SRC_LEN(re1)) == 0) { return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#=~;F;[[I"str;T0;[[@}i ;T;;P;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;H ;II" overload;F;J0;;P;K0;#I" =~(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @#;[;I"@return [Integer, nil];T;0; @#;@F;Mi;N0;[[I"str;T0; @#;[;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; @#;@F;Ao;B;CT;Di] ;Ei ;!@i;"I"VALUE rb_reg_match(VALUE re, VALUE str) { long pos = reg_match_pos(re, &str, 0); if (pos < 0) return Qnil; pos = rb_str_sublen(str, pos); return LONG2FIX(pos); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Regexp#===;F;[[I"str;T0;[[@}i ;T;;O;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;H ;II" overload;F;J0;;O;K0;#I" ===(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @C;[;I"@return [Boolean];T;0; @C;@F;Mi;N0;[[I"str;T0; @C;[;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; @C;@F;Ao;B;CT;Di ;Ei ;!@i;"I"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" VALUE;T;$To; ; F; ;,;;;I" Regexp#~;F;[;[[@}i ;T;:~;0;[;{;IC;"Match---Matches rxp against the contents of $_. Equivalent to rxp =~ $_. $_ = "input data" ~ /at/ #=> 7 ;T;[o;H ;II" overload;F;J0;; ;K0;#I" ~ rxp;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @b;[;I"@return [Integer, nil];T;0; @b;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@i;"I"@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; ; F; ;,;;;I"Regexp#match;F;[[@0;[[@}i ;T;;;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;H ;II" overload;F;J0;;;K0;#I"match(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"MatchData;TI"nil;T; @;[;I"@return [MatchData, nil];T;0; @;@F;Mi;N0;[[I"str;T0; @o;H ;II" overload;F;J0;;;K0;#I"match(str,pos);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"MatchData;TI"nil;T; @;[;I"@return [MatchData, nil];T;0; @;@F;Mi;N0;[[I"str;T0[I"pos;T0; @;[;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) @return [MatchData, nil] @overload match(str,pos) @return [MatchData, nil];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@i;"I"static VALUE rb_reg_match_m(int argc, VALUE *argv, VALUE re) { VALUE result, 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); if (pos < 0) { rb_backref_set(Qnil); return Qnil; } result = rb_backref_get(); rb_match_busy(result); if (!NIL_P(result) && rb_block_given_p()) { return rb_yield(result); } return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#match?;F;[[@0;[[@}i& ;T;;;0;[;{;IC;"Returns a true or false indicates 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;H ;II" overload;F;J0;;;K0;#I"match?(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"str;T0; @o;H ;II" overload;F;J0;;;K0;#I"match?(str,pos);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"str;T0[I"pos;T0; @;[;I"Returns a true or false indicates 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) @return [Boolean];T;0; @;@F;Ao;B;CT;Di ;Ei$ ;Mi;!@i;"I"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; ; F; ;,;;;I"Regexp#to_s;F;[;[[@}i;T;;h;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;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@i;"I"Ustatic VALUE rb_reg_to_s(VALUE re) { return rb_reg_str_with_term(re, '/'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#inspect;F;[;[[@}i;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@i;"I"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; ; F; ;,;;;I"Regexp#source;F;[;[[@}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;H ;II" overload;F;J0;;;K0;#I" source;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@i;"I"static VALUE rb_reg_source(VALUE re) { VALUE str; rb_reg_check(re); str = rb_str_dup(RREGEXP_SRC(re)); if (OBJ_TAINTED(re)) OBJ_TAINT(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#casefold?;F;[;[[@}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;H ;II" overload;F;J0;;;K0;#I"casefold?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[; @1;[;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; @1;@F;Ao;B;CT;Di;Ei;Mi;!@i;"I"static VALUE rb_reg_casefold_p(VALUE re) { rb_reg_check(re); if (RREGEXP_PTR(re)->options & ONIG_OPTION_IGNORECASE) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#options;F;[;[[@}i;T;: options;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;H ;II" overload;F;J0;;;K0;#I" options;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @L;[;I"@return [Integer];T;0; @L;@F;Mi;N0;[; @L;[;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; @L;@F;Ao;B;CT;Di;Ei;!@i;"I"sstatic VALUE rb_reg_options_m(VALUE re) { int options = rb_reg_options(re); return INT2NUM(options); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#encoding;F;[;[[I"encoding.c;Ti;T;;;0;[;{;IC;"EReturns the Encoding object that represents the encoding of obj. ;T;[o;H ;II" overload;F;J0;;;K0;#I" encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @g;[;I"@return [Encoding];T;0; @g;@F;Mi;N0;[; @g;[;I"oReturns the Encoding object that represents the encoding of obj. @overload encoding @return [Encoding];T;0; @g;@F;Ao;B;CT;Di;Ei;!@i;"I"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; ; F; ;,;;;I"Regexp#fixed_encoding?;F;[;[[@}io;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;H ;II" overload;F;J0;;;K0;#I"fixed_encoding?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiR;Eil;Mi;!@i;"I"static VALUE rb_reg_fixed_encoding_p(VALUE re) { if (FL_TEST(re, KCODE_FIXED)) return Qtrue; else return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Regexp#names;F;[;[[@}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;H ;II" overload;F;J0;;;K0;#I" names;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei ;!@i;"I"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; ; F; ;,;;;I"Regexp#named_captures;F;[;[[@}i<;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;H ;II" overload;F;J0;;;K0;#I"named_captures;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di&;Ei9;!@i;"I"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;9;[[@}i;F;:IGNORECASE;;;;;;[;{;IC;"&see Regexp.options and Regexp.new ;T;[;[;I"&see Regexp.options and Regexp.new;T;0; @;@F;Ao;B;CT;Di;Ei;!@i;I"Regexp::IGNORECASE;F;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. :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. :include: doc/regexp.rdoc ;T;0; @i;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Regexp;F;1@<;F;o; ;IC;[ o; ;IC;[;&@$;'IC;[;&@$;(IC;[;&@$;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"%ext/-test-/exception/dataerror.c;Ti";F;:DataError;;0;;;[;{;IC;" ;T;[;[;@;0; @$;!@";I"Bug::Bignum::DataError;F;1o;2 ;30;40;50;:StandardError;!@;7o; ;IC;[;&@7;'IC;[;&@7;(IC;[;&@7;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;;;;0;;;[;{;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; @7;@F;Ao;B;CT;Di;Ei;!@;I"StandardError;F;1o; ;IC;[o; ; F; ;;;;I"Exception.exception;F;[[@0;[[@i;T;:exception;0;[;{;IC;"DAllocates and initializes an instance of \a klass. Equivalent to \c Class\#new in Ruby \param[in] argc the number of arguments to \c #initialize \param[in] argv a pointer to an array of arguments to \c #initialize \param[in] klass a Class object \return the new instance of \a klass \sa rb_obj_call_init \sa rb_obj_alloc ;T;[;[;I"EAllocates and initializes an instance of \a klass. Equivalent to \c Class\#new in Ruby \param[in] argc the number of arguments to \c #initialize \param[in] argv a pointer to an array of arguments to \c #initialize \param[in] klass a Class object \return the new instance of \a klass \sa rb_obj_call_init \sa rb_obj_alloc ;T;0; @M;@F;Ao;B;CT;Di;Ei;!@K;"I"VALUE rb_class_new_instance(int argc, const VALUE *argv, VALUE klass) { Check_Type(klass, T_CLASS); return rb_class_s_new(argc, argv, klass); };T;#I" VALUE;T;$To; ; F; ;;;;I"Exception.to_tty?;F;[;[[@i;T;: to_tty?;0;[;{;IC;"@Returns +true+ if exception messages will be sent to a tty.;T;[o;H ;II" overload;F;J0;;;K0;#I" to_tty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @\;[;I"@return [Boolean];T;0; @\;@F;Mi;N0;[; @\;[;I"hReturns +true+ if exception messages will be sent to a tty. @overload to_tty? @return [Boolean];T;0; @\;@F;Ao;B;CT;Di;Ei;Mi;!@K;"I"_static VALUE exc_s_to_tty_p(VALUE self) { return rb_stderr_tty_p() ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Exception#exception;F;[[@0;[[@i;T;;;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; @w;@F;Ao;B;CT;Di;Ei;!@K;"I"static VALUE exc_exception(int argc, VALUE *argv, VALUE self) { VALUE exc; if (argc == 0) return self; if (argc == 1 && self == argv[0]) return self; exc = rb_obj_clone(self); exc_initialize(argc, argv, exc); return exc; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Exception#initialize;F;[[@0;[[@i;T;;;0;[;{;IC;"HConstruct a new Exception object, optionally passing in a message. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(msg = nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Exception;T; @;[;I"@return [Exception];T;0; @;@F;Mi;N0;[[I"msg;TI"nil;T; @;[;I"z Construct a new Exception object, optionally passing in a message. @overload new(msg = nil) @return [Exception];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"Exception#==;F;[[I"obj;T0;[[@i;T;;S;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;H ;II" overload;F;J0;;S;K0;#I" ==(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@K;"I"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; if (!rb_equal(exc_backtrace(exc), backtrace)) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Exception#to_s;F;[;[[@i;T;;h;0;[;{;IC;"UReturns exception's message (or the name of the exception if no message is set). ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"yReturns exception's message (or the name of the exception if no message is set). @overload to_s @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"Exception#message;F;[;[[@iC;T;: message;0;[;{;IC;"wReturns the result of invoking exception.to_s. Normally this returns the exception's message or name. ;T;[o;H ;II" overload;F;J0;;;K0;#I" message;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;;Ei@;!@K;"I"Wstatic VALUE exc_message(VALUE exc) { return rb_funcallv(exc, idTo_s, 0, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Exception#full_message;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#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;Ao;B;CT;Di;Ei ;!@K;"I"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_raise(rb_eArgError, "expected true or false as " "highlight: %+"PRIsVALUE, args[kw_highlight]); 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; ; F; ;,;;;I"Exception#inspect;F;[;[[@iP;T;;i;0;[;{;IC;"4Return this exception's class name and message. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"[Return this exception's class name and message. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;DiI;EiM;!@K;"I"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_str_dup(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; ; F; ;,;;;I"Exception#backtrace;F;[;[[@i;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 ;T;[o;H ;II" overload;F;J0;;;K0;#I"backtrace;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @7;[;I"@return [Array];T;0; @7;@F;Mi;N0;[; @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 @overload backtrace @return [Array];T;0; @7;@F;Ao;B;CT;Die;Ei;!@K;"I"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; ; F; ;,;;;I""Exception#backtrace_locations;F;[;[[@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. Now, this method is not affected by Exception#set_backtrace(). ;T;[o;H ;II" overload;F;J0;; ;K0;#I"backtrace_locations;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @R;[;I"@return [Array];T;0; @R;@F;Mi;N0;[; @R;[;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. Now, this method is not affected by Exception#set_backtrace(). @overload backtrace_locations @return [Array];T;0; @R;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"Exception#set_backtrace;F;[[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;H ;II" overload;F;J0;;!;K0;#I"set_backtrace(backtrace);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @m;[;I"@return [Array];T;0; @m;@F;Mi;N0;[[I"backtrace;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"Exception#cause;F;[;[[@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;H ;II" overload;F;J0;;";K0;#I" cause;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Exception;TI"nil;T; @;[;I"@return [Exception, nil];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@K;"I"Qstatic VALUE exc_cause(VALUE exc) { return rb_attr_get(exc, id_cause); };T;#I"static VALUE;T;$T;&@K;'IC;[;&@K;(IC;[;&@K;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i~ ;F;:Exception;;0;;;[;{;IC;"Descendants of class Exception are used to communicate between Kernel#raise and +rescue+ statements in begin ... end blocks. Exception objects carry information about the exception -- its type (the exception's class name), an optional descriptive string, and optional traceback information. Exception subclasses may add additional information like NameError#name. Programs may make subclasses of Exception, typically of StandardError or RuntimeError, to provide custom classes and add additional information. See the subclass list below for defaults for +raise+ and +rescue+. When an exception has been raised but not yet handled (in +rescue+, +ensure+, +at_exit+ and +END+ blocks) the global variable $! will contain the current exception and $@ contains the current exception's backtrace. It is recommended that a library should have one subclass of StandardError or RuntimeError and have specific exception types inherit from it. This allows the user to rescue a generic exception type to catch all exceptions the library may raise even if future versions of the library add new exception subclasses. For example: class MyLibrary class Error < RuntimeError end class WidgetError < Error end class FrobError < Error end end To handle both WidgetError and FrobError the library user can rescue MyLibrary::Error. The built-in subclasses of Exception are: * NoMemoryError * ScriptError * LoadError * NotImplementedError * SyntaxError * SecurityError * SignalException * Interrupt * StandardError -- default for +rescue+ * ArgumentError * UncaughtThrowError * EncodingError * FiberError * IOError * EOFError * IndexError * KeyError * StopIteration * LocalJumpError * NameError * NoMethodError * RangeError * FloatDomainError * RegexpError * RuntimeError -- default for +raise+ * FrozenError * SystemCallError * Errno::* * ThreadError * TypeError * ZeroDivisionError * SystemExit * SystemStackError * fatal -- impossible to rescue ;T;[;[;I"Descendants of class Exception are used to communicate between Kernel#raise and +rescue+ statements in begin ... end blocks. Exception objects carry information about the exception -- its type (the exception's class name), an optional descriptive string, and optional traceback information. Exception subclasses may add additional information like NameError#name. Programs may make subclasses of Exception, typically of StandardError or RuntimeError, to provide custom classes and add additional information. See the subclass list below for defaults for +raise+ and +rescue+. When an exception has been raised but not yet handled (in +rescue+, +ensure+, +at_exit+ and +END+ blocks) the global variable $! will contain the current exception and $@ contains the current exception's backtrace. It is recommended that a library should have one subclass of StandardError or RuntimeError and have specific exception types inherit from it. This allows the user to rescue a generic exception type to catch all exceptions the library may raise even if future versions of the library add new exception subclasses. For example: class MyLibrary class Error < RuntimeError end class WidgetError < Error end class FrobError < Error end end To handle both WidgetError and FrobError the library user can rescue MyLibrary::Error. The built-in subclasses of Exception are: * NoMemoryError * ScriptError * LoadError * NotImplementedError * SyntaxError * SecurityError * SignalException * Interrupt * StandardError -- default for +rescue+ * ArgumentError * UncaughtThrowError * EncodingError * FiberError * IOError * EOFError * IndexError * KeyError * StopIteration * LocalJumpError * NameError * NoMethodError * RangeError * FloatDomainError * RegexpError * RuntimeError -- default for +raise+ * FrozenError * SystemCallError * Errno::* * ThreadError * TypeError * ZeroDivisionError * SystemExit * SystemStackError * fatal -- impossible to rescue ;T;0; @K;@F;Ao;B;CT;Di- ;Eix ;!@;I"Exception;F;1@<;F;o; ; F; ;,;;;I"Bug::Bignum#ensured;F;[[I" object;T0;[[I"#ext/-test-/exception/ensured.c;Ti;T;: ensured;0;[;{;IC;" ;T;[;[;I";F;0; @;@F;N0;!@";"I"nstatic VALUE ensured(VALUE module, VALUE object) { return rb_ensure(begin, object, ensure, object); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Bug::Bignum.ensured;F;@;@;T;;$;0;@;{;IC;" ;T;[;[;@;0; @;Mi;!@";"@;#@;$To; ; F; ;,;;;I"Bug::Bignum#ensure_raise;F;[[I" object;T0[I"exc;T0;[[@i!;T;:ensure_raise;0;[;{;IC;" ;T;[;[;I";F;0; @;@F;N0;!@";"I"|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; ; T; ;;;;I"Bug::Bignum.ensure_raise;F;@;@;T;;%;0;@;{;IC;" ;T;[;[;@;0; @;Mi;!@";"@;#@;$T;&@";'IC;[;&@";(IC;[;&@";)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/bignum/init.c;Ti;F;;?;;0;;;[;{;IC;" ;T;[;[;@;0; @";!@;I"Bug::Bignum;F;1o; ;IC;[o; ; F; ;,;;;I"String#to_c;F;[;[[@iu;T;: to_c;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;H ;II" overload;F;J0;;&;K0;#I" to_c;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di^;Eir;!@;"I"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; ; F; ;;;;I"String.try_convert;F;[[I"str;T0;[[@i* ;T;; ;0;[;{;IC;"Try to convert obj into a String, using to_str method. Returns converted string or nil if obj cannot be converted for any reason. String.try_convert("str") #=> "str" String.try_convert(/re/) #=> nil ;T;[o;H ;II" overload;F;J0;; ;K0;#I"try_convert(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"Try to convert obj into a String, using to_str method. Returns converted string or nil if obj cannot be converted for any reason. String.try_convert("str") #=> "str" String.try_convert(/re/) #=> nil @overload try_convert(obj) @return [String, nil];T;0; @;@F;Ao;B;CT;Di ;Ei( ;!@;"I"hstatic VALUE rb_str_s_try_convert(VALUE dummy, VALUE str) { return rb_check_string_type(str); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#initialize;F;[[@0;[[@i5;T;;;0;[;{;IC;"Returns a new string object containing a copy of str. The optional encoding keyword argument specifies the encoding of the new string. If not specified, the encoding of str is used (or ASCII-8BIT, if str is not specified). The optional capacity keyword argument specifies the size of the internal buffer. This may improve performance, when the string will be concatenated many times (causing many realloc calls). ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(str="");T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @.;[;I"@return [String];T;0; @.;@F;Mi;N0;[[I"str;TI""";T; @.o;H ;II" overload;F;J0;; ;K0;#I"new(str="", encoding: enc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @.;[;I"@return [String];T;0; @.;@F;Mi;N0;[[I"str;TI""";T[I"encoding:;TI"enc;T; @.o;H ;II" overload;F;J0;; ;K0;#I" new(str="", capacity: size);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @.;[;I"@return [String];T;0; @.;@F;Mi;N0;[[I"str;TI""";T[I"capacity:;TI" size;T; @.;[;I"]Returns a new string object containing a copy of str. The optional encoding keyword argument specifies the encoding of the new string. If not specified, the encoding of str is used (or ASCII-8BIT, if str is not specified). The optional capacity keyword argument specifies the size of the internal buffer. This may improve performance, when the string will be concatenated many times (causing many realloc calls). @overload new(str="") @return [String] @overload new(str="", encoding: enc) @return [String] @overload new(str="", capacity: size) @return [String];T;0; @.;@F;Ao;B;CT;Di";Ei4;!@;"I"P static VALUE rb_str_init(int argc, VALUE *argv, VALUE str) { static ID keyword_ids[2]; VALUE orig, opt, venc, vcapa; VALUE kwargs[2]; rb_encoding *enc = 0; int n; if (!keyword_ids[0]) { keyword_ids[0] = rb_id_encoding(); CONST_ID(keyword_ids[1], "capacity"); } n = rb_scan_args(argc, argv, "01:", &orig, &opt); if (!NIL_P(opt)) { rb_get_kwargs(opt, keyword_ids, 0, 2, kwargs); venc = kwargs[0]; vcapa = kwargs[1]; if (venc != Qundef && !NIL_P(venc)) { enc = rb_to_encoding(venc); } if (vcapa != Qundef && !NIL_P(vcapa)) { long capa = NUM2LONG(vcapa); long len = 0; int termlen = enc ? rb_enc_mbminlen(enc) : 1; if (capa < STR_BUF_MIN_SIZE) { capa = STR_BUF_MIN_SIZE; } if (n == 1) { StringValue(orig); len = RSTRING_LEN(orig); if (capa < len) { capa = len; } if (orig == str) n = 0; } str_modifiable(str); if (STR_EMBED_P(str)) { /* make noembed always */ char *new_ptr = ALLOC_N(char, (size_t)capa + termlen); memcpy(new_ptr, RSTRING(str)->as.ary, RSTRING_EMBED_LEN_MAX + 1); RSTRING(str)->as.heap.ptr = new_ptr; } else if (FL_TEST(str, STR_SHARED|STR_NOFREE)) { const size_t size = (size_t)capa + termlen; const char *const old_ptr = RSTRING_PTR(str); const size_t osize = RSTRING(str)->as.heap.len + TERM_LEN(str); char *new_ptr = ALLOC_N(char, (size_t)capa + termlen); memcpy(new_ptr, old_ptr, osize < size ? osize : size); FL_UNSET_RAW(str, STR_SHARED); RSTRING(str)->as.heap.ptr = new_ptr; } else if (STR_HEAP_SIZE(str) != (size_t)capa + termlen) { SIZED_REALLOC_N(RSTRING(str)->as.heap.ptr, char, (size_t)capa + termlen, STR_HEAP_SIZE(str)); } RSTRING(str)->as.heap.len = len; TERM_FILL(&RSTRING(str)->as.heap.ptr[len], termlen); if (n == 1) { memcpy(RSTRING(str)->as.heap.ptr, RSTRING_PTR(orig), len); rb_enc_cr_str_exact_copy(str, orig); } FL_SET(str, STR_NOEMBED); RSTRING(str)->as.heap.aux.capa = capa; } else if (n == 1) { rb_str_replace(str, orig); } if (enc) { rb_enc_associate(str, enc); ENC_CODERANGE_CLEAR(str); } } else if (n == 1) { rb_str_replace(str, orig); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#initialize_copy;F;[[I" str2;T0;[[@i;T;;];0;[;{;IC;"Replaces the contents and taintedness of str with the corresponding values in other_str. s = "hello" #=> "hello" s.replace "world" #=> "world" ;T;[o;H ;II" overload;F;J0;: replace;K0;#I"replace(other_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @s;[;I"@return [String];T;0; @s;@F;Mi;N0;[[I"other_str;T0; @s;[;I"Replaces the contents and taintedness of str with the corresponding values in other_str. s = "hello" #=> "hello" s.replace "world" #=> "world" @overload replace(other_str) @return [String];T;0; @s;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_str_replace(VALUE str, VALUE str2) { str_modifiable(str); if (str == str2) return str; StringValue(str2); str_discard(str); return str_replace(str, str2); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#<=>;F;[[I" str2;T0;[[@i ;T;;V;0;[;{;IC;"Comparison---Returns -1, 0, +1, or +nil+ depending on whether +string+ is less than, equal to, or greater than +other_string+. +nil+ is returned if the two values are incomparable. If the strings are of different lengths, and the strings are equal when compared up to the shortest length, then the longer string is considered greater than the shorter one. <=> is the basis for the methods <, <=, >, >=, and between?, included from module Comparable. The method String#== does not use Comparable#==. "abcdef" <=> "abcde" #=> 1 "abcdef" <=> "abcdef" #=> 0 "abcdef" <=> "abcdefg" #=> -1 "abcdef" <=> "ABCDEF" #=> 1 "abcdef" <=> 1 #=> nil ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(other_string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @;[;I"@return [-1, 0, +1, nil];T;0; @;@F;Mi;N0;[[I"other_string;T0; @;[;I",Comparison---Returns -1, 0, +1, or +nil+ depending on whether +string+ is less than, equal to, or greater than +other_string+. +nil+ is returned if the two values are incomparable. If the strings are of different lengths, and the strings are equal when compared up to the shortest length, then the longer string is considered greater than the shorter one. <=> is the basis for the methods <, <=, >, >=, and between?, included from module Comparable. The method String#== does not use Comparable#==. "abcdef" <=> "abcde" #=> 1 "abcdef" <=> "abcdef" #=> 0 "abcdef" <=> "abcdefg" #=> -1 "abcdef" <=> "ABCDEF" #=> 1 "abcdef" <=> 1 #=> nil @overload <=>(other_string) @return [-1, 0, +1, nil];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE rb_str_cmp_m(VALUE str1, VALUE str2) { int result; VALUE s = rb_check_string_type(str2); if (NIL_P(s)) { return rb_invcmp(str1, str2); } result = rb_str_cmp(str1, s); return INT2FIX(result); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#==;F;[[I" str2;T0;[[@i ;T;;S;0;[;{;IC;" Equality---Returns whether +str+ == +obj+, similar to Object#==. If +obj+ is not an instance of String but responds to +to_str+, then the two strings are compared using obj.==. Otherwise, returns similarly to String#eql?, comparing length and content. ;T;[o;H ;II" overload;F;J0;;S;K0;#I" ==(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;O;K0;#I" ===(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"YEquality---Returns whether +str+ == +obj+, similar to Object#==. If +obj+ is not an instance of String but responds to +to_str+, then the two strings are compared using obj.==. Otherwise, returns similarly to String#eql?, comparing length and content. @overload ==(obj) @return [Boolean] @overload ===(obj) @return [Boolean];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"VALUE rb_str_equal(VALUE str1, VALUE str2) { if (str1 == str2) return Qtrue; if (!RB_TYPE_P(str2, T_STRING)) { if (!rb_respond_to(str2, idTo_str)) { return Qfalse; } return rb_equal(str2, str1); } return str_eql(str1, str2); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#===;F;[[I" str2;T0;[[@i ;T;;O;0;[;{;IC;" Equality---Returns whether +str+ == +obj+, similar to Object#==. If +obj+ is not an instance of String but responds to +to_str+, then the two strings are compared using obj.==. Otherwise, returns similarly to String#eql?, comparing length and content. ;T;[o;H ;II" overload;F;J0;;S;K0;#I" ==(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;O;K0;#I" ===(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"VALUE rb_str_equal(VALUE str1, VALUE str2) { if (str1 == str2) return Qtrue; if (!RB_TYPE_P(str2, T_STRING)) { if (!rb_respond_to(str2, idTo_str)) { return Qfalse; } return rb_equal(str2, str1); } return str_eql(str1, str2); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#eql?;F;[[I" str2;T0;[[@i ;T;;R;0;[;{;IC;"DTwo strings are equal if they have the same length and content.;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" other;T0; @ ;[;I"pTwo strings are equal if they have the same length and content. @overload eql?(other) @return [Boolean];T;0; @ ;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I"MJIT_FUNC_EXPORTED VALUE rb_str_eql(VALUE str1, VALUE str2) { if (str1 == str2) return Qtrue; if (!RB_TYPE_P(str2, T_STRING)) return Qfalse; return str_eql(str1, str2); };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"String#hash;F;[;[[@i ;T;;U;0;[;{;IC;"^Returns a hash based on the string's length, content and encoding. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @. ;[;I"@return [Integer];T;0; @. ;@F;Mi;N0;[; @. ;[;I"~Returns a hash based on the string's length, content and encoding. See also Object#hash. @overload hash @return [Integer];T;0; @. ;@F;Ao;B;CT;Di ;Ei ;!@;"I"ostatic VALUE rb_str_hash_m(VALUE str) { st_index_t hval = rb_str_hash(str); return ST2FIX(hval); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#casecmp;F;[[I" str2;T0;[[@i: ;T;;;0;[;{;IC;"Case-insensitive version of String#<=>. Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from String#casecmp?. "aBcDeF".casecmp("abcde") #=> 1 "aBcDeF".casecmp("abcdef") #=> 0 "aBcDeF".casecmp("abcdefg") #=> -1 "abcdef".casecmp("ABCDEF") #=> 0 +nil+ is returned if the two strings have incompatible encodings, or if +other_str+ is not a string. "foo".casecmp(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}") #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"casecmp(other_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @I ;[;I"@return [-1, 0, +1, nil];T;0; @I ;@F;Mi;N0;[[I"other_str;T0; @I ;[;I"XCase-insensitive version of String#<=>. Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from String#casecmp?. "aBcDeF".casecmp("abcde") #=> 1 "aBcDeF".casecmp("abcdef") #=> 0 "aBcDeF".casecmp("abcdefg") #=> -1 "abcdef".casecmp("ABCDEF") #=> 0 +nil+ is returned if the two strings have incompatible encodings, or if +other_str+ is not a string. "foo".casecmp(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}") #=> nil @overload casecmp(other_str) @return [-1, 0, +1, nil];T;0; @I ;@F;Ao;B;CT;Di& ;Ei7 ;!@;"I"static VALUE rb_str_casecmp(VALUE str1, VALUE str2) { VALUE s = rb_check_string_type(str2); if (NIL_P(s)) { return Qnil; } return str_casecmp(str1, s); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#casecmp?;F;[[I" str2;T0;[[@i ;T;;;0;[;{;IC;"!Returns +true+ if +str+ and +other_str+ are equal after Unicode case folding, +false+ if they are not equal. "aBcDeF".casecmp?("abcde") #=> false "aBcDeF".casecmp?("abcdef") #=> true "aBcDeF".casecmp?("abcdefg") #=> false "abcdef".casecmp?("ABCDEF") #=> true "\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}") #=> true +nil+ is returned if the two strings have incompatible encodings, or if +other_str+ is not a string. "foo".casecmp?(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").casecmp?("\u{c4 d6 dc}") #=> nil;T;[o;H ;II" overload;F;J0;;;K0;#I"casecmp?(other_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @k ;[;I"@return [true, false, nil];T;0; @k ;@F;Mi;N0;[[I"other_str;T0; @k ;[;I"^Returns +true+ if +str+ and +other_str+ are equal after Unicode case folding, +false+ if they are not equal. "aBcDeF".casecmp?("abcde") #=> false "aBcDeF".casecmp?("abcdef") #=> true "aBcDeF".casecmp?("abcdefg") #=> false "abcdef".casecmp?("ABCDEF") #=> true "\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}") #=> true +nil+ is returned if the two strings have incompatible encodings, or if +other_str+ is not a string. "foo".casecmp?(2) #=> nil "\u{e4 f6 fc}".encode("ISO-8859-1").casecmp?("\u{c4 d6 dc}") #=> nil @overload casecmp?(other_str) @return [true, false, nil];T;0; @k ;@F;Ao;B;CT;Di} ;Ei ;Mi;!@;"I"static VALUE rb_str_casecmp_p(VALUE str1, VALUE str2) { VALUE s = rb_check_string_type(str2); if (NIL_P(s)) { return Qnil; } return str_casecmp_p(str1, s); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" String#+;F;[[I" str2;T0;[[@i;T;:+;0;[;{;IC;"Concatenation---Returns a new String containing other_str concatenated to str. "Hello from " + self.to_s #=> "Hello from main" ;T;[o;H ;II" overload;F;J0;;(;K0;#I"+(other_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[I"other_str;T0; @ ;[;I"Concatenation---Returns a new String containing other_str concatenated to str. "Hello from " + self.to_s #=> "Hello from main" @overload +(other_str) @return [String];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"`VALUE rb_str_plus(VALUE str1, VALUE str2) { VALUE str3; rb_encoding *enc; char *ptr1, *ptr2, *ptr3; long len1, len2; int termlen; StringValue(str2); enc = rb_enc_check_str(str1, str2); RSTRING_GETMEM(str1, ptr1, len1); RSTRING_GETMEM(str2, ptr2, len2); termlen = rb_enc_mbminlen(enc); if (len1 > LONG_MAX - len2) { rb_raise(rb_eArgError, "string size too big"); } str3 = str_new0(rb_cString, 0, len1+len2, termlen); ptr3 = RSTRING_PTR(str3); memcpy(ptr3, ptr1, len1); memcpy(ptr3+len1, ptr2, len2); TERM_FILL(&ptr3[len1+len2], termlen); FL_SET_RAW(str3, OBJ_TAINTED_RAW(str1) | OBJ_TAINTED_RAW(str2)); ENCODING_CODERANGE_SET(str3, rb_enc_to_index(enc), ENC_CODERANGE_AND(ENC_CODERANGE(str1), ENC_CODERANGE(str2))); RB_GC_GUARD(str1); RB_GC_GUARD(str2); return str3; };T;#I" VALUE;T;$To; ; F; ;,;;;I" String#*;F;[[I" times;T0;[[@i;T;:*;0;[;{;IC;"Copy --- Returns a new String containing +integer+ copies of the receiver. +integer+ must be greater than or equal to 0. "Ho! " * 3 #=> "Ho! Ho! Ho! " "Ho! " * 0 #=> "" ;T;[o;H ;II" overload;F;J0;;);K0;#I"*(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[I" integer;T0; @ ;[;I"Copy --- Returns a new String containing +integer+ copies of the receiver. +integer+ must be greater than or equal to 0. "Ho! " * 3 #=> "Ho! Ho! Ho! " "Ho! " * 0 #=> "" @overload *(integer) @return [String];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_str_times(VALUE str, VALUE times) { VALUE str2; long n, len; char *ptr2; int termlen; if (times == INT2FIX(1)) { return rb_str_dup(str); } if (times == INT2FIX(0)) { str2 = str_alloc(rb_obj_class(str)); rb_enc_copy(str2, str); OBJ_INFECT(str2, str); return str2; } len = NUM2LONG(times); if (len < 0) { rb_raise(rb_eArgError, "negative argument"); } if (RSTRING_LEN(str) == 1 && RSTRING_PTR(str)[0] == 0) { str2 = str_alloc(rb_obj_class(str)); if (!STR_EMBEDDABLE_P(len, 1)) { RSTRING(str2)->as.heap.aux.capa = len; RSTRING(str2)->as.heap.ptr = ZALLOC_N(char, (size_t)len + 1); STR_SET_NOEMBED(str2); } STR_SET_LEN(str2, len); rb_enc_copy(str2, str); OBJ_INFECT(str2, str); return str2; } if (len && LONG_MAX/len < RSTRING_LEN(str)) { rb_raise(rb_eArgError, "argument too big"); } len *= RSTRING_LEN(str); termlen = TERM_LEN(str); str2 = str_new0(rb_obj_class(str), 0, len, termlen); ptr2 = RSTRING_PTR(str2); if (len) { n = RSTRING_LEN(str); memcpy(ptr2, RSTRING_PTR(str), n); while (n <= len/2) { memcpy(ptr2 + n, ptr2, n); n *= 2; } memcpy(ptr2 + n, ptr2, len-n); } STR_SET_LEN(str2, len); TERM_FILL(&ptr2[len], termlen); OBJ_INFECT(str2, str); rb_enc_cr_str_copy_for_substr(str2, str); return str2; };T;#I" VALUE;T;$To; ; F; ;,;;;I" String#%;F;[[I"arg;T0;[[@i;T;:%;0;[;{;IC;"Format---Uses str as a format specification, and returns the result of applying it to arg. If the format specification contains more than one substitution, then arg must be an Array or Hash containing the values to be substituted. See Kernel::sprintf for details of the format string. "%05d" % 123 #=> "00123" "%-5s: %016x" % [ "ID", self.object_id ] #=> "ID : 00002b054ec93168" "foo = %{foo}" % { :foo => 'bar' } #=> "foo = bar" ;T;[o;H ;II" overload;F;J0;;*;K0;#I" %(arg);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[I"arg;T0; @ ;[;I"@Format---Uses str as a format specification, and returns the result of applying it to arg. If the format specification contains more than one substitution, then arg must be an Array or Hash containing the values to be substituted. See Kernel::sprintf for details of the format string. "%05d" % 123 #=> "00123" "%-5s: %016x" % [ "ID", self.object_id ] #=> "ID : 00002b054ec93168" "foo = %{foo}" % { :foo => 'bar' } #=> "foo = bar" @overload %(arg) @return [String];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_format_m(VALUE str, VALUE arg) { VALUE tmp = rb_check_array_type(arg); if (!NIL_P(tmp)) { return rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str); } return rb_str_format(1, &arg, str); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#[];F;[[@0;[[@i;T;;;0;[;{;IC;"Element Reference --- If passed a single +index+, returns a substring of one character at that index. If passed a +start+ index and a +length+, returns a substring containing +length+ characters starting at the +start+ index. If passed a +range+, its beginning and end are interpreted as offsets delimiting the substring to be returned. In these three cases, if an index is negative, it is counted from the end of the string. For the +start+ and +range+ cases the starting index is just before a character and an index matching the string's size. Additionally, an empty string is returned when the starting index for a character range is at the end of the string. Returns +nil+ if the initial index falls outside the string or the length is negative. If a +Regexp+ is supplied, the matching portion of the string is returned. If a +capture+ follows the regular expression, which may be a capture group index or name, follows the regular expression that component of the MatchData is returned instead. If a +match_str+ is given, that string is returned if it occurs in the string. Returns +nil+ if the regular expression does not match or the match string cannot be found. a = "hello there" a[1] #=> "e" a[2, 3] #=> "llo" a[2..3] #=> "ll" a[-3, 2] #=> "er" a[7..-2] #=> "her" a[-4..-2] #=> "her" a[-2..-4] #=> "" a[11, 0] #=> "" a[11] #=> nil a[12, 0] #=> nil a[12..-1] #=> nil a[/[aeiou](.)\1/] #=> "ell" a[/[aeiou](.)\1/, 0] #=> "ell" a[/[aeiou](.)\1/, 1] #=> "l" a[/[aeiou](.)\1/, 2] #=> nil a[/(?[aeiou])(?[^aeiou])/, "non_vowel"] #=> "l" a[/(?[aeiou])(?[^aeiou])/, "vowel"] #=> "e" a["lo"] #=> "lo" a["bye"] #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"[](index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" index;T0; @ o;H ;II" overload;F;J0;;;K0;#I"[](start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" start;T0[I" length;T0; @ o;H ;II" overload;F;J0;;;K0;#I"[](range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" range;T0; @ o;H ;II" overload;F;J0;;;K0;#I"[](regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" regexp;T0; @ o;H ;II" overload;F;J0;;;K0;#I"[](regexp, capture);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" regexp;T0[I" capture;T0; @ o;H ;II" overload;F;J0;;;K0;#I"[](match_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I"match_str;T0; @ o;H ;II" overload;F;J0;;;K0;#I"slice(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" index;T0; @ o;H ;II" overload;F;J0;;;K0;#I"slice(start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" start;T0[I" length;T0; @ o;H ;II" overload;F;J0;;;K0;#I"slice(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" range;T0; @ o;H ;II" overload;F;J0;;;K0;#I"slice(regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" regexp;T0; @ o;H ;II" overload;F;J0;;;K0;#I"slice(regexp, capture);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" regexp;T0[I" capture;T0; @ o;H ;II" overload;F;J0;;;K0;#I"slice(match_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I"match_str;T0; @ ;[;I" Element Reference --- If passed a single +index+, returns a substring of one character at that index. If passed a +start+ index and a +length+, returns a substring containing +length+ characters starting at the +start+ index. If passed a +range+, its beginning and end are interpreted as offsets delimiting the substring to be returned. In these three cases, if an index is negative, it is counted from the end of the string. For the +start+ and +range+ cases the starting index is just before a character and an index matching the string's size. Additionally, an empty string is returned when the starting index for a character range is at the end of the string. Returns +nil+ if the initial index falls outside the string or the length is negative. If a +Regexp+ is supplied, the matching portion of the string is returned. If a +capture+ follows the regular expression, which may be a capture group index or name, follows the regular expression that component of the MatchData is returned instead. If a +match_str+ is given, that string is returned if it occurs in the string. Returns +nil+ if the regular expression does not match or the match string cannot be found. a = "hello there" a[1] #=> "e" a[2, 3] #=> "llo" a[2..3] #=> "ll" a[-3, 2] #=> "er" a[7..-2] #=> "her" a[-4..-2] #=> "her" a[-2..-4] #=> "" a[11, 0] #=> "" a[11] #=> nil a[12, 0] #=> nil a[12..-1] #=> nil a[/[aeiou](.)\1/] #=> "ell" a[/[aeiou](.)\1/, 0] #=> "ell" a[/[aeiou](.)\1/, 1] #=> "l" a[/[aeiou](.)\1/, 2] #=> nil a[/(?[aeiou])(?[^aeiou])/, "non_vowel"] #=> "l" a[/(?[aeiou])(?[^aeiou])/, "vowel"] #=> "e" a["lo"] #=> "lo" a["bye"] #=> nil @overload [](index) @return [String, nil] @overload [](start, length) @return [String, nil] @overload [](range) @return [String, nil] @overload [](regexp) @return [String, nil] @overload [](regexp, capture) @return [String, nil] @overload [](match_str) @return [String, nil] @overload slice(index) @return [String, nil] @overload slice(start, length) @return [String, nil] @overload slice(range) @return [String, nil] @overload slice(regexp) @return [String, nil] @overload slice(regexp, capture) @return [String, nil] @overload slice(match_str) @return [String, nil];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"vstatic VALUE rb_str_aref_m(int argc, VALUE *argv, VALUE str) { if (argc == 2) { if (RB_TYPE_P(argv[0], T_REGEXP)) { return rb_str_subpat(str, argv[0], argv[1]); } else { long beg = NUM2LONG(argv[0]); long len = NUM2LONG(argv[1]); return rb_str_substr(str, beg, len); } } rb_check_arity(argc, 1, 2); return rb_str_aref(str, argv[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#[]=;F;[[@0;[[@i;T;:[]=;0;[;{;IC;"Element Assignment---Replaces some or all of the content of str. The portion of the string affected is determined using the same criteria as String#[]. If the replacement string is not the same length as the text it is replacing, the string will be adjusted accordingly. If the regular expression or string is used as the index doesn't match a position in the string, IndexError is raised. If the regular expression form is used, the optional second Integer allows you to specify which portion of the match to replace (effectively using the MatchData indexing rules. The forms that take an Integer will raise an IndexError if the value is out of range; the Range form will raise a RangeError, and the Regexp and String will raise an IndexError on negative match. ;T;[ o;H ;II" overload;F;J0;;+;K0;#I"[]=(integer);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I" integer;T0; @!o;H ;II" overload;F;J0;;+;K0;#I"[]=(integer, integer);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I" integer;T0[I" integer;T0; @!o;H ;II" overload;F;J0;;+;K0;#I"[]=(range);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I" range;T0; @!o;H ;II" overload;F;J0;;+;K0;#I"[]=(regexp);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I" regexp;T0; @!o;H ;II" overload;F;J0;;+;K0;#I"[]=(regexp, integer);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I" regexp;T0[I" integer;T0; @!o;H ;II" overload;F;J0;;+;K0;#I"[]=(regexp, name);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I" regexp;T0[I" name;T0; @!o;H ;II" overload;F;J0;;+;K0;#I"[]=(other_str);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I"other_str;T0; @!;[;I"HElement Assignment---Replaces some or all of the content of str. The portion of the string affected is determined using the same criteria as String#[]. If the replacement string is not the same length as the text it is replacing, the string will be adjusted accordingly. If the regular expression or string is used as the index doesn't match a position in the string, IndexError is raised. If the regular expression form is used, the optional second Integer allows you to specify which portion of the match to replace (effectively using the MatchData indexing rules. The forms that take an Integer will raise an IndexError if the value is out of range; the Range form will raise a RangeError, and the Regexp and String will raise an IndexError on negative match. @overload []=(integer) @overload []=(integer, integer) @overload []=(range) @overload []=(regexp) @overload []=(regexp, integer) @overload []=(regexp, name) @overload []=(other_str);T;0; @!;@F;Ao;B;CT;Di;Ei;!@;"I"nstatic VALUE rb_str_aset_m(int argc, VALUE *argv, VALUE str) { if (argc == 3) { if (RB_TYPE_P(argv[0], T_REGEXP)) { rb_str_subpat_set(str, argv[0], argv[1], argv[2]); } else { rb_str_splice(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]); } return argv[2]; } rb_check_arity(argc, 2, 3); return rb_str_aset(str, argv[0], argv[1]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#insert;F;[[I"idx;T0[I" str2;T0;[[@i;T;: insert;0;[;{;IC;"Inserts other_str before the character at the given index, modifying str. Negative indices count from the end of the string, and insert after the given character. The intent is insert aString so that it starts at the given index. "abcd".insert(0, 'X') #=> "Xabcd" "abcd".insert(3, 'X') #=> "abcXd" "abcd".insert(4, 'X') #=> "abcdX" "abcd".insert(-3, 'X') #=> "abXcd" "abcd".insert(-1, 'X') #=> "abcdX" ;T;[o;H ;II" overload;F;J0;;,;K0;#I"insert(index, other_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @";[;I"@return [String];T;0; @";@F;Mi;N0;[[I" index;T0[I"other_str;T0; @";[;I"Inserts other_str before the character at the given index, modifying str. Negative indices count from the end of the string, and insert after the given character. The intent is insert aString so that it starts at the given index. "abcd".insert(0, 'X') #=> "Xabcd" "abcd".insert(3, 'X') #=> "abcXd" "abcd".insert(4, 'X') #=> "abcdX" "abcd".insert(-3, 'X') #=> "abXcd" "abcd".insert(-1, 'X') #=> "abcdX" @overload insert(index, other_str) @return [String];T;0; @";@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_insert(VALUE str, VALUE idx, VALUE str2) { long pos = NUM2LONG(idx); if (pos == -1) { return rb_str_append(str, str2); } else if (pos < 0) { pos++; } rb_str_splice(str, pos, 0, str2); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#length;F;[;[[@i\;T;;;0;[;{;IC;"0Returns the character length of str. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @>";[;I"@return [Integer];T;0; @>";@F;Mi;N0;[; @>"o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @>";[;I"@return [Integer];T;0; @>";@F;Mi;N0;[; @>";[;I"zReturns the character length of str. @overload length @return [Integer] @overload size @return [Integer];T;0; @>";@F;Ao;B;CT;DiT;EiZ;!@;"I"SVALUE rb_str_length(VALUE str) { return LONG2NUM(str_strlen(str, NULL)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#size;F;[;[[@i\;T;;;0;[;{;IC;"0Returns the character length of str. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @f";[;I"@return [Integer];T;0; @f";@F;Mi;N0;[; @f"o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @f";[;I"@return [Integer];T;0; @f";@F;Mi;N0;[; @f";[;@b";0; @f";@F;Ao;B;CT;DiT;EiZ;!@;"I"SVALUE rb_str_length(VALUE str) { return LONG2NUM(str_strlen(str, NULL)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#bytesize;F;[;[[@il;T;: bytesize;0;[;{;IC;"iReturns the length of +str+ in bytes. "\x80\u3042".bytesize #=> 4 "hello".bytesize #=> 5 ;T;[o;H ;II" overload;F;J0;;-;K0;#I" bytesize;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @";[;I"@return [Integer];T;0; @";@F;Mi;N0;[; @";[;I"Returns the length of +str+ in bytes. "\x80\u3042".bytesize #=> 4 "hello".bytesize #=> 5 @overload bytesize @return [Integer];T;0; @";@F;Ao;B;CT;Dib;Eii;!@;"I"Wstatic VALUE rb_str_bytesize(VALUE str) { return LONG2NUM(RSTRING_LEN(str)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#empty?;F;[;[[@i};T;;;0;[;{;IC;"Returns true if str has a length of zero. "hello".empty? #=> false " ".empty? #=> false "".empty? #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @";[;I"@return [Boolean];T;0; @";@F;Mi;N0;[; @";[;I"Returns true if str has a length of zero. "hello".empty? #=> false " ".empty? #=> false "".empty? #=> true @overload empty? @return [Boolean];T;0; @";@F;Ao;B;CT;Dir;Eiz;Mi;!@;"I"nstatic VALUE rb_str_empty(VALUE str) { if (RSTRING_LEN(str) == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#=~;F;[[I"y;T0;[[@i;T;;P;0;[;{;IC;"FMatch---If obj is a Regexp, use it as a pattern to match against str,and returns the position the match starts, or nil if there is no match. Otherwise, invokes obj.=~, passing str as an argument. The default =~ in Object returns nil. Note: str =~ regexp is not the same as regexp =~ str. Strings captured from named capture groups are assigned to local variables only in the second case. "cat o' 9 tails" =~ /\d/ #=> 7 "cat o' 9 tails" =~ 9 #=> nil ;T;[o;H ;II" overload;F;J0;;P;K0;#I" =~(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @";[;I"@return [Integer, nil];T;0; @";@F;Mi;N0;[[I"obj;T0; @";[;I"sMatch---If obj is a Regexp, use it as a pattern to match against str,and returns the position the match starts, or nil if there is no match. Otherwise, invokes obj.=~, passing str as an argument. The default =~ in Object returns nil. Note: str =~ regexp is not the same as regexp =~ str. Strings captured from named capture groups are assigned to local variables only in the second case. "cat o' 9 tails" =~ /\d/ #=> 7 "cat o' 9 tails" =~ 9 #=> nil @overload =~(obj) @return [Integer, nil];T;0; @";@F;Ao;B;CT;Di;Ei;!@;"I"Estatic VALUE rb_str_match(VALUE x, VALUE y) { if (SPECIAL_CONST_P(y)) goto generic; switch (BUILTIN_TYPE(y)) { case T_STRING: rb_raise(rb_eTypeError, "type mismatch: String given"); case T_REGEXP: return rb_reg_match(y, x); generic: default: return rb_funcall(y, idEqTilde, 1, x); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#match;F;[[@0;[[@i;T;;;0;[;{;IC;"Converts pattern to a Regexp (if it isn't already one), then invokes its match method on str. If the second parameter is present, it specifies the position in the string to begin the search. 'hello'.match('(.)\1') #=> # 'hello'.match('(.)\1')[0] #=> "ll" 'hello'.match(/(.)\1/)[0] #=> "ll" 'hello'.match(/(.)\1/, 3) #=> nil 'hello'.match('xx') #=> nil If a block is given, invoke the block with MatchData if match succeed, so that you can write str.match(pat) {|m| ...} instead of if m = str.match(pat) ... end The return value is a value from block execution in this case. ;T;[o;H ;II" overload;F;J0;;;K0;#I"match(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"MatchData;TI"nil;T; @";[;I"@return [MatchData, nil];T;0; @";@F;Mi;N0;[[I" pattern;T0; @"o;H ;II" overload;F;J0;;;K0;#I"match(pattern, pos);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"MatchData;TI"nil;T; @";[;I"@return [MatchData, nil];T;0; @";@F;Mi;N0;[[I" pattern;T0[I"pos;T0; @";[;I"!Converts pattern to a Regexp (if it isn't already one), then invokes its match method on str. If the second parameter is present, it specifies the position in the string to begin the search. 'hello'.match('(.)\1') #=> # 'hello'.match('(.)\1')[0] #=> "ll" 'hello'.match(/(.)\1/)[0] #=> "ll" 'hello'.match(/(.)\1/, 3) #=> nil 'hello'.match('xx') #=> nil If a block is given, invoke the block with MatchData if match succeed, so that you can write str.match(pat) {|m| ...} instead of if m = str.match(pat) ... end The return value is a value from block execution in this case. @overload match(pattern) @return [MatchData, nil] @overload match(pattern, pos) @return [MatchData, nil];T;0; @";@F;Ao;B;CT;Di;Ei;!@;"I"Ustatic VALUE rb_str_match_m(int argc, VALUE *argv, VALUE str) { VALUE re, result; if (argc < 1) rb_check_arity(argc, 1, 2); re = argv[0]; argv[0] = str; result = rb_funcallv(get_pat(re), rb_intern("match"), argc, argv); if (!NIL_P(result) && rb_block_given_p()) { return rb_yield(result); } return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#match?;F;[[@0;[[@i>;T;;;0;[;{;IC;"Converts _pattern_ to a +Regexp+ (if it isn't already one), then returns a +true+ or +false+ indicates whether the regexp is matched _str_ 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. "Ruby".match?(/R.../) #=> true "Ruby".match?(/R.../, 1) #=> false "Ruby".match?(/P.../) #=> false $& #=> nil;T;[o;H ;II" overload;F;J0;;;K0;#I"match?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @#;[;I"@return [Boolean];T;0; @#;@F;Mi;N0;[[I" pattern;T0; @#o;H ;II" overload;F;J0;;;K0;#I"match?(pattern, pos);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @#;[;I"@return [Boolean];T;0; @#;@F;Mi;N0;[[I" pattern;T0[I"pos;T0; @#;[;I"*Converts _pattern_ to a +Regexp+ (if it isn't already one), then returns a +true+ or +false+ indicates whether the regexp is matched _str_ 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. "Ruby".match?(/R.../) #=> true "Ruby".match?(/R.../, 1) #=> false "Ruby".match?(/P.../) #=> false $& #=> nil @overload match?(pattern) @return [Boolean] @overload match?(pattern, pos) @return [Boolean];T;0; @#;@F;Ao;B;CT;Di-;Ei<;Mi;!@;"I"static VALUE rb_str_match_m_p(int argc, VALUE *argv, VALUE str) { VALUE re; rb_check_arity(argc, 1, 2); re = get_pat(argv[0]); return rb_reg_match_p(re, str, argc > 1 ? NUM2LONG(argv[1]) : 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#succ;F;[;[[@i;T;;;0;[;{;IC;")Returns the successor to str. The successor is calculated by incrementing characters starting from the rightmost alphanumeric (or the rightmost character if there are no alphanumerics) in the string. Incrementing a digit always results in another digit, and incrementing a letter results in another letter of the same case. Incrementing nonalphanumerics uses the underlying character set's collating sequence. If the increment generates a ``carry,'' the character to the left of it is incremented. This process repeats until there is no carry, adding an additional character if necessary. "abcd".succ #=> "abce" "THX1138".succ #=> "THX1139" "<>".succ #=> "<>" "1999zzz".succ #=> "2000aaa" "ZZZ9999".succ #=> "AAAA0000" "***".succ #=> "**+" ;T;[o;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @C#;[;I"@return [String];T;0; @C#;@F;Mi;N0;[; @C#o;H ;II" overload;F;J0;;;K0;#I" next;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @C#;[;I"@return [String];T;0; @C#;@F;Mi;N0;[; @C#;[;I"oReturns the successor to str. The successor is calculated by incrementing characters starting from the rightmost alphanumeric (or the rightmost character if there are no alphanumerics) in the string. Incrementing a digit always results in another digit, and incrementing a letter results in another letter of the same case. Incrementing nonalphanumerics uses the underlying character set's collating sequence. If the increment generates a ``carry,'' the character to the left of it is incremented. This process repeats until there is no carry, adding an additional character if necessary. "abcd".succ #=> "abce" "THX1138".succ #=> "THX1139" "<>".succ #=> "<>" "1999zzz".succ #=> "2000aaa" "ZZZ9999".succ #=> "AAAA0000" "***".succ #=> "**+" @overload succ @return [String] @overload next @return [String];T;0; @C#;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_str_succ(VALUE orig) { VALUE str; str = rb_str_new_with_class(orig, RSTRING_PTR(orig), RSTRING_LEN(orig)); rb_enc_cr_str_copy_for_substr(str, orig); OBJ_INFECT(str, orig); return str_succ(str); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#succ!;F;[;[[@i;T;: succ!;0;[;{;IC;"PEquivalent to String#succ, but modifies the receiver in place. ;T;[o;H ;II" overload;F;J0;;.;K0;#I" succ!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k#;[;I"@return [String];T;0; @k#;@F;Mi;N0;[; @k#o;H ;II" overload;F;J0;: next!;K0;#I" next!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k#;[;I"@return [String];T;0; @k#;@F;Mi;N0;[; @k#;[;I"Equivalent to String#succ, but modifies the receiver in place. @overload succ! @return [String] @overload next! @return [String];T;0; @k#;@F;Ao;B;CT;Di|;Ei;!@;"I"lstatic VALUE rb_str_succ_bang(VALUE str) { rb_str_modify(str); str_succ(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#next;F;[;[[@i;T;;;0;[;{;IC;")Returns the successor to str. The successor is calculated by incrementing characters starting from the rightmost alphanumeric (or the rightmost character if there are no alphanumerics) in the string. Incrementing a digit always results in another digit, and incrementing a letter results in another letter of the same case. Incrementing nonalphanumerics uses the underlying character set's collating sequence. If the increment generates a ``carry,'' the character to the left of it is incremented. This process repeats until there is no carry, adding an additional character if necessary. "abcd".succ #=> "abce" "THX1138".succ #=> "THX1139" "<>".succ #=> "<>" "1999zzz".succ #=> "2000aaa" "ZZZ9999".succ #=> "AAAA0000" "***".succ #=> "**+" ;T;[o;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I"@return [String];T;0; @#;@F;Mi;N0;[; @#o;H ;II" overload;F;J0;;;K0;#I" next;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I"@return [String];T;0; @#;@F;Mi;N0;[; @#;[;@g#;0; @#;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_str_succ(VALUE orig) { VALUE str; str = rb_str_new_with_class(orig, RSTRING_PTR(orig), RSTRING_LEN(orig)); rb_enc_cr_str_copy_for_substr(str, orig); OBJ_INFECT(str, orig); return str_succ(str); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#next!;F;[;[[@i;T;;/;0;[;{;IC;"PEquivalent to String#succ, but modifies the receiver in place. ;T;[o;H ;II" overload;F;J0;;.;K0;#I" succ!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I"@return [String];T;0; @#;@F;Mi;N0;[; @#o;H ;II" overload;F;J0;;/;K0;#I" next!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I"@return [String];T;0; @#;@F;Mi;N0;[; @#;[;@#;0; @#;@F;Ao;B;CT;Di|;Ei;!@;"I"lstatic VALUE rb_str_succ_bang(VALUE str) { rb_str_modify(str); str_succ(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#upto;F;[[@0;[[@i;T;: upto;0;[;{;IC;"Iterates through successive values, starting at str and ending at other_str inclusive, passing each value in turn to the block. The String#succ method is used to generate each value. If optional second argument exclusive is omitted or is false, the last value will be included; otherwise it will be excluded. If no block is given, an enumerator is returned instead. "a8".upto("b6") {|s| print s, ' ' } for s in "a8".."b6" print s, ' ' end produces: a8 a9 b0 b1 b2 b3 b4 b5 b6 a8 a9 b0 b1 b2 b3 b4 b5 b6 If str and other_str contains only ascii numeric characters, both are recognized as decimal numbers. In addition, the width of string (e.g. leading zeros) is handled appropriately. "9".upto("11").to_a #=> ["9", "10", "11"] "25".upto("5").to_a #=> [] "07".upto("11").to_a #=> ["07", "08", "09", "10", "11"] ;T;[o;H ;II" overload;F;J0;;0;K0;#I"%upto(other_str, exclusive=false);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"s;T; @#o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I" @yield [s] @return [String];T;0; @#;@F;Mi;N0;[[I"other_str;T0[I"exclusive;TI" false;T; @#o;H ;II" overload;F;J0;;0;K0;#I"%upto(other_str, exclusive=false);T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[[I"other_str;T0[I"exclusive;TI" false;T; @#;[;I"Iterates through successive values, starting at str and ending at other_str inclusive, passing each value in turn to the block. The String#succ method is used to generate each value. If optional second argument exclusive is omitted or is false, the last value will be included; otherwise it will be excluded. If no block is given, an enumerator is returned instead. "a8".upto("b6") {|s| print s, ' ' } for s in "a8".."b6" print s, ' ' end produces: a8 a9 b0 b1 b2 b3 b4 b5 b6 a8 a9 b0 b1 b2 b3 b4 b5 b6 If str and other_str contains only ascii numeric characters, both are recognized as decimal numbers. In addition, the width of string (e.g. leading zeros) is handled appropriately. "9".upto("11").to_a #=> ["9", "10", "11"] "25".upto("5").to_a #=> [] "07".upto("11").to_a #=> ["07", "08", "09", "10", "11"] @overload upto(other_str, exclusive=false) @yield [s] @return [String] @overload upto(other_str, exclusive=false);T;0; @#;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_upto(int argc, VALUE *argv, VALUE beg) { VALUE end, exclusive; rb_scan_args(argc, argv, "11", &end, &exclusive); RETURN_ENUMERATOR(beg, argc, argv); return rb_str_upto_each(beg, end, RTEST(exclusive), str_upto_i, Qnil); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#index;F;[[@0;[[@i ;T;: index;0;[;{;IC;"Returns the index of the first occurrence of the given substring or pattern (regexp) in str. Returns nil if not found. If the second parameter is present, it specifies the position in the string to begin the search. "hello".index('e') #=> 1 "hello".index('lo') #=> 3 "hello".index('a') #=> nil "hello".index(?e) #=> 1 "hello".index(/[aeiou]/, -3) #=> 4 ;T;[o;H ;II" overload;F;J0;;1;K0;#I" index(substring [, offset]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @$;[;I"@return [Integer, nil];T;0; @$;@F;Mi;N0;[[I"substring[, offset];T0; @$o;H ;II" overload;F;J0;;1;K0;#I"index(regexp [, offset]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @$;[;I"@return [Integer, nil];T;0; @$;@F;Mi;N0;[[I"regexp[, offset];T0; @$;[;I"AReturns the index of the first occurrence of the given substring or pattern (regexp) in str. Returns nil if not found. If the second parameter is present, it specifies the position in the string to begin the search. "hello".index('e') #=> 1 "hello".index('lo') #=> 3 "hello".index('a') #=> nil "hello".index(?e) #=> 1 "hello".index(/[aeiou]/, -3) #=> 4 @overload index(substring [, offset]) @return [Integer, nil] @overload index(regexp [, offset]) @return [Integer, nil];T;0; @$;@F;Ao;B;CT;Di ;Ei ;!@;"I"rstatic VALUE rb_str_index_m(int argc, VALUE *argv, VALUE str) { VALUE sub; VALUE initpos; long pos; if (rb_scan_args(argc, argv, "11", &sub, &initpos) == 2) { pos = NUM2LONG(initpos); } else { pos = 0; } if (pos < 0) { pos += str_strlen(str, NULL); if (pos < 0) { if (RB_TYPE_P(sub, T_REGEXP)) { rb_backref_set(Qnil); } return Qnil; } } if (SPECIAL_CONST_P(sub)) goto generic; switch (BUILTIN_TYPE(sub)) { case T_REGEXP: if (pos > str_strlen(str, NULL)) return Qnil; pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos, rb_enc_check(str, sub), single_byte_optimizable(str)); pos = rb_reg_search(sub, str, pos, 0); pos = rb_str_sublen(str, pos); break; generic: default: { VALUE tmp; tmp = rb_check_string_type(sub); if (NIL_P(tmp)) { rb_raise(rb_eTypeError, "type mismatch: %s given", rb_obj_classname(sub)); } sub = tmp; } /* fall through */ case T_STRING: pos = rb_str_index(str, sub, pos); pos = rb_str_sublen(str, pos); break; } if (pos == -1) return Qnil; return LONG2NUM(pos); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#rindex;F;[[@0;[[@i;T;: rindex;0;[;{;IC;"Returns the index of the last occurrence of the given substring or pattern (regexp) in str. Returns nil if not found. If the second parameter is present, it specifies the position in the string to end the search---characters beyond this point will not be considered. "hello".rindex('e') #=> 1 "hello".rindex('l') #=> 3 "hello".rindex('a') #=> nil "hello".rindex(?e) #=> 1 "hello".rindex(/[aeiou]/, -2) #=> 1 ;T;[o;H ;II" overload;F;J0;;2;K0;#I""rindex(substring [, integer]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @C$;[;I"@return [Integer, nil];T;0; @C$;@F;Mi;N0;[[I"substring[, integer];T0; @C$o;H ;II" overload;F;J0;;2;K0;#I"rindex(regexp [, integer]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @C$;[;I"@return [Integer, nil];T;0; @C$;@F;Mi;N0;[[I"regexp[, integer];T0; @C$;[;I"}Returns the index of the last occurrence of the given substring or pattern (regexp) in str. Returns nil if not found. If the second parameter is present, it specifies the position in the string to end the search---characters beyond this point will not be considered. "hello".rindex('e') #=> 1 "hello".rindex('l') #=> 3 "hello".rindex('a') #=> nil "hello".rindex(?e) #=> 1 "hello".rindex(/[aeiou]/, -2) #=> 1 @overload rindex(substring [, integer]) @return [Integer, nil] @overload rindex(regexp [, integer]) @return [Integer, nil];T;0; @C$;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_rindex_m(int argc, VALUE *argv, VALUE str) { VALUE sub; VALUE vpos; rb_encoding *enc = STR_ENC_GET(str); long pos, len = str_strlen(str, enc); /* str's enc */ if (rb_scan_args(argc, argv, "11", &sub, &vpos) == 2) { pos = NUM2LONG(vpos); if (pos < 0) { pos += len; if (pos < 0) { if (RB_TYPE_P(sub, T_REGEXP)) { rb_backref_set(Qnil); } return Qnil; } } if (pos > len) pos = len; } else { pos = len; } if (SPECIAL_CONST_P(sub)) goto generic; switch (BUILTIN_TYPE(sub)) { case T_REGEXP: /* enc = rb_get_check(str, sub); */ pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos, enc, single_byte_optimizable(str)); pos = rb_reg_search(sub, str, pos, 1); pos = rb_str_sublen(str, pos); if (pos >= 0) return LONG2NUM(pos); break; generic: default: { VALUE tmp; tmp = rb_check_string_type(sub); if (NIL_P(tmp)) { rb_raise(rb_eTypeError, "type mismatch: %s given", rb_obj_classname(sub)); } sub = tmp; } /* fall through */ case T_STRING: pos = rb_str_rindex(str, sub, pos); if (pos >= 0) return LONG2NUM(pos); break; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#replace;F;[[I" str2;T0;[[@i;T;;';0;[;{;IC;"Replaces the contents and taintedness of str with the corresponding values in other_str. s = "hello" #=> "hello" s.replace "world" #=> "world" ;T;[o;H ;II" overload;F;J0;;';K0;#I"replace(other_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @r$;[;I"@return [String];T;0; @r$;@F;Mi;N0;[[I"other_str;T0; @r$;[;@;0; @r$;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_str_replace(VALUE str, VALUE str2) { str_modifiable(str); if (str == str2) return str; StringValue(str2); str_discard(str); return str_replace(str, str2); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#clear;F;[;[[@i;T;: clear;0;[;{;IC;"=Makes string empty. a = "abcde" a.clear #=> "" ;T;[o;H ;II" overload;F;J0;;3;K0;#I" clear;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @$;[;I"@return [String];T;0; @$;@F;Mi;N0;[; @$;[;I"bMakes string empty. a = "abcde" a.clear #=> "" @overload clear @return [String];T;0; @$;@F;Ao;B;CT;Di;Ei;!@;"I"4static VALUE rb_str_clear(VALUE str) { str_discard(str); STR_SET_EMBED(str); STR_SET_EMBED_LEN(str, 0); RSTRING_PTR(str)[0] = 0; if (rb_enc_asciicompat(STR_ENC_GET(str))) ENC_CODERANGE_SET(str, ENC_CODERANGE_7BIT); else ENC_CODERANGE_SET(str, ENC_CODERANGE_VALID); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#chr;F;[;[[@i1;T;:chr;0;[;{;IC;"gReturns a one-character string at the beginning of the string. a = "abcde" a.chr #=> "a" ;T;[o;H ;II" overload;F;J0;;4;K0;#I"chr;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @$;[;I"@return [String];T;0; @$;@F;Mi;N0;[; @$;[;I"Returns a one-character string at the beginning of the string. a = "abcde" a.chr #=> "a" @overload chr @return [String];T;0; @$;@F;Ao;B;CT;Di';Ei.;!@;"I"Pstatic VALUE rb_str_chr(VALUE str) { return rb_str_substr(str, 0, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#getbyte;F;[[I" index;T0;[[@i=;T;: getbyte;0;[;{;IC;"3returns the indexth byte as an integer. ;T;[o;H ;II" overload;F;J0;;5;K0;#I"getbyte(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" 0 .. 255;T; @$;[;I"@return [0 .. 255];T;0; @$;@F;Mi;N0;[[I" index;T0; @$;[;I"creturns the indexth byte as an integer. @overload getbyte(index) @return [0 .. 255];T;0; @$;@F;Ao;B;CT;Di7;Ei;;!@;"I"static VALUE rb_str_getbyte(VALUE str, VALUE index) { long pos = NUM2LONG(index); if (pos < 0) pos += RSTRING_LEN(str); if (pos < 0 || RSTRING_LEN(str) <= pos) return Qnil; return INT2FIX((unsigned char)RSTRING_PTR(str)[pos]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#setbyte;F;[[I" index;T0[I" value;T0;[[@iP;T;: setbyte;0;[;{;IC;"8modifies the indexth byte as integer. ;T;[o;H ;II" overload;F;J0;;6;K0;#I"setbyte(index, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @$;[;I"@return [Integer];T;0; @$;@F;Mi;N0;[[I" index;T0[I" integer;T0; @$;[;I"pmodifies the indexth byte as integer. @overload setbyte(index, integer) @return [Integer];T;0; @$;@F;Ao;B;CT;DiJ;EiN;!@;"I"static VALUE rb_str_setbyte(VALUE str, VALUE index, VALUE value) { long pos = NUM2LONG(index); long len = RSTRING_LEN(str); char *head, *left = 0; unsigned char *ptr; rb_encoding *enc; int cr = ENC_CODERANGE_UNKNOWN, width, nlen; if (pos < -len || len <= pos) rb_raise(rb_eIndexError, "index %ld out of string", pos); if (pos < 0) pos += len; VALUE v = rb_to_int(value); VALUE w = rb_int_modulo(v, INT2FIX(256)); unsigned char byte = NUM2INT(w) & 0xFF; if (!str_independent(str)) str_make_independent(str); enc = STR_ENC_GET(str); head = RSTRING_PTR(str); ptr = (unsigned char *)&head[pos]; if (!STR_EMBED_P(str)) { cr = ENC_CODERANGE(str); switch (cr) { case ENC_CODERANGE_7BIT: left = (char *)ptr; *ptr = byte; if (ISASCII(byte)) goto end; nlen = rb_enc_precise_mbclen(left, head+len, enc); if (!MBCLEN_CHARFOUND_P(nlen)) ENC_CODERANGE_SET(str, ENC_CODERANGE_BROKEN); else ENC_CODERANGE_SET(str, ENC_CODERANGE_VALID); goto end; case ENC_CODERANGE_VALID: left = rb_enc_left_char_head(head, ptr, head+len, enc); width = rb_enc_precise_mbclen(left, head+len, enc); *ptr = byte; nlen = rb_enc_precise_mbclen(left, head+len, enc); if (!MBCLEN_CHARFOUND_P(nlen)) ENC_CODERANGE_SET(str, ENC_CODERANGE_BROKEN); else if (MBCLEN_CHARFOUND_LEN(nlen) != width || ISASCII(byte)) ENC_CODERANGE_CLEAR(str); goto end; } } ENC_CODERANGE_CLEAR(str); *ptr = byte; end: return value; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#byteslice;F;[[@0;[[@i;T;:byteslice;0;[;{;IC;"XByte Reference---If passed a single Integer, returns a substring of one byte at that position. If passed two Integer objects, returns a substring starting at the offset given by the first, and a length given by the second. If given a Range, a substring containing bytes at offsets given by the range is returned. In all three cases, if an offset is negative, it is counted from the end of str. Returns nil if the initial offset falls outside the string, the length is negative, or the beginning of the range is greater than the end. The encoding of the resulted string keeps original encoding. "hello".byteslice(1) #=> "e" "hello".byteslice(-1) #=> "o" "hello".byteslice(1, 2) #=> "el" "\x80\u3042".byteslice(1, 3) #=> "\u3042" "\x03\u3042\xff".byteslice(1..3) #=> "\u3042" ;T;[o;H ;II" overload;F;J0;;7;K0;#I"byteslice(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @%;[;I"@return [String, nil];T;0; @%;@F;Mi;N0;[[I" integer;T0; @%o;H ;II" overload;F;J0;;7;K0;#I" byteslice(integer, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @%;[;I"@return [String, nil];T;0; @%;@F;Mi;N0;[[I" integer;T0[I" integer;T0; @%o;H ;II" overload;F;J0;;7;K0;#I"byteslice(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @%;[;I"@return [String, nil];T;0; @%;@F;Mi;N0;[[I" range;T0; @%;[;I"Byte Reference---If passed a single Integer, returns a substring of one byte at that position. If passed two Integer objects, returns a substring starting at the offset given by the first, and a length given by the second. If given a Range, a substring containing bytes at offsets given by the range is returned. In all three cases, if an offset is negative, it is counted from the end of str. Returns nil if the initial offset falls outside the string, the length is negative, or the beginning of the range is greater than the end. The encoding of the resulted string keeps original encoding. "hello".byteslice(1) #=> "e" "hello".byteslice(-1) #=> "o" "hello".byteslice(1, 2) #=> "el" "\x80\u3042".byteslice(1, 3) #=> "\u3042" "\x03\u3042\xff".byteslice(1..3) #=> "\u3042" @overload byteslice(integer) @return [String, nil] @overload byteslice(integer, integer) @return [String, nil] @overload byteslice(range) @return [String, nil];T;0; @%;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_byteslice(int argc, VALUE *argv, VALUE str) { if (argc == 2) { long beg = NUM2LONG(argv[0]); long end = NUM2LONG(argv[1]); return str_byte_substr(str, beg, end, TRUE); } rb_check_arity(argc, 1, 2); return str_byte_aref(str, argv[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#scrub;F;[[@0;[[@i(;T;: scrub;0;[;{;IC;"{If the string is invalid byte sequence then replace invalid bytes with given replacement character, else returns self. If block is given, replace invalid bytes with returned value of the block. "abc\u3042\x81".scrub #=> "abc\u3042\uFFFD" "abc\u3042\x81".scrub("*") #=> "abc\u3042*" "abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042" ;T;[o;H ;II" overload;F;J0;;8;K0;#I" scrub;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I%;[;I"@return [String];T;0; @I%;@F;Mi;N0;[; @I%o;H ;II" overload;F;J0;;8;K0;#I"scrub(repl);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I%;[;I"@return [String];T;0; @I%;@F;Mi;N0;[[I" repl;T0; @I%o;H ;II" overload;F;J0;;8;K0;#I" scrub;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" bytes;T; @I%o;L ;II" return;F;JI";T;0;K[I" String;T; @I%;[;I"$@yield [bytes] @return [String];T;0; @I%;@F;Mi;N0;[; @I%;[;I"If the string is invalid byte sequence then replace invalid bytes with given replacement character, else returns self. If block is given, replace invalid bytes with returned value of the block. "abc\u3042\x81".scrub #=> "abc\u3042\uFFFD" "abc\u3042\x81".scrub("*") #=> "abc\u3042*" "abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042" @overload scrub @return [String] @overload scrub(repl) @return [String] @overload scrub @yield [bytes] @return [String];T;0; @I%;@F;Ao;B;CT;Di(;Ei(;!@;"I"static VALUE str_scrub(int argc, VALUE *argv, VALUE str) { VALUE repl = argc ? (rb_check_arity(argc, 0, 1), argv[0]) : Qnil; VALUE new = rb_str_scrub(str, repl); return NIL_P(new) ? rb_str_dup(str): new; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#scrub!;F;[[@0;[[@i(;T;: scrub!;0;[;{;IC;"~If the string is invalid byte sequence then replace invalid bytes with given replacement character, else returns self. If block is given, replace invalid bytes with returned value of the block. "abc\u3042\x81".scrub! #=> "abc\u3042\uFFFD" "abc\u3042\x81".scrub!("*") #=> "abc\u3042*" "abc\u3042\xE3\x80".scrub!{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042" ;T;[o;H ;II" overload;F;J0;;9;K0;#I" scrub!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @%;[;I"@return [String];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;;9;K0;#I"scrub!(repl);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @%;[;I"@return [String];T;0; @%;@F;Mi;N0;[[I" repl;T0; @%o;H ;II" overload;F;J0;;9;K0;#I" scrub!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" bytes;T; @%o;L ;II" return;F;JI";T;0;K[I" String;T; @%;[;I"$@yield [bytes] @return [String];T;0; @%;@F;Mi;N0;[; @%;[;I"If the string is invalid byte sequence then replace invalid bytes with given replacement character, else returns self. If block is given, replace invalid bytes with returned value of the block. "abc\u3042\x81".scrub! #=> "abc\u3042\uFFFD" "abc\u3042\x81".scrub!("*") #=> "abc\u3042*" "abc\u3042\xE3\x80".scrub!{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042" @overload scrub! @return [String] @overload scrub!(repl) @return [String] @overload scrub! @yield [bytes] @return [String];T;0; @%;@F;Ao;B;CT;Di(;Ei(;!@;"I"static VALUE str_scrub_bang(int argc, VALUE *argv, VALUE str) { VALUE repl = argc ? (rb_check_arity(argc, 0, 1), argv[0]) : Qnil; VALUE new = rb_str_scrub(str, repl); if (!NIL_P(new)) rb_str_replace(str, new); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#freeze;F;[;[[@iH ;T;;f;0;[;{;IC;" ;T;[;[;@;0; @%;!@;"I"VALUE rb_str_freeze(VALUE str) { if (OBJ_FROZEN(str)) return str; rb_str_resize(str, RSTRING_LEN(str)); return rb_obj_freeze(str); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#+@;F;[;[[@iY ;T;:+@;0;[;{;IC;"|If the string is frozen, then return duplicated mutable string. If the string is not frozen, then return the string itself. ;T;[o;H ;II" overload;F;J0;;(;K0;#I" +str;T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[; @%;[;I"If the string is frozen, then return duplicated mutable string. If the string is not frozen, then return the string itself. @overload +str;T;0; @%;@F;Ao;B;CT;DiQ ;EiV ;!@;"I"}static VALUE str_uplus(VALUE str) { if (OBJ_FROZEN(str)) { return rb_str_dup(str); } else { return str; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#-@;F;[;[[@im ;T;:-@;0;[;{;IC;"Returns a frozen, possibly pre-existing copy of the string. The string will be deduplicated as long as it is not tainted, or has any instance variables set on it. ;T;[o;H ;II" overload;F;J0;:-;K0;#I" -str;T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[; @%;[;I"Returns a frozen, possibly pre-existing copy of the string. The string will be deduplicated as long as it is not tainted, or has any instance variables set on it. @overload -str;T;0; @%;@F;Ao;B;CT;Did ;Eij ;!@;"I"Gstatic VALUE str_uminus(VALUE str) { return rb_fstring(str); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#to_i;F;[[@0;[[@i;T;: to_i;0;[;{;IC;"Returns the result of interpreting leading characters in str as an integer base base (between 2 and 36). Extraneous characters past the end of a valid number are ignored. If there is not a valid number at the start of str, 0 is returned. This method never raises an exception when base is valid. "12345".to_i #=> 12345 "99 red balloons".to_i #=> 99 "0a".to_i #=> 0 "0a".to_i(16) #=> 10 "hello".to_i #=> 0 "1100101".to_i(2) #=> 101 "1100101".to_i(8) #=> 294977 "1100101".to_i(10) #=> 1100101 "1100101".to_i(16) #=> 17826049 ;T;[o;H ;II" overload;F;J0;;=;K0;#I"to_i(base=10);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @%;[;I"@return [Integer];T;0; @%;@F;Mi;N0;[[I" base;TI"10;T; @%;[;I"Returns the result of interpreting leading characters in str as an integer base base (between 2 and 36). Extraneous characters past the end of a valid number are ignored. If there is not a valid number at the start of str, 0 is returned. This method never raises an exception when base is valid. "12345".to_i #=> 12345 "99 red balloons".to_i #=> 99 "0a".to_i #=> 0 "0a".to_i(16) #=> 10 "hello".to_i #=> 0 "1100101".to_i(2) #=> 101 "1100101".to_i(8) #=> 294977 "1100101".to_i(10) #=> 1100101 "1100101".to_i(16) #=> 17826049 @overload to_i(base=10) @return [Integer];T;0; @%;@F;Ao;B;CT;Dit;Ei;!@;"I"static VALUE rb_str_to_i(int argc, VALUE *argv, VALUE str) { int base = 10; if (rb_check_arity(argc, 0, 1) && (base = NUM2INT(argv[0])) < 0) { rb_raise(rb_eArgError, "invalid radix %d", base); } return rb_str_to_inum(str, base, FALSE); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#to_f;F;[;[[@i;T;: to_f;0;[;{;IC;"Returns the result of interpreting leading characters in str as a floating point number. Extraneous characters past the end of a valid number are ignored. If there is not a valid number at the start of str, 0.0 is returned. This method never raises an exception. "123.45e1".to_f #=> 1234.5 "45.67 degrees".to_f #=> 45.67 "thx1138".to_f #=> 0.0 ;T;[o;H ;II" overload;F;J0;;>;K0;#I" to_f;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @&;[;I"@return [Float];T;0; @&;@F;Mi;N0;[; @&;[;I"Returns the result of interpreting leading characters in str as a floating point number. Extraneous characters past the end of a valid number are ignored. If there is not a valid number at the start of str, 0.0 is returned. This method never raises an exception. "123.45e1".to_f #=> 1234.5 "45.67 degrees".to_f #=> 45.67 "thx1138".to_f #=> 0.0 @overload to_f @return [Float];T;0; @&;@F;Ao;B;CT;Di;Ei;!@;"I"[static VALUE rb_str_to_f(VALUE str) { return DBL2NUM(rb_str_to_dbl(str, FALSE)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#to_s;F;[;[[@i;T;;h;0;[;{;IC;"bReturns +self+. If called on a subclass of String, converts the receiver to a String object. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @5&;[;I"@return [String];T;0; @5&;@F;Mi;N0;[; @5&o;H ;II" overload;F;J0;: to_str;K0;#I" to_str;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @5&;[;I"@return [String];T;0; @5&;@F;Mi;N0;[; @5&;[;I"Returns +self+. If called on a subclass of String, converts the receiver to a String object. @overload to_s @return [String] @overload to_str @return [String];T;0; @5&;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_to_s(VALUE str) { if (rb_obj_class(str) != rb_cString) { return str_duplicate(rb_cString, str); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#to_str;F;[;[[@i;T;;?;0;[;{;IC;"bReturns +self+. If called on a subclass of String, converts the receiver to a String object. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @]&;[;I"@return [String];T;0; @]&;@F;Mi;N0;[; @]&o;H ;II" overload;F;J0;;?;K0;#I" to_str;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @]&;[;I"@return [String];T;0; @]&;@F;Mi;N0;[; @]&;[;@Y&;0; @]&;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_to_s(VALUE str) { if (rb_obj_class(str) != rb_cString) { return str_duplicate(rb_cString, str); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#inspect;F;[;[[@i8;T;;i;0;[;{;IC;"Returns a printable version of _str_, surrounded by quote marks, with special characters escaped. str = "hello" str[3] = "\b" str.inspect #=> "\"hel\\bo\"" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[; @&;[;I"Returns a printable version of _str_, surrounded by quote marks, with special characters escaped. str = "hello" str[3] = "\b" str.inspect #=> "\"hel\\bo\"" @overload inspect @return [String];T;0; @&;@F;Ao;B;CT;Di,;Ei5;!@;"I" VALUE rb_str_inspect(VALUE str) { int encidx = ENCODING_GET(str); rb_encoding *enc = rb_enc_from_index(encidx), *actenc; const char *p, *pend, *prev; char buf[CHAR_ESC_LEN + 1]; VALUE result = rb_str_buf_new(0); rb_encoding *resenc = rb_default_internal_encoding(); int unicode_p = rb_enc_unicode_p(enc); int asciicompat = rb_enc_asciicompat(enc); if (resenc == NULL) resenc = rb_default_external_encoding(); if (!rb_enc_asciicompat(resenc)) resenc = rb_usascii_encoding(); rb_enc_associate(result, resenc); str_buf_cat2(result, "\""); p = RSTRING_PTR(str); pend = RSTRING_END(str); prev = p; actenc = get_actual_encoding(encidx, str); if (actenc != enc) { enc = actenc; if (unicode_p) unicode_p = rb_enc_unicode_p(enc); } while (p < pend) { unsigned int c, cc; int n; n = rb_enc_precise_mbclen(p, pend, enc); if (!MBCLEN_CHARFOUND_P(n)) { if (p > prev) str_buf_cat(result, prev, p - prev); n = rb_enc_mbminlen(enc); if (pend < p + n) n = (int)(pend - p); while (n--) { snprintf(buf, CHAR_ESC_LEN, "\\x%02X", *p & 0377); str_buf_cat(result, buf, strlen(buf)); prev = ++p; } continue; } n = MBCLEN_CHARFOUND_LEN(n); c = rb_enc_mbc_to_codepoint(p, pend, enc); p += n; if ((asciicompat || unicode_p) && (c == '"'|| c == '\\' || (c == '#' && p < pend && MBCLEN_CHARFOUND_P(rb_enc_precise_mbclen(p,pend,enc)) && (cc = rb_enc_codepoint(p,pend,enc), (cc == '$' || cc == '@' || cc == '{'))))) { if (p - n > prev) str_buf_cat(result, prev, p - n - prev); str_buf_cat2(result, "\\"); if (asciicompat || enc == resenc) { prev = p - n; continue; } } switch (c) { case '\n': cc = 'n'; break; case '\r': cc = 'r'; break; case '\t': cc = 't'; break; case '\f': cc = 'f'; break; case '\013': cc = 'v'; break; case '\010': cc = 'b'; break; case '\007': cc = 'a'; break; case 033: cc = 'e'; break; default: cc = 0; break; } if (cc) { if (p - n > prev) str_buf_cat(result, prev, p - n - prev); buf[0] = '\\'; buf[1] = (char)cc; str_buf_cat(result, buf, 2); prev = p; continue; } if ((enc == resenc && rb_enc_isprint(c, enc)) || (asciicompat && rb_enc_isascii(c, enc) && ISPRINT(c))) { continue; } else { if (p - n > prev) str_buf_cat(result, prev, p - n - prev); rb_str_buf_cat_escaped_char(result, c, unicode_p); prev = p; continue; } } if (p > prev) str_buf_cat(result, prev, p - prev); str_buf_cat2(result, "\""); OBJ_INFECT_RAW(result, str); return result; };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#dump;F;[;[[@i;T;: dump;0;[;{;IC;"Produces a version of +str+ with all non-printing characters replaced by \nnn notation and all special characters escaped. "hello \n ''".dump #=> "\"hello \\n ''\"" ;T;[o;H ;II" overload;F;J0;;@;K0;#I" dump;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[; @&;[;I"Produces a version of +str+ with all non-printing characters replaced by \nnn notation and all special characters escaped. "hello \n ''".dump #=> "\"hello \\n ''\"" @overload dump @return [String];T;0; @&;@F;Ao;B;CT;Di;Ei;!@;"I"R VALUE rb_str_dump(VALUE str) { int encidx = rb_enc_get_index(str); rb_encoding *enc = rb_enc_from_index(encidx); long len; const char *p, *pend; char *q, *qend; VALUE result; int u8 = (encidx == rb_utf8_encindex()); static const char nonascii_suffix[] = ".dup.force_encoding(\"%s\")"; len = 2; /* "" */ if (!rb_enc_asciicompat(enc)) { len += strlen(nonascii_suffix) - rb_strlen_lit("%s"); len += strlen(enc->name); } p = RSTRING_PTR(str); pend = p + RSTRING_LEN(str); while (p < pend) { int clen; unsigned char c = *p++; switch (c) { case '"': case '\\': case '\n': case '\r': case '\t': case '\f': case '\013': case '\010': case '\007': case '\033': clen = 2; break; case '#': clen = IS_EVSTR(p, pend) ? 2 : 1; break; default: if (ISPRINT(c)) { clen = 1; } else { if (u8 && c > 0x7F) { /* \u notation */ int n = rb_enc_precise_mbclen(p-1, pend, enc); if (MBCLEN_CHARFOUND_P(n)) { unsigned int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc); if (cc <= 0xFFFF) clen = 6; /* \uXXXX */ else if (cc <= 0xFFFFF) clen = 9; /* \u{XXXXX} */ else clen = 10; /* \u{XXXXXX} */ p += MBCLEN_CHARFOUND_LEN(n)-1; break; } } clen = 4; /* \xNN */ } break; } if (clen > LONG_MAX - len) { rb_raise(rb_eRuntimeError, "string size too big"); } len += clen; } result = rb_str_new_with_class(str, 0, len); p = RSTRING_PTR(str); pend = p + RSTRING_LEN(str); q = RSTRING_PTR(result); qend = q + len + 1; *q++ = '"'; while (p < pend) { unsigned char c = *p++; if (c == '"' || c == '\\') { *q++ = '\\'; *q++ = c; } else if (c == '#') { if (IS_EVSTR(p, pend)) *q++ = '\\'; *q++ = '#'; } else if (c == '\n') { *q++ = '\\'; *q++ = 'n'; } else if (c == '\r') { *q++ = '\\'; *q++ = 'r'; } else if (c == '\t') { *q++ = '\\'; *q++ = 't'; } else if (c == '\f') { *q++ = '\\'; *q++ = 'f'; } else if (c == '\013') { *q++ = '\\'; *q++ = 'v'; } else if (c == '\010') { *q++ = '\\'; *q++ = 'b'; } else if (c == '\007') { *q++ = '\\'; *q++ = 'a'; } else if (c == '\033') { *q++ = '\\'; *q++ = 'e'; } else if (ISPRINT(c)) { *q++ = c; } else { *q++ = '\\'; if (u8) { int n = rb_enc_precise_mbclen(p-1, pend, enc) - 1; if (MBCLEN_CHARFOUND_P(n)) { int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc); p += n; if (cc <= 0xFFFF) snprintf(q, qend-q, "u%04X", cc); /* \uXXXX */ else snprintf(q, qend-q, "u{%X}", cc); /* \u{XXXXX} or \u{XXXXXX} */ q += strlen(q); continue; } } snprintf(q, qend-q, "x%02X", c); q += 3; } } *q++ = '"'; *q = '\0'; if (!rb_enc_asciicompat(enc)) { snprintf(q, qend-q, nonascii_suffix, enc->name); encidx = rb_ascii8bit_encindex(); } OBJ_INFECT_RAW(result, str); /* result from dump is ASCII */ rb_enc_associate_index(result, encidx); ENC_CODERANGE_SET(result, ENC_CODERANGE_7BIT); return result; };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#undump;F;[;[[@i;T;: undump;0;[;{;IC;"Produces unescaped version of +str+. See also String#dump because String#undump does inverse of String#dump. "\"hello \\n ''\"".undump #=> "hello \n ''" ;T;[o;H ;II" overload;F;J0;;A;K0;#I" undump;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[; @&;[;I"Produces unescaped version of +str+. See also String#dump because String#undump does inverse of String#dump. "\"hello \\n ''\"".undump #=> "hello \n ''" @overload undump @return [String];T;0; @&;@F;Ao;B;CT;Di;Ei;!@;"I"J static VALUE str_undump(VALUE str) { const char *s = RSTRING_PTR(str); const char *s_end = RSTRING_END(str); rb_encoding *enc = rb_enc_get(str); VALUE undumped = rb_enc_str_new(s, 0L, enc); bool utf8 = false; bool binary = false; int w; rb_must_asciicompat(str); if (rb_str_is_ascii_only_p(str) == Qfalse) { rb_raise(rb_eRuntimeError, "non-ASCII character detected"); } if (!str_null_check(str, &w)) { rb_raise(rb_eRuntimeError, "string contains null byte"); } if (RSTRING_LEN(str) < 2) goto invalid_format; if (*s != '"') goto invalid_format; /* strip '"' at the start */ s++; for (;;) { if (s >= s_end) { rb_raise(rb_eRuntimeError, "unterminated dumped string"); } if (*s == '"') { /* epilogue */ s++; if (s == s_end) { /* ascii compatible dumped string */ break; } else { static const char force_encoding_suffix[] = ".force_encoding(\""; /* "\")" */ static const char dup_suffix[] = ".dup"; const char *encname; int encidx; ptrdiff_t size; /* check separately for strings dumped by older versions */ size = sizeof(dup_suffix) - 1; if (s_end - s > size && memcmp(s, dup_suffix, size) == 0) s += size; size = sizeof(force_encoding_suffix) - 1; if (s_end - s <= size) goto invalid_format; if (memcmp(s, force_encoding_suffix, size) != 0) goto invalid_format; s += size; if (utf8) { rb_raise(rb_eRuntimeError, "dumped string contained Unicode escape but used force_encoding"); } encname = s; s = memchr(s, '"', s_end-s); size = s - encname; if (!s) goto invalid_format; if (s_end - s != 2) goto invalid_format; if (s[0] != '"' || s[1] != ')') goto invalid_format; encidx = rb_enc_find_index2(encname, (long)size); if (encidx < 0) { rb_raise(rb_eRuntimeError, "dumped string has unknown encoding name"); } rb_enc_associate_index(undumped, encidx); } break; } if (*s == '\\') { s++; if (s >= s_end) { rb_raise(rb_eRuntimeError, "invalid escape"); } undump_after_backslash(undumped, &s, s_end, &enc, &utf8, &binary); } else { rb_str_cat(undumped, s++, 1); } } OBJ_INFECT(undumped, str); return undumped; invalid_format: rb_raise(rb_eRuntimeError, "invalid dumped string; not wrapped with '\"' nor '\"...\".force_encoding(\"...\")' form"); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#upcase;F;[[@0;[[@i;T;;;0;[;{;IC;"Returns a copy of str with all lowercase letters replaced with their uppercase counterparts. See String#downcase for meaning of +options+ and use with different encodings. "hEllO".upcase #=> "HELLO" ;T;[o;H ;II" overload;F;J0;;;K0;#I" upcase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[; @&o;H ;II" overload;F;J0;;;K0;#I"upcase([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[[I"[options];T0; @&;[;I")Returns a copy of str with all lowercase letters replaced with their uppercase counterparts. See String#downcase for meaning of +options+ and use with different encodings. "hEllO".upcase #=> "HELLO" @overload upcase @return [String] @overload upcase([options]) @return [String];T;0; @&;@F;Ao;B;CT;Di;Ei ;!@;"I"static VALUE rb_str_upcase(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); rb_str_upcase_bang(argc, argv, str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#downcase;F;[[@0;[[@iv;T;;;0;[;{;IC;"Returns a copy of str with all uppercase letters replaced with their lowercase counterparts. Which letters exactly are replaced, and by which other letters, depends on the presence or absence of options, and on the +encoding+ of the string. The meaning of the +options+ is as follows: No option :: Full Unicode case mapping, suitable for most languages (see :turkic and :lithuanian options below for exceptions). Context-dependent case mapping as described in Table 3-14 of the Unicode standard is currently not supported. :ascii :: Only the ASCII region, i.e. the characters ``A'' to ``Z'' and ``a'' to ``z'', are affected. This option cannot be combined with any other option. :turkic :: Full Unicode case mapping, adapted for Turkic languages (Turkish, Azerbaijani, ...). This means that upper case I is mapped to lower case dotless i, and so on. :lithuanian :: Currently, just full Unicode case mapping. In the future, full Unicode case mapping adapted for Lithuanian (keeping the dot on the lower case i even if there is an accent on top). :fold :: Only available on +downcase+ and +downcase!+. Unicode case folding, which is more far-reaching than Unicode case mapping. This option currently cannot be combined with any other option (i.e. there is currently no variant for turkic languages). Please note that several assumptions that are valid for ASCII-only case conversions do not hold for more general case conversions. For example, the length of the result may not be the same as the length of the input (neither in characters nor in bytes), some roundtrip assumptions (e.g. str.downcase == str.upcase.downcase) may not apply, and Unicode normalization (i.e. String#unicode_normalize) is not necessarily maintained by case mapping operations. Non-ASCII case mapping/folding is currently supported for UTF-8, UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols. This support will be extended to other encodings. "hEllO".downcase #=> "hello" ;T;[o;H ;II" overload;F;J0;;;K0;#I" downcase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @';[;I"@return [String];T;0; @';@F;Mi;N0;[; @'o;H ;II" overload;F;J0;;;K0;#I"downcase([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @';[;I"@return [String];T;0; @';@F;Mi;N0;[[I"[options];T0; @';[;I"8Returns a copy of str with all uppercase letters replaced with their lowercase counterparts. Which letters exactly are replaced, and by which other letters, depends on the presence or absence of options, and on the +encoding+ of the string. The meaning of the +options+ is as follows: No option :: Full Unicode case mapping, suitable for most languages (see :turkic and :lithuanian options below for exceptions). Context-dependent case mapping as described in Table 3-14 of the Unicode standard is currently not supported. :ascii :: Only the ASCII region, i.e. the characters ``A'' to ``Z'' and ``a'' to ``z'', are affected. This option cannot be combined with any other option. :turkic :: Full Unicode case mapping, adapted for Turkic languages (Turkish, Azerbaijani, ...). This means that upper case I is mapped to lower case dotless i, and so on. :lithuanian :: Currently, just full Unicode case mapping. In the future, full Unicode case mapping adapted for Lithuanian (keeping the dot on the lower case i even if there is an accent on top). :fold :: Only available on +downcase+ and +downcase!+. Unicode case folding, which is more far-reaching than Unicode case mapping. This option currently cannot be combined with any other option (i.e. there is currently no variant for turkic languages). Please note that several assumptions that are valid for ASCII-only case conversions do not hold for more general case conversions. For example, the length of the result may not be the same as the length of the input (neither in characters nor in bytes), some roundtrip assumptions (e.g. str.downcase == str.upcase.downcase) may not apply, and Unicode normalization (i.e. String#unicode_normalize) is not necessarily maintained by case mapping operations. Non-ASCII case mapping/folding is currently supported for UTF-8, UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols. This support will be extended to other encodings. "hEllO".downcase #=> "hello" @overload downcase @return [String] @overload downcase([options]) @return [String];T;0; @';@F;Ao;B;CT;DiD;Eit;!@;"I"static VALUE rb_str_downcase(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); rb_str_downcase_bang(argc, argv, str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#capitalize;F;[[@0;[[@i;T;;;0;[;{;IC;"-Returns a copy of str with the first character converted to uppercase and the remainder to lowercase. See String#downcase for meaning of +options+ and use with different encodings. "hello".capitalize #=> "Hello" "HELLO".capitalize #=> "Hello" "123ABC".capitalize #=> "123abc" ;T;[o;H ;II" overload;F;J0;;;K0;#I"capitalize;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @+';[;I"@return [String];T;0; @+';@F;Mi;N0;[; @+'o;H ;II" overload;F;J0;;;K0;#I"capitalize([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @+';[;I"@return [String];T;0; @+';@F;Mi;N0;[[I"[options];T0; @+';[;I"Returns a copy of str with the first character converted to uppercase and the remainder to lowercase. See String#downcase for meaning of +options+ and use with different encodings. "hello".capitalize #=> "Hello" "HELLO".capitalize #=> "Hello" "123ABC".capitalize #=> "123abc" @overload capitalize @return [String] @overload capitalize([options]) @return [String];T;0; @+';@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_capitalize(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); rb_str_capitalize_bang(argc, argv, str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#swapcase;F;[[@0;[[@i;T;;;0;[;{;IC;"3Returns a copy of str with uppercase alphabetic characters converted to lowercase and lowercase characters converted to uppercase. See String#downcase for meaning of +options+ and use with different encodings. "Hello".swapcase #=> "hELLO" "cYbEr_PuNk11".swapcase #=> "CyBeR_pUnK11" ;T;[o;H ;II" overload;F;J0;;;K0;#I" swapcase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @V';[;I"@return [String];T;0; @V';@F;Mi;N0;[; @V'o;H ;II" overload;F;J0;;;K0;#I"swapcase([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @V';[;I"@return [String];T;0; @V';@F;Mi;N0;[[I"[options];T0; @V';[;I"Returns a copy of str with uppercase alphabetic characters converted to lowercase and lowercase characters converted to uppercase. See String#downcase for meaning of +options+ and use with different encodings. "Hello".swapcase #=> "hELLO" "cYbEr_PuNk11".swapcase #=> "CyBeR_pUnK11" @overload swapcase @return [String] @overload swapcase([options]) @return [String];T;0; @V';@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_swapcase(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); rb_str_swapcase_bang(argc, argv, str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#upcase!;F;[[@0;[[@i;T;: upcase!;0;[;{;IC;"Upcases the contents of str, returning nil if no changes were made. See String#downcase for meaning of +options+ and use with different encodings. ;T;[o;H ;II" overload;F;J0;;B;K0;#I" upcase!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @';[;I"@return [String, nil];T;0; @';@F;Mi;N0;[; @'o;H ;II" overload;F;J0;;B;K0;#I"upcase!([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @';[;I"@return [String, nil];T;0; @';@F;Mi;N0;[[I"[options];T0; @';[;I"Upcases the contents of str, returning nil if no changes were made. See String#downcase for meaning of +options+ and use with different encodings. @overload upcase! @return [String, nil] @overload upcase!([options]) @return [String, nil];T;0; @';@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_upcase_bang(int argc, VALUE *argv, VALUE str) { rb_encoding *enc; OnigCaseFoldType flags = ONIGENC_CASE_UPCASE; flags = check_case_options(argc, argv, flags); str_modify_keep_cr(str); enc = STR_ENC_GET(str); rb_str_check_dummy_enc(enc); if (((flags&ONIGENC_CASE_ASCII_ONLY) && (enc==rb_utf8_encoding() || rb_enc_mbmaxlen(enc)==1)) || (!(flags&ONIGENC_CASE_FOLD_TURKISH_AZERI) && ENC_CODERANGE(str)==ENC_CODERANGE_7BIT)) { char *s = RSTRING_PTR(str), *send = RSTRING_END(str); while (s < send) { unsigned int c = *(unsigned char*)s; if (rb_enc_isascii(c, enc) && 'a' <= c && c <= 'z') { *s = 'A' + (c - 'a'); flags |= ONIGENC_CASE_MODIFIED; } s++; } } else if (flags&ONIGENC_CASE_ASCII_ONLY) rb_str_ascii_casemap(str, &flags, enc); else str_shared_replace(str, rb_str_casemap(str, &flags, enc)); if (ONIGENC_CASE_MODIFIED&flags) return str; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#downcase!;F;[[@0;[[@i";T;:downcase!;0;[;{;IC;"Downcases the contents of str, returning nil if no changes were made. See String#downcase for meaning of +options+ and use with different encodings. ;T;[o;H ;II" overload;F;J0;;C;K0;#I"downcase!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @';[;I"@return [String, nil];T;0; @';@F;Mi;N0;[; @'o;H ;II" overload;F;J0;;C;K0;#I"downcase!([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @';[;I"@return [String, nil];T;0; @';@F;Mi;N0;[[I"[options];T0; @';[;I"Downcases the contents of str, returning nil if no changes were made. See String#downcase for meaning of +options+ and use with different encodings. @overload downcase! @return [String, nil] @overload downcase!([options]) @return [String, nil];T;0; @';@F;Ao;B;CT;Di;Ei ;!@;"I"static VALUE rb_str_downcase_bang(int argc, VALUE *argv, VALUE str) { rb_encoding *enc; OnigCaseFoldType flags = ONIGENC_CASE_DOWNCASE; flags = check_case_options(argc, argv, flags); str_modify_keep_cr(str); enc = STR_ENC_GET(str); rb_str_check_dummy_enc(enc); if (((flags&ONIGENC_CASE_ASCII_ONLY) && (enc==rb_utf8_encoding() || rb_enc_mbmaxlen(enc)==1)) || (!(flags&ONIGENC_CASE_FOLD_TURKISH_AZERI) && ENC_CODERANGE(str)==ENC_CODERANGE_7BIT)) { char *s = RSTRING_PTR(str), *send = RSTRING_END(str); while (s < send) { unsigned int c = *(unsigned char*)s; if (rb_enc_isascii(c, enc) && 'A' <= c && c <= 'Z') { *s = 'a' + (c - 'A'); flags |= ONIGENC_CASE_MODIFIED; } s++; } } else if (flags&ONIGENC_CASE_ASCII_ONLY) rb_str_ascii_casemap(str, &flags, enc); else str_shared_replace(str, rb_str_casemap(str, &flags, enc)); if (ONIGENC_CASE_MODIFIED&flags) return str; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#capitalize!;F;[[@0;[[@i;T;:capitalize!;0;[;{;IC;"Modifies str by converting the first character to uppercase and the remainder to lowercase. Returns nil if no changes are made. There is an exception for modern Georgian (mkhedruli/MTAVRULI), where the result is the same as for String#downcase, to avoid mixed case. See String#downcase for meaning of +options+ and use with different encodings. a = "hello" a.capitalize! #=> "Hello" a #=> "Hello" a.capitalize! #=> nil ;T;[o;H ;II" overload;F;J0;;D;K0;#I"capitalize!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @';[;I"@return [String, nil];T;0; @';@F;Mi;N0;[; @'o;H ;II" overload;F;J0;;D;K0;#I"capitalize!([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @';[;I"@return [String, nil];T;0; @';@F;Mi;N0;[[I"[options];T0; @';[;I"?Modifies str by converting the first character to uppercase and the remainder to lowercase. Returns nil if no changes are made. There is an exception for modern Georgian (mkhedruli/MTAVRULI), where the result is the same as for String#downcase, to avoid mixed case. See String#downcase for meaning of +options+ and use with different encodings. a = "hello" a.capitalize! #=> "Hello" a #=> "Hello" a.capitalize! #=> nil @overload capitalize! @return [String, nil] @overload capitalize!([options]) @return [String, nil];T;0; @';@F;Ao;B;CT;Di;Ei;!@;"I"Xstatic VALUE rb_str_capitalize_bang(int argc, VALUE *argv, VALUE str) { rb_encoding *enc; OnigCaseFoldType flags = ONIGENC_CASE_UPCASE | ONIGENC_CASE_TITLECASE; flags = check_case_options(argc, argv, flags); str_modify_keep_cr(str); enc = STR_ENC_GET(str); rb_str_check_dummy_enc(enc); if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil; if (flags&ONIGENC_CASE_ASCII_ONLY) rb_str_ascii_casemap(str, &flags, enc); else str_shared_replace(str, rb_str_casemap(str, &flags, enc)); if (ONIGENC_CASE_MODIFIED&flags) return str; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#swapcase!;F;[[@0;[[@i;T;:swapcase!;0;[;{;IC;"Equivalent to String#swapcase, but modifies the receiver in place, returning str, or nil if no changes were made. See String#downcase for meaning of +options+ and use with different encodings. ;T;[o;H ;II" overload;F;J0;;E;K0;#I"swapcase!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @(;[;I"@return [String, nil];T;0; @(;@F;Mi;N0;[; @(o;H ;II" overload;F;J0;;E;K0;#I"swapcase!([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @(;[;I"@return [String, nil];T;0; @(;@F;Mi;N0;[[I"[options];T0; @(;[;I"GEquivalent to String#swapcase, but modifies the receiver in place, returning str, or nil if no changes were made. See String#downcase for meaning of +options+ and use with different encodings. @overload swapcase! @return [String, nil] @overload swapcase!([options]) @return [String, nil];T;0; @(;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_swapcase_bang(int argc, VALUE *argv, VALUE str) { rb_encoding *enc; OnigCaseFoldType flags = ONIGENC_CASE_UPCASE | ONIGENC_CASE_DOWNCASE; flags = check_case_options(argc, argv, flags); str_modify_keep_cr(str); enc = STR_ENC_GET(str); rb_str_check_dummy_enc(enc); if (flags&ONIGENC_CASE_ASCII_ONLY) rb_str_ascii_casemap(str, &flags, enc); else str_shared_replace(str, rb_str_casemap(str, &flags, enc)); if (ONIGENC_CASE_MODIFIED&flags) return str; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#hex;F;[;[[@i8$;T;:hex;0;[;{;IC;"*Treats leading characters from str as a string of hexadecimal digits (with an optional sign and an optional 0x) and returns the corresponding number. Zero is returned on error. "0x0a".hex #=> 10 "-1234".hex #=> -4660 "0".hex #=> 0 "wombat".hex #=> 0 ;T;[o;H ;II" overload;F;J0;;F;K0;#I"hex;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @5(;[;I"@return [Integer];T;0; @5(;@F;Mi;N0;[; @5(;[;I"NTreats leading characters from str as a string of hexadecimal digits (with an optional sign and an optional 0x) and returns the corresponding number. Zero is returned on error. "0x0a".hex #=> 10 "-1234".hex #=> -4660 "0".hex #=> 0 "wombat".hex #=> 0 @overload hex @return [Integer];T;0; @5(;@F;Ao;B;CT;Di*$;Ei5$;!@;"I"Vstatic VALUE rb_str_hex(VALUE str) { return rb_str_to_inum(str, 16, FALSE); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#oct;F;[;[[@iP$;T;:oct;0;[;{;IC;"hTreats leading characters of str as a string of octal digits (with an optional sign) and returns the corresponding number. Returns 0 if the conversion fails. "123".oct #=> 83 "-377".oct #=> -255 "bad".oct #=> 0 "0377bad".oct #=> 255 If +str+ starts with 0, radix indicators are honored. See Kernel#Integer. ;T;[o;H ;II" overload;F;J0;;G;K0;#I"oct;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @P(;[;I"@return [Integer];T;0; @P(;@F;Mi;N0;[; @P(;[;I"Treats leading characters of str as a string of octal digits (with an optional sign) and returns the corresponding number. Returns 0 if the conversion fails. "123".oct #=> 83 "-377".oct #=> -255 "bad".oct #=> 0 "0377bad".oct #=> 255 If +str+ starts with 0, radix indicators are honored. See Kernel#Integer. @overload oct @return [Integer];T;0; @P(;@F;Ao;B;CT;Di?$;EiM$;!@;"I"Vstatic VALUE rb_str_oct(VALUE str) { return rb_str_to_inum(str, -8, FALSE); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#split;F;[[@0;[[@i~;T;: split;0;[;{;IC;" Divides str into substrings based on a delimiter, returning an array of these substrings. If pattern is a String, then its contents are used as the delimiter when splitting str. If pattern is a single space, str is split on whitespace, with leading and trailing whitespace and runs of contiguous whitespace characters ignored. If pattern is a Regexp, str is divided where the pattern matches. Whenever the pattern matches a zero-length string, str is split into individual characters. If pattern contains groups, the respective matches will be returned in the array as well. If pattern is nil, the value of $; is used. If $; is nil (which is the default), str is split on whitespace as if ' ' were specified. If the limit parameter is omitted, trailing null fields are suppressed. If limit is a positive number, at most that number of split substrings will be returned (captured groups will be returned as well, but are not counted towards the limit). If limit is 1, the entire string is returned as the only entry in an array. If negative, there is no limit to the number of fields returned, and trailing null fields are not suppressed. When the input +str+ is empty an empty Array is returned as the string is considered to have no fields to split. " now's the time ".split #=> ["now's", "the", "time"] " now's the time ".split(' ') #=> ["now's", "the", "time"] " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"] "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"] "hello".split(//) #=> ["h", "e", "l", "l", "o"] "hello".split(//, 3) #=> ["h", "e", "llo"] "hi mom".split(%r{\s*}) #=> ["h", "i", "m", "o", "m"] "mellow yellow".split("ello") #=> ["m", "w y", "w"] "1,2,,3,4,,".split(',') #=> ["1", "2", "", "3", "4"] "1,2,,3,4,,".split(',', 4) #=> ["1", "2", "", "3,4,,"] "1,2,,3,4,,".split(',', -4) #=> ["1", "2", "", "3", "4", "", ""] "1:2:3".split(/(:)()()/, 2) #=> ["1", ":", "", "", "2:3"] "".split(',', -1) #=> [] If a block is given, invoke the block with each split substring. ;T;[o;H ;II" overload;F;J0;;H;K0;#I" split(pattern=nil, [limit]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @k(;[;I"@return [Array];T;0; @k(;@F;Mi;N0;[[I" pattern;TI"nil;T[I" [limit];T0; @k(o;H ;II" overload;F;J0;;H;K0;#I" split(pattern=nil, [limit]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"sub;T; @k(o;L ;II" return;F;JI";T;0;K[I" String;T; @k(;[;I""@yield [sub] @return [String];T;0; @k(;@F;Mi;N0;[[I" pattern;TI"nil;T[I" [limit];T0; @k(;[;I" Divides str into substrings based on a delimiter, returning an array of these substrings. If pattern is a String, then its contents are used as the delimiter when splitting str. If pattern is a single space, str is split on whitespace, with leading and trailing whitespace and runs of contiguous whitespace characters ignored. If pattern is a Regexp, str is divided where the pattern matches. Whenever the pattern matches a zero-length string, str is split into individual characters. If pattern contains groups, the respective matches will be returned in the array as well. If pattern is nil, the value of $; is used. If $; is nil (which is the default), str is split on whitespace as if ' ' were specified. If the limit parameter is omitted, trailing null fields are suppressed. If limit is a positive number, at most that number of split substrings will be returned (captured groups will be returned as well, but are not counted towards the limit). If limit is 1, the entire string is returned as the only entry in an array. If negative, there is no limit to the number of fields returned, and trailing null fields are not suppressed. When the input +str+ is empty an empty Array is returned as the string is considered to have no fields to split. " now's the time ".split #=> ["now's", "the", "time"] " now's the time ".split(' ') #=> ["now's", "the", "time"] " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"] "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"] "hello".split(//) #=> ["h", "e", "l", "l", "o"] "hello".split(//, 3) #=> ["h", "e", "llo"] "hi mom".split(%r{\s*}) #=> ["h", "i", "m", "o", "m"] "mellow yellow".split("ello") #=> ["m", "w y", "w"] "1,2,,3,4,,".split(',') #=> ["1", "2", "", "3", "4"] "1,2,,3,4,,".split(',', 4) #=> ["1", "2", "", "3,4,,"] "1,2,,3,4,,".split(',', -4) #=> ["1", "2", "", "3", "4", "", ""] "1:2:3".split(/(:)()()/, 2) #=> ["1", ":", "", "", "2:3"] "".split(',', -1) #=> [] If a block is given, invoke the block with each split substring. @overload split(pattern=nil, [limit]) @return [Array] @overload split(pattern=nil, [limit]) @yield [sub] @return [String];T;0; @k(;@F;Ao;B;CT;DiG;Ei};!@;"I"2static VALUE rb_str_split_m(int argc, VALUE *argv, VALUE str) { rb_encoding *enc; VALUE spat; VALUE limit; enum {awk, string, regexp} split_type; long beg, end, i = 0, empty_count = -1; int lim = 0; VALUE result, tmp; result = rb_block_given_p() ? Qfalse : Qnil; if (rb_scan_args(argc, argv, "02", &spat, &limit) == 2) { lim = NUM2INT(limit); if (lim <= 0) limit = Qnil; else if (lim == 1) { if (RSTRING_LEN(str) == 0) return result ? rb_ary_new2(0) : str; tmp = rb_str_dup(str); if (!result) { rb_yield(tmp); return str; } return rb_ary_new3(1, tmp); } i = 1; } if (NIL_P(limit) && !lim) empty_count = 0; enc = STR_ENC_GET(str); split_type = regexp; if (!NIL_P(spat)) { spat = get_pat_quoted(spat, 0); } else if (NIL_P(spat = rb_fs)) { split_type = awk; } else if (!(spat = rb_fs_check(spat))) { rb_raise(rb_eTypeError, "value of $; must be String or Regexp"); } if (split_type != awk) { if (BUILTIN_TYPE(spat) == T_STRING) { rb_encoding *enc2 = STR_ENC_GET(spat); mustnot_broken(spat); split_type = string; if (RSTRING_LEN(spat) == 0) { /* Special case - split into chars */ spat = rb_reg_regcomp(spat); split_type = regexp; } else if (rb_enc_asciicompat(enc2) == 1) { if (RSTRING_LEN(spat) == 1 && RSTRING_PTR(spat)[0] == ' ') { split_type = awk; } } else { int l; if (rb_enc_ascget(RSTRING_PTR(spat), RSTRING_END(spat), &l, enc2) == ' ' && RSTRING_LEN(spat) == l) { split_type = awk; } } } } #define SPLIT_STR(beg, len) (empty_count = split_string(result, str, beg, len, empty_count)) if (result) result = rb_ary_new(); beg = 0; if (split_type == awk) { char *ptr = RSTRING_PTR(str); char *eptr = RSTRING_END(str); char *bptr = ptr; int skip = 1; unsigned int c; end = beg; if (is_ascii_string(str)) { while (ptr < eptr) { c = (unsigned char)*ptr++; if (skip) { if (ascii_isspace(c)) { beg = ptr - bptr; } else { end = ptr - bptr; skip = 0; if (!NIL_P(limit) && lim <= i) break; } } else if (ascii_isspace(c)) { SPLIT_STR(beg, end-beg); skip = 1; beg = ptr - bptr; if (!NIL_P(limit)) ++i; } else { end = ptr - bptr; } } } else { while (ptr < eptr) { int n; c = rb_enc_codepoint_len(ptr, eptr, &n, enc); ptr += n; if (skip) { if (rb_isspace(c)) { beg = ptr - bptr; } else { end = ptr - bptr; skip = 0; if (!NIL_P(limit) && lim <= i) break; } } else if (rb_isspace(c)) { SPLIT_STR(beg, end-beg); skip = 1; beg = ptr - bptr; if (!NIL_P(limit)) ++i; } else { end = ptr - bptr; } } } } else if (split_type == string) { char *ptr = RSTRING_PTR(str); char *str_start = ptr; char *substr_start = ptr; char *eptr = RSTRING_END(str); char *sptr = RSTRING_PTR(spat); long slen = RSTRING_LEN(spat); mustnot_broken(str); enc = rb_enc_check(str, spat); while (ptr < eptr && (end = rb_memsearch(sptr, slen, ptr, eptr - ptr, enc)) >= 0) { /* Check we are at the start of a char */ char *t = rb_enc_right_char_head(ptr, ptr + end, eptr, enc); if (t != ptr + end) { ptr = t; continue; } SPLIT_STR(substr_start - str_start, (ptr+end) - substr_start); ptr += end + slen; substr_start = ptr; if (!NIL_P(limit) && lim <= ++i) break; } beg = ptr - str_start; } else { char *ptr = RSTRING_PTR(str); long len = RSTRING_LEN(str); long start = beg; long idx; int last_null = 0; struct re_registers *regs; VALUE match = 0; for (; (end = rb_reg_search(spat, str, start, 0)) >= 0; (match ? (rb_match_unbusy(match), rb_backref_set(match)) : (void)0)) { match = rb_backref_get(); if (!result) rb_match_busy(match); regs = RMATCH_REGS(match); if (start == end && BEG(0) == END(0)) { if (!ptr) { SPLIT_STR(0, 0); break; } else if (last_null == 1) { SPLIT_STR(beg, rb_enc_fast_mbclen(ptr+beg, ptr+len, enc)); beg = start; } else { if (start == len) start++; else start += rb_enc_fast_mbclen(ptr+start,ptr+len,enc); last_null = 1; continue; } } else { SPLIT_STR(beg, end-beg); beg = start = END(0); } last_null = 0; for (idx=1; idx < regs->num_regs; idx++) { if (BEG(idx) == -1) continue; SPLIT_STR(BEG(idx), END(idx)-BEG(idx)); } if (!NIL_P(limit) && lim <= ++i) break; } if (match) rb_match_unbusy(match); } if (RSTRING_LEN(str) > 0 && (!NIL_P(limit) || RSTRING_LEN(str) > beg || lim < 0)) { SPLIT_STR(beg, RSTRING_LEN(str)-beg); } return result ? result : str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#lines;F;[[@0;[[@iJ ;T;: lines;0;[;{;IC;"Returns an array of lines in str split using the supplied record separator ($/ by default). This is a shorthand for str.each_line(separator, getline_args).to_a. See IO.readlines for details about getline_args. "hello\nworld\n".lines #=> ["hello\n", "world\n"] "hello world".lines(' ') #=> ["hello ", " ", "world"] "hello\nworld\n".lines(chomp: true) #=> ["hello", "world"] If a block is given, which is a deprecated form, works the same as each_line. ;T;[o;H ;II" overload;F;J0;;I;K0;#I")lines(separator=$/ [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @(;[;I"@return [Array];T;0; @(;@F;Mi;N0;[[I"separator;TI"$/[, getline_args];T; @(;[;I"XReturns an array of lines in str split using the supplied record separator ($/ by default). This is a shorthand for str.each_line(separator, getline_args).to_a. See IO.readlines for details about getline_args. "hello\nworld\n".lines #=> ["hello\n", "world\n"] "hello world".lines(' ') #=> ["hello ", " ", "world"] "hello\nworld\n".lines(chomp: true) #=> ["hello", "world"] If a block is given, which is a deprecated form, works the same as each_line. @overload lines(separator=$/ [, getline_args]) @return [Array];T;0; @(;@F;Ao;B;CT;Di8 ;EiG ;!@;"I"static VALUE rb_str_lines(int argc, VALUE *argv, VALUE str) { VALUE ary = WANTARRAY("lines", 0); return rb_str_enumerate_lines(argc, argv, str, ary); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#bytes;F;[;[[@i ;T;: bytes;0;[;{;IC;"Returns an array of bytes in str. This is a shorthand for str.each_byte.to_a. If a block is given, which is a deprecated form, works the same as each_byte. ;T;[o;H ;II" overload;F;J0;;J;K0;#I" bytes;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @(;[;I"@return [Array];T;0; @(;@F;Mi;N0;[; @(;[;I"Returns an array of bytes in str. This is a shorthand for str.each_byte.to_a. If a block is given, which is a deprecated form, works the same as each_byte. @overload bytes @return [Array];T;0; @(;@F;Ao;B;CT;Di{ ;Ei ;!@;"I"static VALUE rb_str_bytes(VALUE str) { VALUE ary = WANTARRAY("bytes", RSTRING_LEN(str)); return rb_str_enumerate_bytes(str, ary); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#chars;F;[;[[@i ;T;: chars;0;[;{;IC;"Returns an array of characters in str. This is a shorthand for str.each_char.to_a. If a block is given, which is a deprecated form, works the same as each_char. ;T;[o;H ;II" overload;F;J0;;K;K0;#I" chars;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @(;[;I"@return [Array];T;0; @(;@F;Mi;N0;[; @(;[;I"Returns an array of characters in str. This is a shorthand for str.each_char.to_a. If a block is given, which is a deprecated form, works the same as each_char. @overload chars @return [Array];T;0; @(;@F;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE rb_str_chars(VALUE str) { VALUE ary = WANTARRAY("chars", rb_str_strlen(str)); return rb_str_enumerate_chars(str, ary); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#codepoints;F;[;[[@i!;T;:codepoints;0;[;{;IC;"Returns an array of the Integer ordinals of the characters in str. This is a shorthand for str.each_codepoint.to_a. If a block is given, which is a deprecated form, works the same as each_codepoint. ;T;[o;H ;II" overload;F;J0;;L;K0;#I"codepoints;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @(;[;I"@return [Array];T;0; @(;@F;Mi;N0;[; @(;[;I"Returns an array of the Integer ordinals of the characters in str. This is a shorthand for str.each_codepoint.to_a. If a block is given, which is a deprecated form, works the same as each_codepoint. @overload codepoints @return [Array];T;0; @(;@F;Ao;B;CT;Di!;Ei!;!@;"I"static VALUE rb_str_codepoints(VALUE str) { VALUE ary = WANTARRAY("codepoints", rb_str_strlen(str)); return rb_str_enumerate_codepoints(str, ary); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#grapheme_clusters;F;[;[[@i!;T;:grapheme_clusters;0;[;{;IC;"Returns an array of grapheme clusters in str. This is a shorthand for str.each_grapheme_cluster.to_a. If a block is given, which is a deprecated form, works the same as each_grapheme_cluster. ;T;[o;H ;II" overload;F;J0;;M;K0;#I"grapheme_clusters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @);[;I"@return [Array];T;0; @);@F;Mi;N0;[; @);[;I"Returns an array of grapheme clusters in str. This is a shorthand for str.each_grapheme_cluster.to_a. If a block is given, which is a deprecated form, works the same as each_grapheme_cluster. @overload grapheme_clusters @return [Array];T;0; @);@F;Ao;B;CT;Di!;Ei!;!@;"I"static VALUE rb_str_grapheme_clusters(VALUE str) { VALUE ary = WANTARRAY("grapheme_clusters", rb_str_strlen(str)); return rb_str_enumerate_grapheme_clusters(str, ary); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#reverse;F;[;[[@i;T;: reverse;0;[;{;IC;"wReturns a new string with the characters from str in reverse order. "stressed".reverse #=> "desserts" ;T;[o;H ;II" overload;F;J0;;N;K0;#I" reverse;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @.);[;I"@return [String];T;0; @.);@F;Mi;N0;[; @.);[;I"Returns a new string with the characters from str in reverse order. "stressed".reverse #=> "desserts" @overload reverse @return [String];T;0; @.);@F;Ao;B;CT;Di;Ei;!@;"I" static VALUE rb_str_reverse(VALUE str) { rb_encoding *enc; VALUE rev; char *s, *e, *p; int cr; if (RSTRING_LEN(str) <= 1) return rb_str_dup(str); enc = STR_ENC_GET(str); rev = rb_str_new_with_class(str, 0, RSTRING_LEN(str)); s = RSTRING_PTR(str); e = RSTRING_END(str); p = RSTRING_END(rev); cr = ENC_CODERANGE(str); if (RSTRING_LEN(str) > 1) { if (single_byte_optimizable(str)) { while (s < e) { *--p = *s++; } } else if (cr == ENC_CODERANGE_VALID) { while (s < e) { int clen = rb_enc_fast_mbclen(s, e, enc); p -= clen; memcpy(p, s, clen); s += clen; } } else { cr = rb_enc_asciicompat(enc) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID; while (s < e) { int clen = rb_enc_mbclen(s, e, enc); if (clen > 1 || (*s & 0x80)) cr = ENC_CODERANGE_UNKNOWN; p -= clen; memcpy(p, s, clen); s += clen; } } } STR_SET_LEN(rev, RSTRING_LEN(str)); OBJ_INFECT_RAW(rev, str); str_enc_copy(rev, str); ENC_CODERANGE_SET(rev, cr); return rev; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#reverse!;F;[;[[@i@;T;: reverse!;0;[;{;IC;""Reverses str in place. ;T;[o;H ;II" overload;F;J0;;O;K0;#I" reverse!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I);[;I"@return [String];T;0; @I);@F;Mi;N0;[; @I);[;I"JReverses str in place. @overload reverse! @return [String];T;0; @I);@F;Ao;B;CT;Di9;Ei=;!@;"I"static VALUE rb_str_reverse_bang(VALUE str) { if (RSTRING_LEN(str) > 1) { if (single_byte_optimizable(str)) { char *s, *e, c; str_modify_keep_cr(str); s = RSTRING_PTR(str); e = RSTRING_END(str) - 1; while (s < e) { c = *s; *s++ = *e; *e-- = c; } } else { str_shared_replace(str, rb_str_reverse(str)); } } else { str_modify_keep_cr(str); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#concat;F;[[@0;[[@i ;T;: concat;0;[;{;IC;"Concatenates the given object(s) to str. If an object is an Integer, it is considered a codepoint and converted to a character before concatenation. +concat+ can take multiple arguments, and all the arguments are concatenated in order. a = "hello " a.concat("world", 33) #=> "hello world!" a #=> "hello world!" b = "sn" b.concat("_", b, "_", b) #=> "sn_sn_sn" See also String#<<, which takes a single argument. ;T;[o;H ;II" overload;F;J0;;P;K0;#I"concat(obj1, obj2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @d);[;I"@return [String];T;0; @d);@F;Mi;N0;[[I" obj1;T0[I" obj2;T0[I"...;T0; @d);[;I"Concatenates the given object(s) to str. If an object is an Integer, it is considered a codepoint and converted to a character before concatenation. +concat+ can take multiple arguments, and all the arguments are concatenated in order. a = "hello " a.concat("world", 33) #=> "hello world!" a #=> "hello world!" b = "sn" b.concat("_", b, "_", b) #=> "sn_sn_sn" See also String#<<, which takes a single argument. @overload concat(obj1, obj2, ...) @return [String];T;0; @d);@F;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE rb_str_concat_multi(int argc, VALUE *argv, VALUE str) { str_modifiable(str); if (argc == 1) { return rb_str_concat(str, argv[0]); } else if (argc > 1) { int i; VALUE arg_str = rb_str_tmp_new(0); rb_enc_copy(arg_str, str); for (i = 0; i < argc; i++) { rb_str_concat(arg_str, argv[i]); } rb_str_buf_append(str, arg_str); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#<<;F;[[I" str2;T0;[[@i ;T;:<<;0;[;{;IC;"5Appends the given object to str. If the object is an Integer, it is considered a codepoint and converted to a character before being appended. a = "hello " a << "world" #=> "hello world" a << 33 #=> "hello world!" See also String#concat, which takes multiple arguments. ;T;[o;H ;II" overload;F;J0;;Q;K0;#I" <<(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @);[;I"@return [String];T;0; @);@F;Mi;N0;[[I"obj;T0; @)o;H ;II" overload;F;J0;;Q;K0;#I"<<(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @);[;I"@return [String];T;0; @);@F;Mi;N0;[[I" integer;T0; @);[;I"Appends the given object to str. If the object is an Integer, it is considered a codepoint and converted to a character before being appended. a = "hello " a << "world" #=> "hello world" a << 33 #=> "hello world!" See also String#concat, which takes multiple arguments. @overload <<(obj) @return [String] @overload <<(integer) @return [String];T;0; @);@F;Ao;B;CT;Di ;Ei ;!@;"I"VALUE rb_str_concat(VALUE str1, VALUE str2) { unsigned int code; rb_encoding *enc = STR_ENC_GET(str1); int encidx; if (RB_INTEGER_TYPE_P(str2)) { if (rb_num_to_uint(str2, &code) == 0) { } else if (FIXNUM_P(str2)) { rb_raise(rb_eRangeError, "%ld out of char range", FIX2LONG(str2)); } else { rb_raise(rb_eRangeError, "bignum out of char range"); } } else { return rb_str_append(str1, str2); } encidx = rb_enc_to_index(enc); if (encidx == ENCINDEX_ASCII || encidx == ENCINDEX_US_ASCII) { /* US-ASCII automatically extended to ASCII-8BIT */ char buf[1]; buf[0] = (char)code; if (code > 0xFF) { rb_raise(rb_eRangeError, "%u out of char range", code); } rb_str_cat(str1, buf, 1); if (encidx == ENCINDEX_US_ASCII && code > 127) { rb_enc_associate_index(str1, ENCINDEX_ASCII); ENC_CODERANGE_SET(str1, ENC_CODERANGE_VALID); } } else { long pos = RSTRING_LEN(str1); int cr = ENC_CODERANGE(str1); int len; char *buf; switch (len = rb_enc_codelen(code, enc)) { case ONIGERR_INVALID_CODE_POINT_VALUE: rb_raise(rb_eRangeError, "invalid codepoint 0x%X in %s", code, rb_enc_name(enc)); break; case ONIGERR_TOO_BIG_WIDE_CHAR_VALUE: case 0: rb_raise(rb_eRangeError, "%u out of char range", code); break; } buf = ALLOCA_N(char, len + 1); rb_enc_mbcput(code, buf, enc); if (rb_enc_precise_mbclen(buf, buf + len + 1, enc) != len) { rb_raise(rb_eRangeError, "invalid codepoint 0x%X in %s", code, rb_enc_name(enc)); } rb_str_resize(str1, pos+len); memcpy(RSTRING_PTR(str1) + pos, buf, len); if (cr == ENC_CODERANGE_7BIT && code > 127) cr = ENC_CODERANGE_VALID; ENC_CODERANGE_SET(str1, cr); } return str1; };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#prepend;F;[[@0;[[@iU ;T;: prepend;0;[;{;IC;"Prepend---Prepend the given strings to str. a = "!" a.prepend("hello ", "world") #=> "hello world!" a #=> "hello world!" See also String#concat. ;T;[o;H ;II" overload;F;J0;;R;K0;#I")prepend(other_str1, other_str2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @);[;I"@return [String];T;0; @);@F;Mi;N0;[[I"other_str1;T0[I"other_str2;T0[I"...;T0; @);[;I"Prepend---Prepend the given strings to str. a = "!" a.prepend("hello ", "world") #=> "hello world!" a #=> "hello world!" See also String#concat. @overload prepend(other_str1, other_str2, ...) @return [String];T;0; @);@F;Ao;B;CT;DiH ;EiR ;!@;"I"static VALUE rb_str_prepend_multi(int argc, VALUE *argv, VALUE str) { str_modifiable(str); if (argc == 1) { rb_str_update(str, 0L, 0L, argv[0]); } else if (argc > 1) { int i; VALUE arg_str = rb_str_tmp_new(0); rb_enc_copy(arg_str, str); for (i = 0; i < argc; i++) { rb_str_append(arg_str, argv[i]); } rb_str_update(str, 0L, 0L, arg_str); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#crypt;F;[[I" salt;T0;[[@i$;T;: crypt;0;[;{;IC;" Returns the string generated by calling crypt(3) standard library function with str and salt_str, in this order, as its arguments. Please do not use this method any longer. It is legacy; provided only for backward compatibility with ruby scripts in earlier days. It is bad to use in contemporary programs for several reasons: * Behaviour of C's crypt(3) depends on the OS it is run. The generated string lacks data portability. * On some OSes such as Mac OS, crypt(3) never fails (i.e. silently ends up in unexpected results). * On some OSes such as Mac OS, crypt(3) is not thread safe. * So-called "traditional" usage of crypt(3) is very very very weak. According to its manpage, Linux's traditional crypt(3) output has only 2**56 variations; too easy to brute force today. And this is the default behaviour. * In order to make things robust some OSes implement so-called "modular" usage. To go through, you have to do a complex build-up of the salt_str parameter, by hand. Failure in generation of a proper salt string tends not to yield any errors; typos in parameters are normally not detectable. * For instance, in the following example, the second invocation of String#crypt is wrong; it has a typo in "round=" (lacks "s"). However the call does not fail and something unexpected is generated. "foo".crypt("$5$rounds=1000$salt$") # OK, proper usage "foo".crypt("$5$round=1000$salt$") # Typo not detected * Even in the "modular" mode, some hash functions are considered archaic and no longer recommended at all; for instance module $1$ is officially abandoned by its author: see http://phk.freebsd.dk/sagas/md5crypt_eol.html . For another instance module $3$ is considered completely broken: see the manpage of FreeBSD. * On some OS such as Mac OS, there is no modular mode. Yet, as written above, crypt(3) on Mac OS never fails. This means even if you build up a proper salt string it generates a traditional DES hash anyways, and there is no way for you to be aware of. "foo".crypt("$5$rounds=1000$salt$") # => "$5fNPQMxC5j6." If for some reason you cannot migrate to other secure contemporary password hashing algorithms, install the string-crypt gem and require 'string/crypt' to continue using it. ;T;[o;H ;II" overload;F;J0;;S;K0;#I"crypt(salt_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @);[;I"@return [String];T;0; @);@F;Mi;N0;[[I" salt_str;T0; @);[;I"2 Returns the string generated by calling crypt(3) standard library function with str and salt_str, in this order, as its arguments. Please do not use this method any longer. It is legacy; provided only for backward compatibility with ruby scripts in earlier days. It is bad to use in contemporary programs for several reasons: * Behaviour of C's crypt(3) depends on the OS it is run. The generated string lacks data portability. * On some OSes such as Mac OS, crypt(3) never fails (i.e. silently ends up in unexpected results). * On some OSes such as Mac OS, crypt(3) is not thread safe. * So-called "traditional" usage of crypt(3) is very very very weak. According to its manpage, Linux's traditional crypt(3) output has only 2**56 variations; too easy to brute force today. And this is the default behaviour. * In order to make things robust some OSes implement so-called "modular" usage. To go through, you have to do a complex build-up of the salt_str parameter, by hand. Failure in generation of a proper salt string tends not to yield any errors; typos in parameters are normally not detectable. * For instance, in the following example, the second invocation of String#crypt is wrong; it has a typo in "round=" (lacks "s"). However the call does not fail and something unexpected is generated. "foo".crypt("$5$rounds=1000$salt$") # OK, proper usage "foo".crypt("$5$round=1000$salt$") # Typo not detected * Even in the "modular" mode, some hash functions are considered archaic and no longer recommended at all; for instance module $1$ is officially abandoned by its author: see http://phk.freebsd.dk/sagas/md5crypt_eol.html . For another instance module $3$ is considered completely broken: see the manpage of FreeBSD. * On some OS such as Mac OS, there is no modular mode. Yet, as written above, crypt(3) on Mac OS never fails. This means even if you build up a proper salt string it generates a traditional DES hash anyways, and there is no way for you to be aware of. "foo".crypt("$5$rounds=1000$salt$") # => "$5fNPQMxC5j6." If for some reason you cannot migrate to other secure contemporary password hashing algorithms, install the string-crypt gem and require 'string/crypt' to continue using it. @overload crypt(salt_str) @return [String];T;0; @);@F;Ao;B;CT;DiW$;Ei$;!@;"I"astatic VALUE rb_str_crypt(VALUE str, VALUE salt) { #ifdef HAVE_CRYPT_R VALUE databuf; struct crypt_data *data; # define CRYPT_END() ALLOCV_END(databuf) #else extern char *crypt(const char *, const char *); # define CRYPT_END() (void)0 #endif VALUE result; const char *s, *saltp; char *res; #ifdef BROKEN_CRYPT char salt_8bit_clean[3]; #endif StringValue(salt); mustnot_wchar(str); mustnot_wchar(salt); if (RSTRING_LEN(salt) < 2) { short_salt: rb_raise(rb_eArgError, "salt too short (need >=2 bytes)"); } s = StringValueCStr(str); saltp = RSTRING_PTR(salt); if (!saltp[0] || !saltp[1]) goto short_salt; #ifdef BROKEN_CRYPT if (!ISASCII((unsigned char)saltp[0]) || !ISASCII((unsigned char)saltp[1])) { salt_8bit_clean[0] = saltp[0] & 0x7f; salt_8bit_clean[1] = saltp[1] & 0x7f; salt_8bit_clean[2] = '\0'; saltp = salt_8bit_clean; } #endif #ifdef HAVE_CRYPT_R data = ALLOCV(databuf, sizeof(struct crypt_data)); # ifdef HAVE_STRUCT_CRYPT_DATA_INITIALIZED data->initialized = 0; # endif res = crypt_r(s, saltp, data); #else res = crypt(s, saltp); #endif if (!res) { int err = errno; CRYPT_END(); rb_syserr_fail(err, "crypt"); } result = rb_str_new_cstr(res); CRYPT_END(); FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt)); return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#intern;F;[;[[@{i;T;;;0;[;{;IC;"Returns the Symbol corresponding to str, creating the symbol if it did not previously exist. See Symbol#id2name. "Koala".intern #=> :Koala s = 'cat'.to_sym #=> :cat s == :cat #=> true s = '@cat'.to_sym #=> :@cat s == :@cat #=> true This can also be used to create symbols that cannot be represented using the :xxx notation. 'cat and dog'.to_sym #=> :"cat and dog" ;T;[o;H ;II" overload;F;J0;;;K0;#I" intern;T;IC;";T;[;[;I";T;0; @);@F;Mi;N0;[; @)o;H ;II" overload;F;J0;;;K0;#I" to_sym;T;IC;";T;[;[;I";T;0; @);@F;Mi;N0;[; @);[;I"Returns the Symbol corresponding to str, creating the symbol if it did not previously exist. See Symbol#id2name. "Koala".intern #=> :Koala s = 'cat'.to_sym #=> :cat s == :cat #=> true s = '@cat'.to_sym #=> :@cat s == :@cat #=> true This can also be used to create symbols that cannot be represented using the :xxx notation. 'cat and dog'.to_sym #=> :"cat and dog" @overload intern @overload to_sym;T;0; @);@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_str_intern(VALUE str) { #if USE_SYMBOL_GC rb_encoding *enc, *ascii; int type; #else ID id; #endif VALUE sym = lookup_str_sym(str); if (sym) { return sym; } #if USE_SYMBOL_GC enc = rb_enc_get(str); ascii = rb_usascii_encoding(); if (enc != ascii && sym_check_asciionly(str)) { str = rb_str_dup(str); rb_enc_associate(str, ascii); OBJ_FREEZE(str); enc = ascii; } else { str = rb_str_dup(str); OBJ_FREEZE(str); } str = rb_fstring(str); type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); if (type < 0) type = ID_JUNK; return dsymbol_alloc(rb_cSymbol, str, enc, type); #else id = intern_str(str, 0); return ID2SYM(id); #endif };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#to_sym;F;[;[[@{i;T;;;0;[;{;IC;"Returns the Symbol corresponding to str, creating the symbol if it did not previously exist. See Symbol#id2name. "Koala".intern #=> :Koala s = 'cat'.to_sym #=> :cat s == :cat #=> true s = '@cat'.to_sym #=> :@cat s == :@cat #=> true This can also be used to create symbols that cannot be represented using the :xxx notation. 'cat and dog'.to_sym #=> :"cat and dog" ;T;[o;H ;II" overload;F;J0;;;K0;#I" intern;T;IC;";T;[;[;I";T;0; @*;@F;Mi;N0;[; @*o;H ;II" overload;F;J0;;;K0;#I" to_sym;T;IC;";T;[;[;I";T;0; @*;@F;Mi;N0;[; @*;[;@*;0; @*;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_str_intern(VALUE str) { #if USE_SYMBOL_GC rb_encoding *enc, *ascii; int type; #else ID id; #endif VALUE sym = lookup_str_sym(str); if (sym) { return sym; } #if USE_SYMBOL_GC enc = rb_enc_get(str); ascii = rb_usascii_encoding(); if (enc != ascii && sym_check_asciionly(str)) { str = rb_str_dup(str); rb_enc_associate(str, ascii); OBJ_FREEZE(str); enc = ascii; } else { str = rb_str_dup(str); OBJ_FREEZE(str); } str = rb_fstring(str); type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); if (type < 0) type = ID_JUNK; return dsymbol_alloc(rb_cSymbol, str, enc, type); #else id = intern_str(str, 0); return ID2SYM(id); #endif };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#ord;F;[;[[@i$;T;:ord;0;[;{;IC;"cReturns the Integer ordinal of a one-character string. "a".ord #=> 97 ;T;[o;H ;II" overload;F;J0;;T;K0;#I"ord;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @0*;[;I"@return [Integer];T;0; @0*;@F;Mi;N0;[; @0*;[;I"Returns the Integer ordinal of a one-character string. "a".ord #=> 97 @overload ord @return [Integer];T;0; @0*;@F;Ao;B;CT;Di$;Ei$;!@;"I"VALUE rb_str_ord(VALUE s) { unsigned int c; c = rb_enc_codepoint(RSTRING_PTR(s), RSTRING_END(s), STR_ENC_GET(s)); return UINT2NUM(c); };T;#I" VALUE;T;$To; ; F; ;,;;;I"String#include?;F;[[I"arg;T0;[[@ig;T;: include?;0;[;{;IC;"Returns true if str contains the given string or character. "hello".include? "lo" #=> true "hello".include? "ol" #=> false "hello".include? ?h #=> true;T;[o;H ;II" overload;F;J0;;U;K0;#I"include? other_str;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @K*;[;I"@return [Boolean];T;0; @K*;@F;Mi;N0;[[I"other_str;T0; @K*;[;I"Returns true if str contains the given string or character. "hello".include? "lo" #=> true "hello".include? "ol" #=> false "hello".include? ?h #=> true @overload include? other_str @return [Boolean];T;0; @K*;@F;Ao;B;CT;Di[;Eid;Mi;!@;"I"static VALUE rb_str_include(VALUE str, VALUE arg) { long i; StringValue(arg); i = rb_str_index(str, arg, 0); if (i == -1) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#start_with?;F;[[@0;[[@i#&;T;:start_with?;0;[;{;IC;"}Returns true if +str+ starts with one of the +prefixes+ given. Each of the +prefixes+ should be a String or a Regexp. "hello".start_with?("hell") #=> true "hello".start_with?(/H/i) #=> true # returns true if one of the prefixes matches. "hello".start_with?("heaven", "hell") #=> true "hello".start_with?("heaven", "paradise") #=> false;T;[o;H ;II" overload;F;J0;;V;K0;#I"start_with?([prefixes]+);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @j*;[;I"@return [Boolean];T;0; @j*;@F;Mi;N0;[[I"[prefixes];T0; @j*;[;I"Returns true if +str+ starts with one of the +prefixes+ given. Each of the +prefixes+ should be a String or a Regexp. "hello".start_with?("hell") #=> true "hello".start_with?(/H/i) #=> true # returns true if one of the prefixes matches. "hello".start_with?("heaven", "hell") #=> true "hello".start_with?("heaven", "paradise") #=> false @overload start_with?([prefixes]+) @return [Boolean];T;0; @j*;@F;Ao;B;CT;Di&;Ei &;Mi;!@;"I"static VALUE rb_str_start_with(int argc, VALUE *argv, VALUE str) { int i; for (i=0; i true # returns true if one of the +suffixes+ matches. "hello".end_with?("heaven", "ello") #=> true "hello".end_with?("heaven", "paradise") #=> false;T;[o;H ;II" overload;F;J0;;W;K0;#I"end_with?([suffixes]+);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @*;[;I"@return [Boolean];T;0; @*;@F;Mi;N0;[[I"[suffixes];T0; @*;[;I"BReturns true if +str+ ends with one of the +suffixes+ given. "hello".end_with?("ello") #=> true # returns true if one of the +suffixes+ matches. "hello".end_with?("heaven", "ello") #=> true "hello".end_with?("heaven", "paradise") #=> false @overload end_with?([suffixes]+) @return [Boolean];T;0; @*;@F;Ao;B;CT;Di9&;EiC&;Mi;!@;"I" static VALUE rb_str_end_with(int argc, VALUE *argv, VALUE str) { int i; char *p, *s, *e; rb_encoding *enc; for (i=0; istr, matching the pattern (which may be a Regexp or a String). For each match, a result is generated and either added to the result array or passed to the block. If the pattern contains no groups, each individual result consists of the matched string, $&. If the pattern contains groups, each individual result is itself an array containing one entry per group. a = "cruel world" a.scan(/\w+/) #=> ["cruel", "world"] a.scan(/.../) #=> ["cru", "el ", "wor"] a.scan(/(...)/) #=> [["cru"], ["el "], ["wor"]] a.scan(/(..)(..)/) #=> [["cr", "ue"], ["l ", "wo"]] And the block form: a.scan(/\w+/) {|w| print "<<#{w}>> " } print "\n" a.scan(/(.)(.)/) {|x,y| print y, x } print "\n" produces: <> <> rceu lowlr ;T;[o;H ;II" overload;F;J0;;X;K0;#I"scan(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @*;[;I"@return [Array];T;0; @*;@F;Mi;N0;[[I" pattern;T0; @*o;H ;II" overload;F;J0;;X;K0;#I"scan(pattern);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" match;TI"...;T; @*o;L ;II" return;F;JI";T;0;K[I" String;T; @*;[;I")@yield [match, ...] @return [String];T;0; @*;@F;Mi;N0;[[I" pattern;T0; @*;[;I"Both forms iterate through str, matching the pattern (which may be a Regexp or a String). For each match, a result is generated and either added to the result array or passed to the block. If the pattern contains no groups, each individual result consists of the matched string, $&. If the pattern contains groups, each individual result is itself an array containing one entry per group. a = "cruel world" a.scan(/\w+/) #=> ["cruel", "world"] a.scan(/.../) #=> ["cru", "el ", "wor"] a.scan(/(...)/) #=> [["cru"], ["el "], ["wor"]] a.scan(/(..)(..)/) #=> [["cr", "ue"], ["l ", "wo"]] And the block form: a.scan(/\w+/) {|w| print "<<#{w}>> " } print "\n" a.scan(/(.)(.)/) {|x,y| print y, x } print "\n" produces: <> <> rceu lowlr @overload scan(pattern) @return [Array] @overload scan(pattern) @yield [match, ...] @return [String];T;0; @*;@F;Ao;B;CT;Di#;Ei$;!@;"I"static VALUE rb_str_scan(VALUE str, VALUE pat) { VALUE result; long start = 0; long last = -1, prev = 0; char *p = RSTRING_PTR(str); long len = RSTRING_LEN(str); pat = get_pat_quoted(pat, 1); mustnot_broken(str); if (!rb_block_given_p()) { VALUE ary = rb_ary_new(); while (!NIL_P(result = scan_once(str, pat, &start, 0))) { last = prev; prev = start; rb_ary_push(ary, result); } if (last >= 0) rb_pat_search(pat, str, last, 1); else rb_backref_set(Qnil); return ary; } while (!NIL_P(result = scan_once(str, pat, &start, 1))) { last = prev; prev = start; rb_yield(result); str_mod_check(str, p, len); } if (last >= 0) rb_pat_search(pat, str, last, 1); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#ljust;F;[[@0;[[@i%;T;: ljust;0;[;{;IC;"sIf integer is greater than the length of str, returns a new String of length integer with str left justified and padded with padstr; otherwise, returns str. "hello".ljust(4) #=> "hello" "hello".ljust(20) #=> "hello " "hello".ljust(20, '1234') #=> "hello123412341234123" ;T;[o;H ;II" overload;F;J0;;Y;K0;#I"ljust(integer, padstr=' ');T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @*;[;I"@return [String];T;0; @*;@F;Mi;N0;[[I" integer;T0[I" padstr;TI"' ';T; @*;[;I"If integer is greater than the length of str, returns a new String of length integer with str left justified and padded with padstr; otherwise, returns str. "hello".ljust(4) #=> "hello" "hello".ljust(20) #=> "hello " "hello".ljust(20, '1234') #=> "hello123412341234123" @overload ljust(integer, padstr=' ') @return [String];T;0; @*;@F;Ao;B;CT;Di}%;Ei%;!@;"I"ustatic VALUE rb_str_ljust(int argc, VALUE *argv, VALUE str) { return rb_str_justify(argc, argv, str, 'l'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#rjust;F;[[@0;[[@i%;T;: rjust;0;[;{;IC;"tIf integer is greater than the length of str, returns a new String of length integer with str right justified and padded with padstr; otherwise, returns str. "hello".rjust(4) #=> "hello" "hello".rjust(20) #=> " hello" "hello".rjust(20, '1234') #=> "123412341234123hello" ;T;[o;H ;II" overload;F;J0;;Z;K0;#I"rjust(integer, padstr=' ');T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @*;[;I"@return [String];T;0; @*;@F;Mi;N0;[[I" integer;T0[I" padstr;TI"' ';T; @*;[;I"If integer is greater than the length of str, returns a new String of length integer with str right justified and padded with padstr; otherwise, returns str. "hello".rjust(4) #=> "hello" "hello".rjust(20) #=> " hello" "hello".rjust(20, '1234') #=> "123412341234123hello" @overload rjust(integer, padstr=' ') @return [String];T;0; @*;@F;Ao;B;CT;Di%;Ei%;!@;"I"ustatic VALUE rb_str_rjust(int argc, VALUE *argv, VALUE str) { return rb_str_justify(argc, argv, str, 'r'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#center;F;[[@0;[[@i%;T;: center;0;[;{;IC;"SCenters +str+ in +width+. If +width+ is greater than the length of +str+, returns a new String of length +width+ with +str+ centered and padded with +padstr+; otherwise, returns +str+. "hello".center(4) #=> "hello" "hello".center(20) #=> " hello " "hello".center(20, '123') #=> "1231231hello12312312" ;T;[o;H ;II" overload;F;J0;;[;K0;#I"center(width, padstr=' ');T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @+;[;I"@return [String];T;0; @+;@F;Mi;N0;[[I" width;T0[I" padstr;TI"' ';T; @+;[;I"Centers +str+ in +width+. If +width+ is greater than the length of +str+, returns a new String of length +width+ with +str+ centered and padded with +padstr+; otherwise, returns +str+. "hello".center(4) #=> "hello" "hello".center(20) #=> " hello " "hello".center(20, '123') #=> "1231231hello12312312" @overload center(width, padstr=' ') @return [String];T;0; @+;@F;Ao;B;CT;Di%;Ei%;!@;"I"vstatic VALUE rb_str_center(int argc, VALUE *argv, VALUE str) { return rb_str_justify(argc, argv, str, 'c'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#sub;F;[[@0;[[@i);T;:sub;0;[;{;IC;"fReturns a copy of +str+ with the _first_ occurrence of +pattern+ replaced by the second argument. The +pattern+ is typically a Regexp; if given as a String, any regular expression metacharacters it contains will be interpreted literally, e.g. '\\\d' will match a backslash followed by 'd', instead of a digit. If +replacement+ is a String it will be substituted for the matched text. It may contain back-references to the pattern's capture groups of the form "\\d", where d is a group number, or "\\k", where n is a group name. If it is a double-quoted string, both back-references must be preceded by an additional backslash. However, within +replacement+ the special match variables, such as $&, will not refer to the current match. If +replacement+ is a String that looks like a pattern's capture group but is actually not a pattern capture group e.g. "\\'", then it will have to be preceded by two backslashes like so "\\\\'". If the second argument is a Hash, and the matched text is one of its keys, the corresponding value is the replacement string. In the block form, the current match string is passed in as a parameter, and variables such as $1, $2, $`, $&, and $' will be set appropriately. The value returned by the block will be substituted for the match on each call. The result inherits any tainting in the original string or any supplied replacement string. "hello".sub(/[aeiou]/, '*') #=> "h*llo" "hello".sub(/([aeiou])/, '<\1>') #=> "hllo" "hello".sub(/./) {|s| s.ord.to_s + ' ' } #=> "104 ello" "hello".sub(/(?[aeiou])/, '*\k*') #=> "h*e*llo" 'Is SHELL your preferred shell?'.sub(/[[:upper:]]{2,}/, ENV) #=> "Is /bin/bash your preferred shell?" ;T;[o;H ;II" overload;F;J0;;\;K0;#I"sub(pattern, replacement);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @=+;[;I"@return [String];T;0; @=+;@F;Mi;N0;[[I" pattern;T0[I"replacement;T0; @=+o;H ;II" overload;F;J0;;\;K0;#I"sub(pattern, hash);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @=+;[;I"@return [String];T;0; @=+;@F;Mi;N0;[[I" pattern;T0[I" hash;T0; @=+o;H ;II" overload;F;J0;;\;K0;#I"sub(pattern);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" match;T; @=+o;L ;II" return;F;JI";T;0;K[I" String;T; @=+;[;I"$@yield [match] @return [String];T;0; @=+;@F;Mi;N0;[[I" pattern;T0; @=+;[;I" Returns a copy of +str+ with the _first_ occurrence of +pattern+ replaced by the second argument. The +pattern+ is typically a Regexp; if given as a String, any regular expression metacharacters it contains will be interpreted literally, e.g. '\\\d' will match a backslash followed by 'd', instead of a digit. If +replacement+ is a String it will be substituted for the matched text. It may contain back-references to the pattern's capture groups of the form "\\d", where d is a group number, or "\\k", where n is a group name. If it is a double-quoted string, both back-references must be preceded by an additional backslash. However, within +replacement+ the special match variables, such as $&, will not refer to the current match. If +replacement+ is a String that looks like a pattern's capture group but is actually not a pattern capture group e.g. "\\'", then it will have to be preceded by two backslashes like so "\\\\'". If the second argument is a Hash, and the matched text is one of its keys, the corresponding value is the replacement string. In the block form, the current match string is passed in as a parameter, and variables such as $1, $2, $`, $&, and $' will be set appropriately. The value returned by the block will be substituted for the match on each call. The result inherits any tainting in the original string or any supplied replacement string. "hello".sub(/[aeiou]/, '*') #=> "h*llo" "hello".sub(/([aeiou])/, '<\1>') #=> "hllo" "hello".sub(/./) {|s| s.ord.to_s + ' ' } #=> "104 ello" "hello".sub(/(?[aeiou])/, '*\k*') #=> "h*e*llo" 'Is SHELL your preferred shell?'.sub(/[[:upper:]]{2,}/, ENV) #=> "Is /bin/bash your preferred shell?" @overload sub(pattern, replacement) @return [String] @overload sub(pattern, hash) @return [String] @overload sub(pattern) @yield [match] @return [String];T;0; @=+;@F;Ao;B;CT;Di;Ei);!@;"I"static VALUE rb_str_sub(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); rb_str_sub_bang(argc, argv, str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#gsub;F;[[@0;[[@i;T;: gsub;0;[;{;IC;"Returns a copy of str with all occurrences of pattern substituted for the second argument. The pattern is typically a Regexp; if given as a String, any regular expression metacharacters it contains will be interpreted literally, e.g. '\\\d' will match a backslash followed by 'd', instead of a digit. If replacement is a String it will be substituted for the matched text. It may contain back-references to the pattern's capture groups of the form \\\d, where d is a group number, or \\\k, where n is a group name. If it is a double-quoted string, both back-references must be preceded by an additional backslash. However, within replacement the special match variables, such as $&, will not refer to the current match. If the second argument is a Hash, and the matched text is one of its keys, the corresponding value is the replacement string. In the block form, the current match string is passed in as a parameter, and variables such as $1, $2, $`, $&, and $' will be set appropriately. The value returned by the block will be substituted for the match on each call. The result inherits any tainting in the original string or any supplied replacement string. When neither a block nor a second argument is supplied, an Enumerator is returned. "hello".gsub(/[aeiou]/, '*') #=> "h*ll*" "hello".gsub(/([aeiou])/, '<\1>') #=> "hll" "hello".gsub(/./) {|s| s.ord.to_s + ' '} #=> "104 101 108 108 111 " "hello".gsub(/(?[aeiou])/, '{\k}') #=> "h{e}ll{o}" 'hello'.gsub(/[eo]/, 'e' => 3, 'o' => '*') #=> "h3ll*" ;T;[ o;H ;II" overload;F;J0;;];K0;#I"gsub(pattern, replacement);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @+;[;I"@return [String];T;0; @+;@F;Mi;N0;[[I" pattern;T0[I"replacement;T0; @+o;H ;II" overload;F;J0;;];K0;#I"gsub(pattern, hash);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @+;[;I"@return [String];T;0; @+;@F;Mi;N0;[[I" pattern;T0[I" hash;T0; @+o;H ;II" overload;F;J0;;];K0;#I"gsub(pattern);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" match;T; @+o;L ;II" return;F;JI";T;0;K[I" String;T; @+;[;I"$@yield [match] @return [String];T;0; @+;@F;Mi;N0;[[I" pattern;T0; @+o;H ;II" overload;F;J0;;];K0;#I"gsub(pattern);T;IC;";T;[;[;I";T;0; @+;@F;Mi;N0;[[I" pattern;T0; @+;[;I"Returns a copy of str with all occurrences of pattern substituted for the second argument. The pattern is typically a Regexp; if given as a String, any regular expression metacharacters it contains will be interpreted literally, e.g. '\\\d' will match a backslash followed by 'd', instead of a digit. If replacement is a String it will be substituted for the matched text. It may contain back-references to the pattern's capture groups of the form \\\d, where d is a group number, or \\\k, where n is a group name. If it is a double-quoted string, both back-references must be preceded by an additional backslash. However, within replacement the special match variables, such as $&, will not refer to the current match. If the second argument is a Hash, and the matched text is one of its keys, the corresponding value is the replacement string. In the block form, the current match string is passed in as a parameter, and variables such as $1, $2, $`, $&, and $' will be set appropriately. The value returned by the block will be substituted for the match on each call. The result inherits any tainting in the original string or any supplied replacement string. When neither a block nor a second argument is supplied, an Enumerator is returned. "hello".gsub(/[aeiou]/, '*') #=> "h*ll*" "hello".gsub(/([aeiou])/, '<\1>') #=> "hll" "hello".gsub(/./) {|s| s.ord.to_s + ' '} #=> "104 101 108 108 111 " "hello".gsub(/(?[aeiou])/, '{\k}') #=> "h{e}ll{o}" 'hello'.gsub(/[eo]/, 'e' => 3, 'o' => '*') #=> "h3ll*" @overload gsub(pattern, replacement) @return [String] @overload gsub(pattern, hash) @return [String] @overload gsub(pattern) @yield [match] @return [String] @overload gsub(pattern);T;0; @+;@F;Ao;B;CT;Di;Ei;!@;"I"lstatic VALUE rb_str_gsub(int argc, VALUE *argv, VALUE str) { return str_gsub(argc, argv, str, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#chop;F;[;[[@i!;T;: chop;0;[;{;IC;"Returns a new String with the last character removed. If the string ends with \r\n, both characters are removed. Applying chop to an empty string returns an empty string. String#chomp is often a safer alternative, as it leaves the string unchanged if it doesn't end in a record separator. "string\r\n".chop #=> "string" "string\n\r".chop #=> "string\n" "string\n".chop #=> "string" "string".chop #=> "strin" "x".chop.chop #=> "" ;T;[o;H ;II" overload;F;J0;;^;K0;#I" chop;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @+;[;I"@return [String];T;0; @+;@F;Mi;N0;[; @+;[;I")Returns a new String with the last character removed. If the string ends with \r\n, both characters are removed. Applying chop to an empty string returns an empty string. String#chomp is often a safer alternative, as it leaves the string unchanged if it doesn't end in a record separator. "string\r\n".chop #=> "string" "string\n\r".chop #=> "string\n" "string\n".chop #=> "string" "string".chop #=> "strin" "x".chop.chop #=> "" @overload chop @return [String];T;0; @+;@F;Ao;B;CT;Di!;Ei!;!@;"I"cstatic VALUE rb_str_chop(VALUE str) { return rb_str_subseq(str, 0, chopped_length(str)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#chomp;F;[[@0;[[@i";T;: chomp;0;[;{;IC;"LReturns a new String with the given record separator removed from the end of str (if present). If $/ has not been changed from the default Ruby record separator, then chomp also removes carriage return characters (that is it will remove \n, \r, and \r\n). If $/ is an empty string, it will remove all trailing newlines from the string. "hello".chomp #=> "hello" "hello\n".chomp #=> "hello" "hello\r\n".chomp #=> "hello" "hello\n\r".chomp #=> "hello\n" "hello\r".chomp #=> "hello" "hello \n there".chomp #=> "hello \n there" "hello".chomp("llo") #=> "he" "hello\r\n\r\n".chomp('') #=> "hello" "hello\r\n\r\r\n".chomp('') #=> "hello\r\n\r" ;T;[o;H ;II" overload;F;J0;;_;K0;#I"chomp(separator=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @+;[;I"@return [String];T;0; @+;@F;Mi;N0;[[I"separator;TI"$/;T; @+;[;I"Returns a new String with the given record separator removed from the end of str (if present). If $/ has not been changed from the default Ruby record separator, then chomp also removes carriage return characters (that is it will remove \n, \r, and \r\n). If $/ is an empty string, it will remove all trailing newlines from the string. "hello".chomp #=> "hello" "hello\n".chomp #=> "hello" "hello\r\n".chomp #=> "hello" "hello\n\r".chomp #=> "hello\n" "hello\r".chomp #=> "hello" "hello \n there".chomp #=> "hello \n there" "hello".chomp("llo") #=> "he" "hello\r\n\r\n".chomp('') #=> "hello" "hello\r\n\r\r\n".chomp('') #=> "hello\r\n\r" @overload chomp(separator=$/) @return [String];T;0; @+;@F;Ao;B;CT;Di";Ei";!@;"I"static VALUE rb_str_chomp(int argc, VALUE *argv, VALUE str) { VALUE rs = chomp_rs(argc, argv); if (NIL_P(rs)) return rb_str_dup(str); return rb_str_subseq(str, 0, chompped_length(str, rs)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#strip;F;[;[[@i#;T;: strip;0;[;{;IC;"sReturns a copy of the receiver with leading and trailing whitespace removed. Whitespace is defined as any of the following characters: null, horizontal tab, line feed, vertical tab, form feed, carriage return, space. " hello ".strip #=> "hello" "\tgoodbye\r\n".strip #=> "goodbye" "\x00\t\n\v\f\r ".strip #=> "" "hello".strip #=> "hello" ;T;[o;H ;II" overload;F;J0;;`;K0;#I" strip;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ,;[;I"@return [String];T;0; @ ,;@F;Mi;N0;[; @ ,;[;I"Returns a copy of the receiver with leading and trailing whitespace removed. Whitespace is defined as any of the following characters: null, horizontal tab, line feed, vertical tab, form feed, carriage return, space. " hello ".strip #=> "hello" "\tgoodbye\r\n".strip #=> "goodbye" "\x00\t\n\v\f\r ".strip #=> "" "hello".strip #=> "hello" @overload strip @return [String];T;0; @ ,;@F;Ao;B;CT;Di#;Ei#;!@;"I"static VALUE rb_str_strip(VALUE str) { char *start; long olen, loffset, roffset; rb_encoding *enc = STR_ENC_GET(str); RSTRING_GETMEM(str, start, olen); loffset = lstrip_offset(str, start, start+olen, enc); roffset = rstrip_offset(str, start+loffset, start+olen, enc); if (loffset <= 0 && roffset <= 0) return rb_str_dup(str); return rb_str_subseq(str, loffset, olen-loffset-roffset); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#lstrip;F;[;[[@i#;T;: lstrip;0;[;{;IC;"Returns a copy of the receiver with leading whitespace removed. See also String#rstrip and String#strip. Refer to String#strip for the definition of whitespace. " hello ".lstrip #=> "hello " "hello".lstrip #=> "hello" ;T;[o;H ;II" overload;F;J0;;a;K0;#I" lstrip;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&,;[;I"@return [String];T;0; @&,;@F;Mi;N0;[; @&,;[;I"Returns a copy of the receiver with leading whitespace removed. See also String#rstrip and String#strip. Refer to String#strip for the definition of whitespace. " hello ".lstrip #=> "hello " "hello".lstrip #=> "hello" @overload lstrip @return [String];T;0; @&,;@F;Ao;B;CT;Di";Ei#;!@;"I"!static VALUE rb_str_lstrip(VALUE str) { char *start; long len, loffset; RSTRING_GETMEM(str, start, len); loffset = lstrip_offset(str, start, start+len, STR_ENC_GET(str)); if (loffset <= 0) return rb_str_dup(str); return rb_str_subseq(str, loffset, len - loffset); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#rstrip;F;[;[[@i\#;T;: rstrip;0;[;{;IC;"Returns a copy of the receiver with trailing whitespace removed. See also String#lstrip and String#strip. Refer to String#strip for the definition of whitespace. " hello ".rstrip #=> " hello" "hello".rstrip #=> "hello" ;T;[o;H ;II" overload;F;J0;;b;K0;#I" rstrip;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @A,;[;I"@return [String];T;0; @A,;@F;Mi;N0;[; @A,;[;I"Returns a copy of the receiver with trailing whitespace removed. See also String#lstrip and String#strip. Refer to String#strip for the definition of whitespace. " hello ".rstrip #=> " hello" "hello".rstrip #=> "hello" @overload rstrip @return [String];T;0; @A,;@F;Ao;B;CT;DiO#;EiY#;!@;"I"Dstatic VALUE rb_str_rstrip(VALUE str) { rb_encoding *enc; char *start; long olen, roffset; enc = STR_ENC_GET(str); RSTRING_GETMEM(str, start, olen); roffset = rstrip_offset(str, start, start+olen, enc); if (roffset <= 0) return rb_str_dup(str); return rb_str_subseq(str, 0, olen-roffset); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#delete_prefix;F;[[I" prefix;T0;[[@i&;T;:delete_prefix;0;[;{;IC;"Returns a copy of str with leading prefix deleted. "hello".delete_prefix("hel") #=> "lo" "hello".delete_prefix("llo") #=> "hello" ;T;[o;H ;II" overload;F;J0;;c;K0;#I"delete_prefix(prefix);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @\,;[;I"@return [String];T;0; @\,;@F;Mi;N0;[[I" prefix;T0; @\,;[;I"Returns a copy of str with leading prefix deleted. "hello".delete_prefix("hel") #=> "lo" "hello".delete_prefix("llo") #=> "hello" @overload delete_prefix(prefix) @return [String];T;0; @\,;@F;Ao;B;CT;Di&;Ei&;!@;"I"static VALUE rb_str_delete_prefix(VALUE str, VALUE prefix) { long prefixlen; prefixlen = deleted_prefix_length(str, prefix); if (prefixlen <= 0) return rb_str_dup(str); return rb_str_subseq(str, prefixlen, RSTRING_LEN(str) - prefixlen); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#delete_suffix;F;[[I" suffix;T0;[[@i&;T;:delete_suffix;0;[;{;IC;"Returns a copy of str with trailing suffix deleted. "hello".delete_suffix("llo") #=> "he" "hello".delete_suffix("hel") #=> "hello" ;T;[o;H ;II" overload;F;J0;;d;K0;#I"delete_suffix(suffix);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @{,;[;I"@return [String];T;0; @{,;@F;Mi;N0;[[I" suffix;T0; @{,;[;I"Returns a copy of str with trailing suffix deleted. "hello".delete_suffix("llo") #=> "he" "hello".delete_suffix("hel") #=> "hello" @overload delete_suffix(suffix) @return [String];T;0; @{,;@F;Ao;B;CT;Di&;Ei&;!@;"I"static VALUE rb_str_delete_suffix(VALUE str, VALUE suffix) { long suffixlen; suffixlen = deleted_suffix_length(str, suffix); if (suffixlen <= 0) return rb_str_dup(str); return rb_str_subseq(str, 0, RSTRING_LEN(str) - suffixlen); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#sub!;F;[[@0;[[@i;T;: sub!;0;[;{;IC;"Performs the same substitution as String#sub in-place. Returns +str+ if a substitution was performed or +nil+ if no substitution was performed. ;T;[o;H ;II" overload;F;J0;;e;K0;#I"sub!(pattern, replacement);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @,;[;I"@return [String, nil];T;0; @,;@F;Mi;N0;[[I" pattern;T0[I"replacement;T0; @,o;H ;II" overload;F;J0;;e;K0;#I"sub!(pattern);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" match;T; @,o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @,;[;I")@yield [match] @return [String, nil];T;0; @,;@F;Mi;N0;[[I" pattern;T0; @,;[;I"Performs the same substitution as String#sub in-place. Returns +str+ if a substitution was performed or +nil+ if no substitution was performed. @overload sub!(pattern, replacement) @return [String, nil] @overload sub!(pattern) @yield [match] @return [String, nil];T;0; @,;@F;Ao;B;CT;Di;Ei;!@;"I"c static VALUE rb_str_sub_bang(int argc, VALUE *argv, VALUE str) { VALUE pat, repl, hash = Qnil; int iter = 0; int tainted = 0; long plen; int min_arity = rb_block_given_p() ? 1 : 2; long beg; rb_check_arity(argc, min_arity, 2); if (argc == 1) { iter = 1; } else { repl = argv[1]; hash = rb_check_hash_type(argv[1]); if (NIL_P(hash)) { StringValue(repl); } tainted = OBJ_TAINTED_RAW(repl); } pat = get_pat_quoted(argv[0], 1); str_modifiable(str); beg = rb_pat_search(pat, str, 0, 1); if (beg >= 0) { rb_encoding *enc; int cr = ENC_CODERANGE(str); long beg0, end0; VALUE match, match0 = Qnil; struct re_registers *regs; char *p, *rp; long len, rlen; match = rb_backref_get(); regs = RMATCH_REGS(match); if (RB_TYPE_P(pat, T_STRING)) { beg0 = beg; end0 = beg0 + RSTRING_LEN(pat); match0 = pat; } else { beg0 = BEG(0); end0 = END(0); if (iter) match0 = rb_reg_nth_match(0, match); } if (iter || !NIL_P(hash)) { p = RSTRING_PTR(str); len = RSTRING_LEN(str); if (iter) { repl = rb_obj_as_string(rb_yield(match0)); } else { repl = rb_hash_aref(hash, rb_str_subseq(str, beg0, end0 - beg0)); repl = rb_obj_as_string(repl); } str_mod_check(str, p, len); rb_check_frozen(str); } else { repl = rb_reg_regsub(repl, str, regs, RB_TYPE_P(pat, T_STRING) ? Qnil : pat); } enc = rb_enc_compatible(str, repl); if (!enc) { rb_encoding *str_enc = STR_ENC_GET(str); p = RSTRING_PTR(str); len = RSTRING_LEN(str); if (coderange_scan(p, beg0, str_enc) != ENC_CODERANGE_7BIT || coderange_scan(p+end0, len-end0, str_enc) != ENC_CODERANGE_7BIT) { rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s", rb_enc_name(str_enc), rb_enc_name(STR_ENC_GET(repl))); } enc = STR_ENC_GET(repl); } rb_str_modify(str); rb_enc_associate(str, enc); tainted |= OBJ_TAINTED_RAW(repl); if (ENC_CODERANGE_UNKNOWN < cr && cr < ENC_CODERANGE_BROKEN) { int cr2 = ENC_CODERANGE(repl); if (cr2 == ENC_CODERANGE_BROKEN || (cr == ENC_CODERANGE_VALID && cr2 == ENC_CODERANGE_7BIT)) cr = ENC_CODERANGE_UNKNOWN; else cr = cr2; } plen = end0 - beg0; rlen = RSTRING_LEN(repl); len = RSTRING_LEN(str); if (rlen > plen) { RESIZE_CAPA(str, len + rlen - plen); } p = RSTRING_PTR(str); if (rlen != plen) { memmove(p + beg0 + rlen, p + beg0 + plen, len - beg0 - plen); } rp = RSTRING_PTR(repl); memmove(p + beg0, rp, rlen); len += rlen - plen; STR_SET_LEN(str, len); TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str)); ENC_CODERANGE_SET(str, cr); FL_SET_RAW(str, tainted); return str; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#gsub!;F;[[@0;[[@i;T;: gsub!;0;[;{;IC;"Performs the substitutions of String#gsub in place, returning str, or nil if no substitutions were performed. If no block and no replacement is given, an enumerator is returned instead. ;T;[ o;H ;II" overload;F;J0;;f;K0;#I" gsub!(pattern, replacement);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @,;[;I"@return [String, nil];T;0; @,;@F;Mi;N0;[[I" pattern;T0[I"replacement;T0; @,o;H ;II" overload;F;J0;;f;K0;#I"gsub!(pattern, hash);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @,;[;I"@return [String, nil];T;0; @,;@F;Mi;N0;[[I" pattern;T0[I" hash;T0; @,o;H ;II" overload;F;J0;;f;K0;#I"gsub!(pattern);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" match;T; @,o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @,;[;I")@yield [match] @return [String, nil];T;0; @,;@F;Mi;N0;[[I" pattern;T0; @,o;H ;II" overload;F;J0;;f;K0;#I"gsub!(pattern);T;IC;";T;[;[;I";T;0; @,;@F;Mi;N0;[[I" pattern;T0; @,;[;I"Performs the substitutions of String#gsub in place, returning str, or nil if no substitutions were performed. If no block and no replacement is given, an enumerator is returned instead. @overload gsub!(pattern, replacement) @return [String, nil] @overload gsub!(pattern, hash) @return [String, nil] @overload gsub!(pattern) @yield [match] @return [String, nil] @overload gsub!(pattern);T;0; @,;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_gsub_bang(int argc, VALUE *argv, VALUE str) { str_modify_keep_cr(str); return str_gsub(argc, argv, str, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#chop!;F;[;[[@i!;T;: chop!;0;[;{;IC;"Processes str as for String#chop, returning str, or nil if str is the empty string. See also String#chomp!. ;T;[o;H ;II" overload;F;J0;;g;K0;#I" chop!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @"-;[;I"@return [String, nil];T;0; @"-;@F;Mi;N0;[; @"-;[;I"Processes str as for String#chop, returning str, or nil if str is the empty string. See also String#chomp!. @overload chop! @return [String, nil];T;0; @"-;@F;Ao;B;CT;Di!;Ei!;!@;"I"Rstatic VALUE rb_str_chop_bang(VALUE str) { str_modify_keep_cr(str); if (RSTRING_LEN(str) > 0) { long len; len = chopped_length(str); STR_SET_LEN(str, len); TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str)); if (ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) { ENC_CODERANGE_CLEAR(str); } return str; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#chomp!;F;[[@0;[[@i";T;: chomp!;0;[;{;IC;"Modifies str in place as described for String#chomp, returning str, or nil if no modifications were made. ;T;[o;H ;II" overload;F;J0;;h;K0;#I"chomp!(separator=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @>-;[;I"@return [String, nil];T;0; @>-;@F;Mi;N0;[[I"separator;TI"$/;T; @>-;[;I"Modifies str in place as described for String#chomp, returning str, or nil if no modifications were made. @overload chomp!(separator=$/) @return [String, nil];T;0; @>-;@F;Ao;B;CT;Di";Ei";!@;"I"static VALUE rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) { VALUE rs; str_modifiable(str); if (RSTRING_LEN(str) == 0) return Qnil; rs = chomp_rs(argc, argv); if (NIL_P(rs)) return Qnil; return rb_str_chomp_string(str, rs); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#strip!;F;[;[[@iy#;T;: strip!;0;[;{;IC;"Removes leading and trailing whitespace from the receiver. Returns the altered receiver, or +nil+ if there was no change. Refer to String#strip for the definition of whitespace. " hello ".strip! #=> "hello" "hello".strip! #=> nil ;T;[o;H ;II" overload;F;J0;;i;K0;#I" strip!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;TI"nil;T; @^-;[;I"@return [self, nil];T;0; @^-;@F;Mi;N0;[; @^-;[;I"Removes leading and trailing whitespace from the receiver. Returns the altered receiver, or +nil+ if there was no change. Refer to String#strip for the definition of whitespace. " hello ".strip! #=> "hello" "hello".strip! #=> nil @overload strip! @return [self, nil];T;0; @^-;@F;Ao;B;CT;Dil#;Eiv#;!@;"I"xstatic VALUE rb_str_strip_bang(VALUE str) { char *start; long olen, loffset, roffset; rb_encoding *enc; str_modify_keep_cr(str); enc = STR_ENC_GET(str); RSTRING_GETMEM(str, start, olen); loffset = lstrip_offset(str, start, start+olen, enc); roffset = rstrip_offset(str, start+loffset, start+olen, enc); if (loffset > 0 || roffset > 0) { long len = olen-roffset; if (loffset > 0) { len -= loffset; memmove(start, start + loffset, len); } STR_SET_LEN(str, len); #if !SHARABLE_MIDDLE_SUBSTRING TERM_FILL(start+len, rb_enc_mbminlen(enc)); #endif return str; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#lstrip!;F;[;[[@i";T;: lstrip!;0;[;{;IC;"6Removes leading whitespace from the receiver. Returns the altered receiver, or +nil+ if no change was made. See also String#rstrip! and String#strip!. Refer to String#strip for the definition of whitespace. " hello ".lstrip! #=> "hello " "hello ".lstrip! #=> nil "hello".lstrip! #=> nil ;T;[o;H ;II" overload;F;J0;;j;K0;#I" lstrip!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;TI"nil;T; @z-;[;I"@return [self, nil];T;0; @z-;@F;Mi;N0;[; @z-;[;I"`Removes leading whitespace from the receiver. Returns the altered receiver, or +nil+ if no change was made. See also String#rstrip! and String#strip!. Refer to String#strip for the definition of whitespace. " hello ".lstrip! #=> "hello " "hello ".lstrip! #=> nil "hello".lstrip! #=> nil @overload lstrip! @return [self, nil];T;0; @z-;@F;Ao;B;CT;Di";Ei";!@;"I"static VALUE rb_str_lstrip_bang(VALUE str) { rb_encoding *enc; char *start, *s; long olen, loffset; str_modify_keep_cr(str); enc = STR_ENC_GET(str); RSTRING_GETMEM(str, start, olen); loffset = lstrip_offset(str, start, start+olen, enc); if (loffset > 0) { long len = olen-loffset; s = start + loffset; memmove(start, s, len); STR_SET_LEN(str, len); #if !SHARABLE_MIDDLE_SUBSTRING TERM_FILL(start+len, rb_enc_mbminlen(enc)); #endif return str; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#rstrip!;F;[;[[@i7#;T;: rstrip!;0;[;{;IC;"7Removes trailing whitespace from the receiver. Returns the altered receiver, or +nil+ if no change was made. See also String#lstrip! and String#strip!. Refer to String#strip for the definition of whitespace. " hello ".rstrip! #=> " hello" " hello".rstrip! #=> nil "hello".rstrip! #=> nil ;T;[o;H ;II" overload;F;J0;;k;K0;#I" rstrip!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;TI"nil;T; @-;[;I"@return [self, nil];T;0; @-;@F;Mi;N0;[; @-;[;I"aRemoves trailing whitespace from the receiver. Returns the altered receiver, or +nil+ if no change was made. See also String#lstrip! and String#strip!. Refer to String#strip for the definition of whitespace. " hello ".rstrip! #=> " hello" " hello".rstrip! #=> nil "hello".rstrip! #=> nil @overload rstrip! @return [self, nil];T;0; @-;@F;Ao;B;CT;Di(#;Ei4#;!@;"I"static VALUE rb_str_rstrip_bang(VALUE str) { rb_encoding *enc; char *start; long olen, roffset; str_modify_keep_cr(str); enc = STR_ENC_GET(str); RSTRING_GETMEM(str, start, olen); roffset = rstrip_offset(str, start, start+olen, enc); if (roffset > 0) { long len = olen - roffset; STR_SET_LEN(str, len); #if !SHARABLE_MIDDLE_SUBSTRING TERM_FILL(start+len, rb_enc_mbminlen(enc)); #endif return str; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#delete_prefix!;F;[[I" prefix;T0;[[@i&;T;:delete_prefix!;0;[;{;IC;"Deletes leading prefix from str, returning nil if no change was made. "hello".delete_prefix!("hel") #=> "lo" "hello".delete_prefix!("llo") #=> nil ;T;[o;H ;II" overload;F;J0;;l;K0;#I"delete_prefix!(prefix);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;TI"nil;T; @-;[;I"@return [self, nil];T;0; @-;@F;Mi;N0;[[I" prefix;T0; @-;[;I"Deletes leading prefix from str, returning nil if no change was made. "hello".delete_prefix!("hel") #=> "lo" "hello".delete_prefix!("llo") #=> nil @overload delete_prefix!(prefix) @return [self, nil];T;0; @-;@F;Ao;B;CT;Di|&;Ei&;!@;"I"static VALUE rb_str_delete_prefix_bang(VALUE str, VALUE prefix) { long prefixlen; str_modify_keep_cr(str); prefixlen = deleted_prefix_length(str, prefix); if (prefixlen <= 0) return Qnil; return rb_str_drop_bytes(str, prefixlen); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#delete_suffix!;F;[[I" suffix;T0;[[@i&;T;:delete_suffix!;0;[;{;IC;"Deletes trailing suffix from str, returning nil if no change was made. "hello".delete_suffix!("llo") #=> "he" "hello".delete_suffix!("hel") #=> nil ;T;[o;H ;II" overload;F;J0;;m;K0;#I"delete_suffix!(suffix);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;TI"nil;T; @-;[;I"@return [self, nil];T;0; @-;@F;Mi;N0;[[I" suffix;T0; @-;[;I"Deletes trailing suffix from str, returning nil if no change was made. "hello".delete_suffix!("llo") #=> "he" "hello".delete_suffix!("hel") #=> nil @overload delete_suffix!(suffix) @return [self, nil];T;0; @-;@F;Ao;B;CT;Di&;Ei&;!@;"I"static VALUE rb_str_delete_suffix_bang(VALUE str, VALUE suffix) { long olen, suffixlen, len; str_modifiable(str); suffixlen = deleted_suffix_length(str, suffix); if (suffixlen <= 0) return Qnil; olen = RSTRING_LEN(str); str_modify_keep_cr(str); len = olen - suffixlen; STR_SET_LEN(str, len); TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str)); if (ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) { ENC_CODERANGE_CLEAR(str); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#tr;F;[[I"src;T0[I" repl;T0;[[@i];T;:tr;0;[;{;IC;"Returns a copy of +str+ with the characters in +from_str+ replaced by the corresponding characters in +to_str+. If +to_str+ is shorter than +from_str+, it is padded with its last character in order to maintain the correspondence. "hello".tr('el', 'ip') #=> "hippo" "hello".tr('aeiou', '*') #=> "h*ll*" "hello".tr('aeiou', 'AA*') #=> "hAll*" Both strings may use the c1-c2 notation to denote ranges of characters, and +from_str+ may start with a ^, which denotes all characters except those listed. "hello".tr('a-y', 'b-z') #=> "ifmmp" "hello".tr('^aeiou', '*') #=> "*e**o" The backslash character \\ can be used to escape ^ or - and is otherwise ignored unless it appears at the end of a range or the end of the +from_str+ or +to_str+: "hello^world".tr("\\^aeiou", "*") #=> "h*ll**w*rld" "hello-world".tr("a\\-eo", "*") #=> "h*ll**w*rld" "hello\r\nworld".tr("\r", "") #=> "hello\nworld" "hello\r\nworld".tr("\\r", "") #=> "hello\r\nwold" "hello\r\nworld".tr("\\\r", "") #=> "hello\nworld" "X['\\b']".tr("X\\", "") #=> "['b']" "X['\\b']".tr("X-\\]", "") #=> "'b'" ;T;[o;H ;II" overload;F;J0;;n;K0;#I"tr(from_str, to_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @-;[;I"@return [String];T;0; @-;@F;Mi;N0;[[I" from_str;T0[I" to_str;T0; @-;[;I"Returns a copy of +str+ with the characters in +from_str+ replaced by the corresponding characters in +to_str+. If +to_str+ is shorter than +from_str+, it is padded with its last character in order to maintain the correspondence. "hello".tr('el', 'ip') #=> "hippo" "hello".tr('aeiou', '*') #=> "h*ll*" "hello".tr('aeiou', 'AA*') #=> "hAll*" Both strings may use the c1-c2 notation to denote ranges of characters, and +from_str+ may start with a ^, which denotes all characters except those listed. "hello".tr('a-y', 'b-z') #=> "ifmmp" "hello".tr('^aeiou', '*') #=> "*e**o" The backslash character \\ can be used to escape ^ or - and is otherwise ignored unless it appears at the end of a range or the end of the +from_str+ or +to_str+: "hello^world".tr("\\^aeiou", "*") #=> "h*ll**w*rld" "hello-world".tr("a\\-eo", "*") #=> "h*ll**w*rld" "hello\r\nworld".tr("\r", "") #=> "hello\nworld" "hello\r\nworld".tr("\\r", "") #=> "hello\r\nwold" "hello\r\nworld".tr("\\\r", "") #=> "hello\nworld" "X['\\b']".tr("X\\", "") #=> "['b']" "X['\\b']".tr("X-\\]", "") #=> "'b'" @overload tr(from_str, to_str) @return [String];T;0; @-;@F;Ao;B;CT;Di:;EiZ;!@;"I"static VALUE rb_str_tr(VALUE str, VALUE src, VALUE repl) { str = rb_str_dup(str); tr_trans(str, src, repl, 0); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#tr_s;F;[[I"src;T0[I" repl;T0;[[@i;T;: tr_s;0;[;{;IC;"Processes a copy of str as described under String#tr, then removes duplicate characters in regions that were affected by the translation. "hello".tr_s('l', 'r') #=> "hero" "hello".tr_s('el', '*') #=> "h*o" "hello".tr_s('el', 'hx') #=> "hhxo" ;T;[o;H ;II" overload;F;J0;;o;K0;#I"tr_s(from_str, to_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @.;[;I"@return [String];T;0; @.;@F;Mi;N0;[[I" from_str;T0[I" to_str;T0; @.;[;I"NProcesses a copy of str as described under String#tr, then removes duplicate characters in regions that were affected by the translation. "hello".tr_s('l', 'r') #=> "hero" "hello".tr_s('el', '*') #=> "h*o" "hello".tr_s('el', 'hx') #=> "hhxo" @overload tr_s(from_str, to_str) @return [String];T;0; @.;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_tr_s(VALUE str, VALUE src, VALUE repl) { str = rb_str_dup(str); tr_trans(str, src, repl, 1); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#delete;F;[[@0;[[@i;T;: delete;0;[;{;IC;"cReturns a copy of str with all characters in the intersection of its arguments deleted. Uses the same rules for building the set of characters as String#count. "hello".delete "l","lo" #=> "heo" "hello".delete "lo" #=> "he" "hello".delete "aeiou", "^e" #=> "hell" "hello".delete "ej-m" #=> "ho" ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete([other_str]+);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @8.;[;I"@return [String];T;0; @8.;@F;Mi;N0;[[I"[other_str];T0; @8.;[;I"Returns a copy of str with all characters in the intersection of its arguments deleted. Uses the same rules for building the set of characters as String#count. "hello".delete "l","lo" #=> "heo" "hello".delete "lo" #=> "he" "hello".delete "aeiou", "^e" #=> "hell" "hello".delete "ej-m" #=> "ho" @overload delete([other_str]+) @return [String];T;0; @8.;@F;Ao;B;CT;Di;Ei ;!@;"I"static VALUE rb_str_delete(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); rb_str_delete_bang(argc, argv, str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#squeeze;F;[[@0;[[@i|;T;: squeeze;0;[;{;IC;"Builds a set of characters from the other_str parameter(s) using the procedure described for String#count. Returns a new string where runs of the same character that occur in this set are replaced by a single character. If no arguments are given, all runs of identical characters are replaced by a single character. "yellow moon".squeeze #=> "yelow mon" " now is the".squeeze(" ") #=> " now is the" "putters shoot balls".squeeze("m-z") #=> "puters shot balls" ;T;[o;H ;II" overload;F;J0;;q;K0;#I"squeeze([other_str]*);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @V.;[;I"@return [String];T;0; @V.;@F;Mi;N0;[[I"[other_str];T0; @V.;[;I"=Builds a set of characters from the other_str parameter(s) using the procedure described for String#count. Returns a new string where runs of the same character that occur in this set are replaced by a single character. If no arguments are given, all runs of identical characters are replaced by a single character. "yellow moon".squeeze #=> "yelow mon" " now is the".squeeze(" ") #=> " now is the" "putters shoot balls".squeeze("m-z") #=> "puters shot balls" @overload squeeze([other_str]*) @return [String];T;0; @V.;@F;Ao;B;CT;Dim;Eiy;!@;"I"static VALUE rb_str_squeeze(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); rb_str_squeeze_bang(argc, argv, str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#count;F;[[@0;[[@i;T;: count;0;[;{;IC;"tEach +other_str+ parameter defines a set of characters to count. The intersection of these sets defines the characters to count in +str+. Any +other_str+ that starts with a caret ^ is negated. The sequence c1-c2 means all characters between c1 and c2. The backslash character \\ can be used to escape ^ or - and is otherwise ignored unless it appears at the end of a sequence or the end of a +other_str+. a = "hello world" a.count "lo" #=> 5 a.count "lo", "o" #=> 2 a.count "hello", "^l" #=> 4 a.count "ej-m" #=> 4 "hello^world".count "\\^aeiou" #=> 4 "hello-world".count "a\\-eo" #=> 4 c = "hello world\\r\\n" c.count "\\" #=> 2 c.count "\\A" #=> 0 c.count "X-\\w" #=> 3 ;T;[o;H ;II" overload;F;J0;;r;K0;#I"count([other_str]+);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @t.;[;I"@return [Integer];T;0; @t.;@F;Mi;N0;[[I"[other_str];T0; @t.;[;I"Each +other_str+ parameter defines a set of characters to count. The intersection of these sets defines the characters to count in +str+. Any +other_str+ that starts with a caret ^ is negated. The sequence c1-c2 means all characters between c1 and c2. The backslash character \\ can be used to escape ^ or - and is otherwise ignored unless it appears at the end of a sequence or the end of a +other_str+. a = "hello world" a.count "lo" #=> 5 a.count "lo", "o" #=> 2 a.count "hello", "^l" #=> 4 a.count "ej-m" #=> 4 "hello^world".count "\\^aeiou" #=> 4 "hello-world".count "a\\-eo" #=> 4 c = "hello world\\r\\n" c.count "\\" #=> 2 c.count "\\A" #=> 0 c.count "X-\\w" #=> 3 @overload count([other_str]+) @return [Integer];T;0; @t.;@F;Ao;B;CT;Di;Ei;!@;"I"`static VALUE rb_str_count(int argc, VALUE *argv, VALUE str) { char table[TR_TABLE_SIZE]; rb_encoding *enc = 0; VALUE del = 0, nodel = 0, tstr; char *s, *send; int i; int ascompat; rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); tstr = argv[0]; StringValue(tstr); enc = rb_enc_check(str, tstr); if (argc == 1) { const char *ptstr; if (RSTRING_LEN(tstr) == 1 && rb_enc_asciicompat(enc) && (ptstr = RSTRING_PTR(tstr), ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc, (const unsigned char *)ptstr, (const unsigned char *)ptstr+1)) && !is_broken_string(str)) { int n = 0; int clen; unsigned char c = rb_enc_codepoint_len(ptstr, ptstr+1, &clen, enc); s = RSTRING_PTR(str); if (!s || RSTRING_LEN(str) == 0) return INT2FIX(0); send = RSTRING_END(str); while (s < send) { if (*(unsigned char*)s++ == c) n++; } return INT2NUM(n); } } tr_setup_table(tstr, table, TRUE, &del, &nodel, enc); for (i=1; istr in place, using the same rules as String#tr. Returns str, or nil if no changes were made. ;T;[o;H ;II" overload;F;J0;;s;K0;#I"tr!(from_str, to_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @.;[;I"@return [String, nil];T;0; @.;@F;Mi;N0;[[I" from_str;T0[I" to_str;T0; @.;[;I"Translates str in place, using the same rules as String#tr. Returns str, or nil if no changes were made. @overload tr!(from_str, to_str) @return [String, nil];T;0; @.;@F;Ao;B;CT;Di*;Ei0;!@;"I"nstatic VALUE rb_str_tr_bang(VALUE str, VALUE src, VALUE repl) { return tr_trans(str, src, repl, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#tr_s!;F;[[I"src;T0[I" repl;T0;[[@i;T;: tr_s!;0;[;{;IC;"Performs String#tr_s processing on str in place, returning str, or nil if no changes were made. ;T;[o;H ;II" overload;F;J0;;t;K0;#I"tr_s!(from_str, to_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @.;[;I"@return [String, nil];T;0; @.;@F;Mi;N0;[[I" from_str;T0[I" to_str;T0; @.;[;I"Performs String#tr_s processing on str in place, returning str, or nil if no changes were made. @overload tr_s!(from_str, to_str) @return [String, nil];T;0; @.;@F;Ao;B;CT;Di;Ei;!@;"I"pstatic VALUE rb_str_tr_s_bang(VALUE str, VALUE src, VALUE repl) { return tr_trans(str, src, repl, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#delete!;F;[[@0;[[@i;T;: delete!;0;[;{;IC;"|Performs a delete operation in place, returning str, or nil if str was not modified. ;T;[o;H ;II" overload;F;J0;;u;K0;#I"delete!([other_str]+);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @.;[;I"@return [String, nil];T;0; @.;@F;Mi;N0;[[I"[other_str];T0; @.;[;I"Performs a delete operation in place, returning str, or nil if str was not modified. @overload delete!([other_str]+) @return [String, nil];T;0; @.;@F;Ao;B;CT;Di;Ei;!@;"I"3static VALUE rb_str_delete_bang(int argc, VALUE *argv, VALUE str) { char squeez[TR_TABLE_SIZE]; rb_encoding *enc = 0; char *s, *send, *t; VALUE del = 0, nodel = 0; int modify = 0; int i, ascompat, cr; if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil; rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); for (i=0; istr in place, returning either str, or nil if no changes were made. ;T;[o;H ;II" overload;F;J0;;v;K0;#I"squeeze!([other_str]*);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @.;[;I"@return [String, nil];T;0; @.;@F;Mi;N0;[[I"[other_str];T0; @.;[;I"Squeezes str in place, returning either str, or nil if no changes were made. @overload squeeze!([other_str]*) @return [String, nil];T;0; @.;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str) { char squeez[TR_TABLE_SIZE]; rb_encoding *enc = 0; VALUE del = 0, nodel = 0; unsigned char *s, *send, *t; int i, modify = 0; int ascompat, singlebyte = single_byte_optimizable(str); unsigned int save; if (argc == 0) { enc = STR_ENC_GET(str); } else { for (i=0; i 0 && !squeez[c])) { *t++ = save = c; } } } else { while (s < send) { unsigned int c; int clen; if (ascompat && (c = *s) < 0x80) { if (c != save || (argc > 0 && !squeez[c])) { *t++ = save = c; } s++; } else { c = rb_enc_codepoint_len((char *)s, (char *)send, &clen, enc); if (c != save || (argc > 0 && !tr_find(c, squeez, del, nodel))) { if (t != s) rb_enc_mbcput(c, t, enc); save = c; t += clen; } s += clen; } } } TERM_FILL((char *)t, TERM_LEN(str)); if ((char *)t - RSTRING_PTR(str) != RSTRING_LEN(str)) { STR_SET_LEN(str, (char *)t - RSTRING_PTR(str)); modify = 1; } if (modify) return str; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#each_line;F;[[@0;[[@i1 ;T;:each_line;0;[;{;IC;"Splits str using the supplied parameter as the record separator ($/ by default), passing each substring in turn to the supplied block. If a zero-length record separator is supplied, the string is split into paragraphs delimited by multiple successive newlines. See IO.readlines for details about getline_args. If no block is given, an enumerator is returned instead. print "Example one\n" "hello\nworld".each_line {|s| p s} print "Example two\n" "hello\nworld".each_line('l') {|s| p s} print "Example three\n" "hello\n\n\nworld".each_line('') {|s| p s} produces: Example one "hello\n" "world" Example two "hel" "l" "o\nworl" "d" Example three "hello\n\n" "world" ;T;[o;H ;II" overload;F;J0;;w;K0;#I"-each_line(separator=$/ [, getline_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" substr;T; @/o;L ;II" return;F;JI";T;0;K[I" String;T; @/;[;I"%@yield [substr] @return [String];T;0; @/;@F;Mi;N0;[[I"separator;TI"$/[, getline_args];T; @/o;H ;II" overload;F;J0;;w;K0;#I"-each_line(separator=$/ [, getline_args]);T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[[I"separator;TI"$/[, getline_args];T; @/;[;I"ySplits str using the supplied parameter as the record separator ($/ by default), passing each substring in turn to the supplied block. If a zero-length record separator is supplied, the string is split into paragraphs delimited by multiple successive newlines. See IO.readlines for details about getline_args. If no block is given, an enumerator is returned instead. print "Example one\n" "hello\nworld".each_line {|s| p s} print "Example two\n" "hello\nworld".each_line('l') {|s| p s} print "Example three\n" "hello\n\n\nworld".each_line('') {|s| p s} produces: Example one "hello\n" "world" Example two "hel" "l" "o\nworl" "d" Example three "hello\n\n" "world" @overload each_line(separator=$/ [, getline_args]) @yield [substr] @return [String] @overload each_line(separator=$/ [, getline_args]);T;0; @/;@F;Ao;B;CT;Di ;Ei/ ;!@;"I"static VALUE rb_str_each_line(int argc, VALUE *argv, VALUE str) { RETURN_SIZED_ENUMERATOR(str, argc, argv, 0); return rb_str_enumerate_lines(argc, argv, str, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#each_byte;F;[;[[@it ;T;:each_byte;0;[;{;IC;"Passes each byte in str to the given block, or returns an enumerator if no block is given. "hello".each_byte {|c| print c, ' ' } produces: 104 101 108 108 111 ;T;[o;H ;II" overload;F;J0;;x;K0;#I"each_byte;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" integer;T; @G/o;L ;II" return;F;JI";T;0;K[I" String;T; @G/;[;I"&@yield [integer] @return [String];T;0; @G/;@F;Mi;N0;[; @G/o;H ;II" overload;F;J0;;x;K0;#I"each_byte;T;IC;";T;[;[;I";T;0; @G/;@F;Mi;N0;[; @G/;[;I"Passes each byte in str to the given block, or returns an enumerator if no block is given. "hello".each_byte {|c| print c, ' ' } produces: 104 101 108 108 111 @overload each_byte @yield [integer] @return [String] @overload each_byte;T;0; @G/;@F;Ao;B;CT;Die ;Eir ;!@;"I"static VALUE rb_str_each_byte(VALUE str) { RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_byte_size); return rb_str_enumerate_bytes(str, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#each_char;F;[;[[@i ;T;:each_char;0;[;{;IC;"Passes each character in str to the given block, or returns an enumerator if no block is given. "hello".each_char {|c| print c, ' ' } produces: h e l l o ;T;[o;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" cstr;T; @o/o;L ;II" return;F;JI";T;0;K[I" String;T; @o/;[;I"#@yield [cstr] @return [String];T;0; @o/;@F;Mi;N0;[; @o/o;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[;[;I";T;0; @o/;@F;Mi;N0;[; @o/;[;I"Passes each character in str to the given block, or returns an enumerator if no block is given. "hello".each_char {|c| print c, ' ' } produces: h e l l o @overload each_char @yield [cstr] @return [String] @overload each_char;T;0; @o/;@F;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE rb_str_each_char(VALUE str) { RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_char_size); return rb_str_enumerate_chars(str, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#each_codepoint;F;[;[[@i !;T;:each_codepoint;0;[;{;IC;"Passes the Integer ordinal of each character in str, also known as a codepoint when applied to Unicode strings to the given block. For encodings other than UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE), values are directly derived from the binary representation of each character. If no block is given, an enumerator is returned instead. "hello\u0639".each_codepoint {|c| print c, ' ' } produces: 104 101 108 108 111 1593 ;T;[o;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" integer;T; @/o;L ;II" return;F;JI";T;0;K[I" String;T; @/;[;I"&@yield [integer] @return [String];T;0; @/;@F;Mi;N0;[; @/o;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[; @/;[;I""Passes the Integer ordinal of each character in str, also known as a codepoint when applied to Unicode strings to the given block. For encodings other than UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE), values are directly derived from the binary representation of each character. If no block is given, an enumerator is returned instead. "hello\u0639".each_codepoint {|c| print c, ' ' } produces: 104 101 108 108 111 1593 @overload each_codepoint @yield [integer] @return [String] @overload each_codepoint;T;0; @/;@F;Ao;B;CT;Di ;Ei !;!@;"I"static VALUE rb_str_each_codepoint(VALUE str) { RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_char_size); return rb_str_enumerate_codepoints(str, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!String#each_grapheme_cluster;F;[;[[@i!;T;:each_grapheme_cluster;0;[;{;IC;"MPasses each grapheme cluster in str to the given block, or returns an enumerator if no block is given. Unlike String#each_char, this enumerates by grapheme clusters defined by Unicode Standard Annex #29 http://unicode.org/reports/tr29/ "a\u0300".each_char.to_a.size #=> 2 "a\u0300".each_grapheme_cluster.to_a.size #=> 1 ;T;[o;H ;II" overload;F;J0;;{;K0;#I"each_grapheme_cluster;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" cstr;T; @/o;L ;II" return;F;JI";T;0;K[I" String;T; @/;[;I"#@yield [cstr] @return [String];T;0; @/;@F;Mi;N0;[; @/o;H ;II" overload;F;J0;;{;K0;#I"each_grapheme_cluster;T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[; @/;[;I"Passes each grapheme cluster in str to the given block, or returns an enumerator if no block is given. Unlike String#each_char, this enumerates by grapheme clusters defined by Unicode Standard Annex #29 http://unicode.org/reports/tr29/ "a\u0300".each_char.to_a.size #=> 2 "a\u0300".each_grapheme_cluster.to_a.size #=> 1 @overload each_grapheme_cluster @yield [cstr] @return [String] @overload each_grapheme_cluster;T;0; @/;@F;Ao;B;CT;Di!;Ei!;!@;"I"static VALUE rb_str_each_grapheme_cluster(VALUE str) { RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_grapheme_cluster_size); return rb_str_enumerate_grapheme_clusters(str, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#sum;F;[[@0;[[@i$;T;:sum;0;[;{;IC;"/Returns a basic n-bit checksum of the characters in str, where n is the optional Integer parameter, defaulting to 16. The result is simply the sum of the binary value of each byte in str modulo 2**n - 1. This is not a particularly good checksum. ;T;[o;H ;II" overload;F;J0;;|;K0;#I"sum(n=16);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @/;[;I"@return [Integer];T;0; @/;@F;Mi;N0;[[I"n;TI"16;T; @/;[;I"YReturns a basic n-bit checksum of the characters in str, where n is the optional Integer parameter, defaulting to 16. The result is simply the sum of the binary value of each byte in str modulo 2**n - 1. This is not a particularly good checksum. @overload sum(n=16) @return [Integer];T;0; @/;@F;Ao;B;CT;Di$;Ei$;!@;"I"static VALUE rb_str_sum(int argc, VALUE *argv, VALUE str) { int bits = 16; char *ptr, *p, *pend; long len; VALUE sum = INT2FIX(0); unsigned long sum0 = 0; if (rb_check_arity(argc, 0, 1) && (bits = NUM2INT(argv[0])) < 0) { bits = 0; } ptr = p = RSTRING_PTR(str); len = RSTRING_LEN(str); pend = p + len; while (p < pend) { if (FIXNUM_MAX - UCHAR_MAX < sum0) { sum = rb_funcall(sum, '+', 1, LONG2FIX(sum0)); str_mod_check(str, ptr, len); sum0 = 0; } sum0 += (unsigned char)*p; p++; } if (bits == 0) { if (sum0) { sum = rb_funcall(sum, '+', 1, LONG2FIX(sum0)); } } else { if (sum == INT2FIX(0)) { if (bits < (int)sizeof(long)*CHAR_BIT) { sum0 &= (((unsigned long)1)< "e" a[2, 3] #=> "llo" a[2..3] #=> "ll" a[-3, 2] #=> "er" a[7..-2] #=> "her" a[-4..-2] #=> "her" a[-2..-4] #=> "" a[11, 0] #=> "" a[11] #=> nil a[12, 0] #=> nil a[12..-1] #=> nil a[/[aeiou](.)\1/] #=> "ell" a[/[aeiou](.)\1/, 0] #=> "ell" a[/[aeiou](.)\1/, 1] #=> "l" a[/[aeiou](.)\1/, 2] #=> nil a[/(?[aeiou])(?[^aeiou])/, "non_vowel"] #=> "l" a[/(?[aeiou])(?[^aeiou])/, "vowel"] #=> "e" a["lo"] #=> "lo" a["bye"] #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"[](index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" index;T0; @0o;H ;II" overload;F;J0;;;K0;#I"[](start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" start;T0[I" length;T0; @0o;H ;II" overload;F;J0;;;K0;#I"[](range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" range;T0; @0o;H ;II" overload;F;J0;;;K0;#I"[](regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" regexp;T0; @0o;H ;II" overload;F;J0;;;K0;#I"[](regexp, capture);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" regexp;T0[I" capture;T0; @0o;H ;II" overload;F;J0;;;K0;#I"[](match_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I"match_str;T0; @0o;H ;II" overload;F;J0;;;K0;#I"slice(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" index;T0; @0o;H ;II" overload;F;J0;;;K0;#I"slice(start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" start;T0[I" length;T0; @0o;H ;II" overload;F;J0;;;K0;#I"slice(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" range;T0; @0o;H ;II" overload;F;J0;;;K0;#I"slice(regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" regexp;T0; @0o;H ;II" overload;F;J0;;;K0;#I"slice(regexp, capture);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" regexp;T0[I" capture;T0; @0o;H ;II" overload;F;J0;;;K0;#I"slice(match_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I"match_str;T0; @0;[;@!;0; @0;@F;Ao;B;CT;Di;Ei;!@;"I"vstatic VALUE rb_str_aref_m(int argc, VALUE *argv, VALUE str) { if (argc == 2) { if (RB_TYPE_P(argv[0], T_REGEXP)) { return rb_str_subpat(str, argv[0], argv[1]); } else { long beg = NUM2LONG(argv[0]); long len = NUM2LONG(argv[1]); return rb_str_substr(str, beg, len); } } rb_check_arity(argc, 1, 2); return rb_str_aref(str, argv[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#slice!;F;[[@0;[[@i";T;: slice!;0;[;{;IC;")Deletes the specified portion from str, and returns the portion deleted. string = "this is a string" string.slice!(2) #=> "i" string.slice!(3..6) #=> " is " string.slice!(/s.*t/) #=> "sa st" string.slice!("r") #=> "r" string #=> "thing" ;T;[ o;H ;II" overload;F;J0;;};K0;#I"slice!(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" integer;T0; @0o;H ;II" overload;F;J0;;};K0;#I"slice!(integer, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" integer;T0[I" integer;T0; @0o;H ;II" overload;F;J0;;};K0;#I"slice!(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" range;T0; @0o;H ;II" overload;F;J0;;};K0;#I"slice!(regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I" regexp;T0; @0o;H ;II" overload;F;J0;;};K0;#I"slice!(other_str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I"other_str;T0; @0;[;I"-Deletes the specified portion from str, and returns the portion deleted. string = "this is a string" string.slice!(2) #=> "i" string.slice!(3..6) #=> " is " string.slice!(/s.*t/) #=> "sa st" string.slice!("r") #=> "r" string #=> "thing" @overload slice!(integer) @return [String, nil] @overload slice!(integer, integer) @return [String, nil] @overload slice!(range) @return [String, nil] @overload slice!(regexp) @return [String, nil] @overload slice!(other_str) @return [String, nil];T;0; @0;@F;Ao;B;CT;Di;Ei#;!@;"I"static VALUE rb_str_slice_bang(int argc, VALUE *argv, VALUE str) { VALUE result; VALUE buf[3]; int i; rb_check_arity(argc, 1, 2); for (i=0; isep or pattern (regexp) in the string and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str. "hello".partition("l") #=> ["he", "l", "lo"] "hello".partition("x") #=> ["hello", "", ""] "hello".partition(/.l/) #=> ["h", "el", "lo"] ;T;[o;H ;II" overload;F;J0;;~;K0;#I"partition(sep);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @=1;[;I"@return [Array];T;0; @=1;@F;Mi;N0;[[I"sep;T0; @=1o;H ;II" overload;F;J0;;~;K0;#I"partition(regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @=1;[;I"@return [Array];T;0; @=1;@F;Mi;N0;[[I" regexp;T0; @=1;[;I"Searches sep or pattern (regexp) in the string and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str. "hello".partition("l") #=> ["he", "l", "lo"] "hello".partition("x") #=> ["hello", "", ""] "hello".partition(/.l/) #=> ["h", "el", "lo"] @overload partition(sep) @return [Array] @overload partition(regexp) @return [Array];T;0; @=1;@F;Ao;B;CT;Di%;Ei%;!@;"I"static VALUE rb_str_partition(VALUE str, VALUE sep) { long pos; sep = get_pat_quoted(sep, 0); if (RB_TYPE_P(sep, T_REGEXP)) { pos = rb_reg_search(sep, str, 0, 0); if (pos < 0) { failed: return rb_ary_new3(3, rb_str_dup(str), str_new_empty(str), str_new_empty(str)); } sep = rb_str_subpat(str, sep, INT2FIX(0)); if (pos == 0 && RSTRING_LEN(sep) == 0) goto failed; } else { pos = rb_str_index(str, sep, 0); if (pos < 0) goto failed; } return rb_ary_new3(3, rb_str_subseq(str, 0, pos), sep, rb_str_subseq(str, pos+RSTRING_LEN(sep), RSTRING_LEN(str)-pos-RSTRING_LEN(sep))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#rpartition;F;[[I"sep;T0;[[@i%;T;:rpartition;0;[;{;IC;"Searches sep or pattern (regexp) in the string from the end of the string, and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str. "hello".rpartition("l") #=> ["hel", "l", "o"] "hello".rpartition("x") #=> ["", "", "hello"] "hello".rpartition(/.l/) #=> ["he", "ll", "o"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"rpartition(sep);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @k1;[;I"@return [Array];T;0; @k1;@F;Mi;N0;[[I"sep;T0; @k1o;H ;II" overload;F;J0;;;K0;#I"rpartition(regexp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @k1;[;I"@return [Array];T;0; @k1;@F;Mi;N0;[[I" regexp;T0; @k1;[;I"Searches sep or pattern (regexp) in the string from the end of the string, and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str. "hello".rpartition("l") #=> ["hel", "l", "o"] "hello".rpartition("x") #=> ["", "", "hello"] "hello".rpartition(/.l/) #=> ["he", "ll", "o"] @overload rpartition(sep) @return [Array] @overload rpartition(regexp) @return [Array];T;0; @k1;@F;Ao;B;CT;Di%;Ei%;!@;"I"`static VALUE rb_str_rpartition(VALUE str, VALUE sep) { long pos = RSTRING_LEN(str); int regex = FALSE; if (RB_TYPE_P(sep, T_REGEXP)) { pos = rb_reg_search(sep, str, pos, 1); regex = TRUE; } else { VALUE tmp; tmp = rb_check_string_type(sep); if (NIL_P(tmp)) { rb_raise(rb_eTypeError, "type mismatch: %s given", rb_obj_classname(sep)); } sep = tmp; pos = rb_str_sublen(str, pos); pos = rb_str_rindex(str, sep, pos); } if (pos < 0) { return rb_ary_new3(3, str_new_empty(str), str_new_empty(str), rb_str_dup(str)); } if (regex) { sep = rb_reg_nth_match(0, rb_backref_get()); } else { pos = rb_str_offset(str, pos); } return rb_ary_new3(3, rb_str_subseq(str, 0, pos), sep, rb_str_subseq(str, pos+RSTRING_LEN(sep), RSTRING_LEN(str)-pos-RSTRING_LEN(sep))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#encoding;F;[;[[@li;T;;;0;[;{;IC;"EReturns the Encoding object that represents the encoding of obj. ;T;[o;H ;II" overload;F;J0;;;K0;#I" encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @1;[;I"@return [Encoding];T;0; @1;@F;Mi;N0;[; @1;[;@;0; @1;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"String#force_encoding;F;[[I"enc;T0;[[@i';T;:force_encoding;0;[;{;IC;"9Changes the encoding to +encoding+ and returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I"force_encoding(encoding);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @1;[;I"@return [String];T;0; @1;@F;Mi;N0;[[I" encoding;T0; @1;[;I"qChanges the encoding to +encoding+ and returns self. @overload force_encoding(encoding) @return [String];T;0; @1;@F;Ao;B;CT;Di';Ei';!@;"I"static VALUE rb_str_force_encoding(VALUE str, VALUE enc) { str_modifiable(str); rb_enc_associate(str, rb_to_encoding(enc)); ENC_CODERANGE_CLEAR(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" String#b;F;[;[[@i+';T;:b;0;[;{;IC;":Returns a copied string whose encoding is ASCII-8BIT. ;T;[o;H ;II" overload;F;J0;;;K0;#I"b;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @1;[;I"@return [String];T;0; @1;@F;Mi;N0;[; @1;[;I"[Returns a copied string whose encoding is ASCII-8BIT. @overload b @return [String];T;0; @1;@F;Ao;B;CT;Di$';Ei(';!@;"I"static VALUE rb_str_b(VALUE str) { VALUE str2 = str_alloc(rb_cString); str_replace_shared_without_enc(str2, str); OBJ_INFECT_RAW(str2, str); ENC_CODERANGE_CLEAR(str2); return str2; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#valid_encoding?;F;[;[[@i@';T;:valid_encoding?;0;[;{;IC;"Returns true for a string which is encoded correctly. "\xc2\xa1".force_encoding("UTF-8").valid_encoding? #=> true "\xc2".force_encoding("UTF-8").valid_encoding? #=> false "\x80".force_encoding("UTF-8").valid_encoding? #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I"valid_encoding?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[; @1;[;I"%Returns true for a string which is encoded correctly. "\xc2\xa1".force_encoding("UTF-8").valid_encoding? #=> true "\xc2".force_encoding("UTF-8").valid_encoding? #=> false "\x80".force_encoding("UTF-8").valid_encoding? #=> false @overload valid_encoding? @return [Boolean];T;0; @1;@F;Ao;B;CT;Di5';Ei=';Mi;!@;"I"static VALUE rb_str_valid_encoding_p(VALUE str) { int cr = rb_enc_str_coderange(str); return cr == ENC_CODERANGE_BROKEN ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#ascii_only?;F;[;[[@iR';T;:ascii_only?;0;[;{;IC;"Returns true for a string which has only ASCII characters. "abc".force_encoding("UTF-8").ascii_only? #=> true "abc\u{6666}".force_encoding("UTF-8").ascii_only? #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I"ascii_only?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @2;[;I"@return [Boolean];T;0; @2;@F;Mi;N0;[; @2;[;I"Returns true for a string which has only ASCII characters. "abc".force_encoding("UTF-8").ascii_only? #=> true "abc\u{6666}".force_encoding("UTF-8").ascii_only? #=> false @overload ascii_only? @return [Boolean];T;0; @2;@F;Ao;B;CT;DiH';EiO';Mi;!@;"I"static VALUE rb_str_is_ascii_only_p(VALUE str) { int cr = rb_enc_str_coderange(str); return cr == ENC_CODERANGE_7BIT ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#unicode_normalize;F;[[@0;[[@i);T;:unicode_normalize;0;[;{;IC;"VUnicode Normalization---Returns a normalized form of +str+, using Unicode normalizations NFC, NFD, NFKC, or NFKD. The normalization form used is determined by +form+, which can be any of the four values +:nfc+, +:nfd+, +:nfkc+, or +:nfkd+. The default is +:nfc+. If the string is not in a Unicode Encoding, then an Exception is raised. In this context, 'Unicode Encoding' means any of UTF-8, UTF-16BE/LE, and UTF-32BE/LE, as well as GB18030, UCS_2BE, and UCS_4BE. Anything other than UTF-8 is implemented by converting to UTF-8, which makes it slower than UTF-8. "a\u0300".unicode_normalize #=> "\u00E0" "a\u0300".unicode_normalize(:nfc) #=> "\u00E0" "\u00E0".unicode_normalize(:nfd) #=> "a\u0300" "\xE0".force_encoding('ISO-8859-1').unicode_normalize(:nfd) #=> Encoding::CompatibilityError raised ;T;[o;H ;II" overload;F;J0;;;K0;#I"!unicode_normalize(form=:nfc);T;IC;";T;[;[;I";T;0; @#2;@F;Mi;N0;[[I" form;TI" :nfc;T; @#2;[;I"Unicode Normalization---Returns a normalized form of +str+, using Unicode normalizations NFC, NFD, NFKC, or NFKD. The normalization form used is determined by +form+, which can be any of the four values +:nfc+, +:nfd+, +:nfkc+, or +:nfkd+. The default is +:nfc+. If the string is not in a Unicode Encoding, then an Exception is raised. In this context, 'Unicode Encoding' means any of UTF-8, UTF-16BE/LE, and UTF-32BE/LE, as well as GB18030, UCS_2BE, and UCS_4BE. Anything other than UTF-8 is implemented by converting to UTF-8, which makes it slower than UTF-8. "a\u0300".unicode_normalize #=> "\u00E0" "a\u0300".unicode_normalize(:nfc) #=> "\u00E0" "\u00E0".unicode_normalize(:nfd) #=> "a\u0300" "\xE0".force_encoding('ISO-8859-1').unicode_normalize(:nfd) #=> Encoding::CompatibilityError raised @overload unicode_normalize(form=:nfc);T;0; @#2;@F;Ao;B;CT;Di(;Ei);!@;"I"static VALUE rb_str_unicode_normalize(int argc, VALUE *argv, VALUE str) { return unicode_normalize_common(argc, argv, str, id_normalize); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#unicode_normalize!;F;[[@0;[[@i);T;:unicode_normalize!;0;[;{;IC;"[Destructive version of String#unicode_normalize, doing Unicode normalization in place. ;T;[o;H ;II" overload;F;J0;;;K0;#I""unicode_normalize!(form=:nfc);T;IC;";T;[;[;I";T;0; @=2;@F;Mi;N0;[[I" form;TI" :nfc;T; @=2;[;I"Destructive version of String#unicode_normalize, doing Unicode normalization in place. @overload unicode_normalize!(form=:nfc);T;0; @=2;@F;Ao;B;CT;Di );Ei);!@;"I"static VALUE rb_str_unicode_normalize_bang(int argc, VALUE *argv, VALUE str) { return rb_str_replace(str, unicode_normalize_common(argc, argv, str, id_normalize)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#unicode_normalized?;F;[[@0;[[@i();T;:unicode_normalized?;0;[;{;IC;"^Checks whether +str+ is in Unicode normalization form +form+, which can be any of the four values +:nfc+, +:nfd+, +:nfkc+, or +:nfkd+. The default is +:nfc+. If the string is not in a Unicode Encoding, then an Exception is raised. For details, see String#unicode_normalize. "a\u0300".unicode_normalized? #=> false "a\u0300".unicode_normalized?(:nfd) #=> true "\u00E0".unicode_normalized? #=> true "\u00E0".unicode_normalized?(:nfd) #=> false "\xE0".force_encoding('ISO-8859-1').unicode_normalized? #=> Encoding::CompatibilityError raised;T;[o;H ;II" overload;F;J0;;;K0;#I"#unicode_normalized?(form=:nfc);T;IC;";T;[;[;I";T;0; @W2;@F;Mi;N0;[[I" form;TI" :nfc;T; @W2o;L ;II" return;F;J@;0;K[@; @W2;[;I"Checks whether +str+ is in Unicode normalization form +form+, which can be any of the four values +:nfc+, +:nfd+, +:nfkc+, or +:nfkd+. The default is +:nfc+. If the string is not in a Unicode Encoding, then an Exception is raised. For details, see String#unicode_normalize. "a\u0300".unicode_normalized? #=> false "a\u0300".unicode_normalized?(:nfd) #=> true "\u00E0".unicode_normalized? #=> true "\u00E0".unicode_normalized?(:nfd) #=> false "\xE0".force_encoding('ISO-8859-1').unicode_normalized? #=> Encoding::CompatibilityError raised @overload unicode_normalized?(form=:nfc);T;0; @W2;@F;Ao;B;CT;Di);Ei&);Mi;!@;"I"static VALUE rb_str_unicode_normalized_p(int argc, VALUE *argv, VALUE str) { return unicode_normalize_common(argc, argv, str, id_normalized_p); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#str2big_poweroftwo;F;[[I" vbase;T0[I" badcheck;T0;[[I" ext/-test-/bignum/str2big.c;Ti;T;:str2big_poweroftwo;0;[;{;IC;" ;T;[;[;@;0; @t2;!@;"I"static VALUE str2big_poweroftwo(VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_poweroftwo(str, NUM2INT(vbase), RTEST(badcheck)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#str2big_normal;F;[[I" vbase;T0[I" badcheck;T0;[[@}2i;T;:str2big_normal;0;[;{;IC;" ;T;[;[;@;0; @2;!@;"I"static VALUE str2big_normal(VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_normal(str, NUM2INT(vbase), RTEST(badcheck)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#str2big_karatsuba;F;[[I" vbase;T0[I" badcheck;T0;[[@}2i;T;:str2big_karatsuba;0;[;{;IC;" ;T;[;[;@;0; @2;!@;"I"static VALUE str2big_karatsuba(VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_karatsuba(str, NUM2INT(vbase), RTEST(badcheck)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#str2big_gmp;F;[[I" vbase;T0[I" badcheck;T0;[[@}2i;T;:str2big_gmp;0;[;{;IC;" ;T;[;[;@;0; @2;!@;"I"static VALUE str2big_gmp(VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_gmp(str, NUM2INT(vbase), RTEST(badcheck)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#to_r;F;[;[[@ i ;T;: to_r;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;H ;II" overload;F;J0;;;K0;#I" to_r;T;IC;";T;[;[;I";T;0; @2;@F;Mi;N0;[; @2;[;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; @2;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"String#unpack;F;[[I"fmt;T0;[[I" pack.c;Tix;T;: unpack;0;[;{;IC;"Decodes str (which may contain binary data) according to the format string, returning an array of each value extracted. The format string consists of a sequence of single-character directives, summarized in the table at the end of this entry. Each directive may be followed by a number, indicating the number of times to repeat with this directive. An asterisk (``*'') will use up all remaining elements. The directives sSiIlL may each be followed by an underscore (``_'') or exclamation mark (``!'') to use the underlying platform's native size for the specified type; otherwise, it uses a platform-independent consistent size. Spaces are ignored in the format string. See also String#unpack1, Array#pack. "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "] "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"] "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "] "aa".unpack('b8B8') #=> ["10000110", "01100001"] "aaa".unpack('h2H2c') #=> ["16", "61", 97] "\xfe\xff\xfe\xff".unpack('sS') #=> [-2, 65534] "now=20is".unpack('M*') #=> ["now is"] "whole".unpack('xax2aX2aX1aX2a') #=> ["h", "e", "l", "l", "o"] This table summarizes the various formats and the Ruby classes returned by each. Integer | | Directive | Returns | Meaning ------------------------------------------------------------------ C | Integer | 8-bit unsigned (unsigned char) S | Integer | 16-bit unsigned, native endian (uint16_t) L | Integer | 32-bit unsigned, native endian (uint32_t) Q | Integer | 64-bit unsigned, native endian (uint64_t) J | Integer | pointer width unsigned, native endian (uintptr_t) | | c | Integer | 8-bit signed (signed char) s | Integer | 16-bit signed, native endian (int16_t) l | Integer | 32-bit signed, native endian (int32_t) q | Integer | 64-bit signed, native endian (int64_t) j | Integer | pointer width signed, native endian (intptr_t) | | S_ S! | Integer | unsigned short, native endian I I_ I! | Integer | unsigned int, native endian L_ L! | Integer | unsigned long, native endian Q_ Q! | Integer | unsigned long long, native endian (ArgumentError | | if the platform has no long long type.) J! | Integer | uintptr_t, native endian (same with J) | | s_ s! | Integer | signed short, native endian i i_ i! | Integer | signed int, native endian l_ l! | Integer | signed long, native endian q_ q! | Integer | signed long long, native endian (ArgumentError | | if the platform has no long long type.) j! | Integer | intptr_t, native endian (same with j) | | S> s> S!> s!> | Integer | same as the directives without ">" except L> l> L!> l!> | | big endian I!> i!> | | Q> q> Q!> q!> | | "S>" is same as "n" J> j> J!> j!> | | "L>" is same as "N" | | S< s< S!< s!< | Integer | same as the directives without "<" except L< l< L!< l!< | | little endian I!< i!< | | Q< q< Q!< q!< | | "S<" is same as "v" J< j< J!< j!< | | "L<" is same as "V" | | n | Integer | 16-bit unsigned, network (big-endian) byte order N | Integer | 32-bit unsigned, network (big-endian) byte order v | Integer | 16-bit unsigned, VAX (little-endian) byte order V | Integer | 32-bit unsigned, VAX (little-endian) byte order | | U | Integer | UTF-8 character w | Integer | BER-compressed integer (see Array.pack) Float | | Directive | Returns | Meaning ----------------------------------------------------------------- D d | Float | double-precision, native format F f | Float | single-precision, native format E | Float | double-precision, little-endian byte order e | Float | single-precision, little-endian byte order G | Float | double-precision, network (big-endian) byte order g | Float | single-precision, network (big-endian) byte order String | | Directive | Returns | Meaning ----------------------------------------------------------------- A | String | arbitrary binary string (remove trailing nulls and ASCII spaces) a | String | arbitrary binary string Z | String | null-terminated string B | String | bit string (MSB first) b | String | bit string (LSB first) H | String | hex string (high nibble first) h | String | hex string (low nibble first) u | String | UU-encoded string M | String | quoted-printable, MIME encoding (see RFC2045) m | String | base64 encoded string (RFC 2045) (default) | | base64 encoded string (RFC 4648) if followed by 0 P | String | pointer to a structure (fixed-length string) p | String | pointer to a null-terminated string Misc. | | Directive | Returns | Meaning ----------------------------------------------------------------- @ | --- | skip to the offset given by the length argument X | --- | skip backward one byte x | --- | skip forward one byte HISTORY * J, J! j, and j! are available since Ruby 2.3. * Q_, Q!, q_, and q! are available since Ruby 2.1. * I!<, i!<, I!>, and i!> are available since Ruby 1.9.3. ;T;[o;H ;II" overload;F;J0;;;K0;#I"unpack(format);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @2;[;I"@return [Array];T;0; @2;@F;Mi;N0;[[I" format;T0; @2;[;I"/Decodes str (which may contain binary data) according to the format string, returning an array of each value extracted. The format string consists of a sequence of single-character directives, summarized in the table at the end of this entry. Each directive may be followed by a number, indicating the number of times to repeat with this directive. An asterisk (``*'') will use up all remaining elements. The directives sSiIlL may each be followed by an underscore (``_'') or exclamation mark (``!'') to use the underlying platform's native size for the specified type; otherwise, it uses a platform-independent consistent size. Spaces are ignored in the format string. See also String#unpack1, Array#pack. "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "] "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"] "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "] "aa".unpack('b8B8') #=> ["10000110", "01100001"] "aaa".unpack('h2H2c') #=> ["16", "61", 97] "\xfe\xff\xfe\xff".unpack('sS') #=> [-2, 65534] "now=20is".unpack('M*') #=> ["now is"] "whole".unpack('xax2aX2aX1aX2a') #=> ["h", "e", "l", "l", "o"] This table summarizes the various formats and the Ruby classes returned by each. Integer | | Directive | Returns | Meaning ------------------------------------------------------------------ C | Integer | 8-bit unsigned (unsigned char) S | Integer | 16-bit unsigned, native endian (uint16_t) L | Integer | 32-bit unsigned, native endian (uint32_t) Q | Integer | 64-bit unsigned, native endian (uint64_t) J | Integer | pointer width unsigned, native endian (uintptr_t) | | c | Integer | 8-bit signed (signed char) s | Integer | 16-bit signed, native endian (int16_t) l | Integer | 32-bit signed, native endian (int32_t) q | Integer | 64-bit signed, native endian (int64_t) j | Integer | pointer width signed, native endian (intptr_t) | | S_ S! | Integer | unsigned short, native endian I I_ I! | Integer | unsigned int, native endian L_ L! | Integer | unsigned long, native endian Q_ Q! | Integer | unsigned long long, native endian (ArgumentError | | if the platform has no long long type.) J! | Integer | uintptr_t, native endian (same with J) | | s_ s! | Integer | signed short, native endian i i_ i! | Integer | signed int, native endian l_ l! | Integer | signed long, native endian q_ q! | Integer | signed long long, native endian (ArgumentError | | if the platform has no long long type.) j! | Integer | intptr_t, native endian (same with j) | | S> s> S!> s!> | Integer | same as the directives without ">" except L> l> L!> l!> | | big endian I!> i!> | | Q> q> Q!> q!> | | "S>" is same as "n" J> j> J!> j!> | | "L>" is same as "N" | | S< s< S!< s!< | Integer | same as the directives without "<" except L< l< L!< l!< | | little endian I!< i!< | | Q< q< Q!< q!< | | "S<" is same as "v" J< j< J!< j!< | | "L<" is same as "V" | | n | Integer | 16-bit unsigned, network (big-endian) byte order N | Integer | 32-bit unsigned, network (big-endian) byte order v | Integer | 16-bit unsigned, VAX (little-endian) byte order V | Integer | 32-bit unsigned, VAX (little-endian) byte order | | U | Integer | UTF-8 character w | Integer | BER-compressed integer (see Array.pack) Float | | Directive | Returns | Meaning ----------------------------------------------------------------- D d | Float | double-precision, native format F f | Float | single-precision, native format E | Float | double-precision, little-endian byte order e | Float | single-precision, little-endian byte order G | Float | double-precision, network (big-endian) byte order g | Float | single-precision, network (big-endian) byte order String | | Directive | Returns | Meaning ----------------------------------------------------------------- A | String | arbitrary binary string (remove trailing nulls and ASCII spaces) a | String | arbitrary binary string Z | String | null-terminated string B | String | bit string (MSB first) b | String | bit string (LSB first) H | String | hex string (high nibble first) h | String | hex string (low nibble first) u | String | UU-encoded string M | String | quoted-printable, MIME encoding (see RFC2045) m | String | base64 encoded string (RFC 2045) (default) | | base64 encoded string (RFC 4648) if followed by 0 P | String | pointer to a structure (fixed-length string) p | String | pointer to a null-terminated string Misc. | | Directive | Returns | Meaning ----------------------------------------------------------------- @ | --- | skip to the offset given by the length argument X | --- | skip backward one byte x | --- | skip forward one byte HISTORY * J, J! j, and j! are available since Ruby 2.3. * Q_, Q!, q_, and q! are available since Ruby 2.1. * I!<, i!<, I!>, and i!> are available since Ruby 1.9.3. @overload unpack(format) @return [Array];T;0; @2;@F;Ao;B;CT;Di;Eiu;!@;"I"static VALUE pack_unpack(VALUE str, VALUE fmt) { int mode = rb_block_given_p() ? UNPACK_BLOCK : UNPACK_ARRAY; return pack_unpack_internal(str, fmt, mode); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#unpack1;F;[[I"fmt;T0;[[@2i;T;: unpack1;0;[;{;IC;"Decodes str (which may contain binary data) according to the format string, returning the first value extracted. See also String#unpack, Array#pack. ;T;[o;H ;II" overload;F;J0;;;K0;#I"unpack1(format);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @2;[;I"@return [Object];T;0; @2;@F;Mi;N0;[[I" format;T0; @2;[;I"Decodes str (which may contain binary data) according to the format string, returning the first value extracted. See also String#unpack, Array#pack. @overload unpack1(format) @return [Object];T;0; @2;@F;Ao;B;CT;Di;Ei;!@;"I"mstatic VALUE pack_unpack1(VALUE str, VALUE fmt) { return pack_unpack_internal(str, fmt, UNPACK_1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"String#encode;F;[[@0;[[I"transcode.c;Ti; ;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+ Hash gives details for conversion and can have the following keys: :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;H ;II" overload;F;J0;;;K0;#I""encode(encoding [, options] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ 3;[;I"@return [String];T;0; @ 3;@F;Mi;N0;[[I"encoding[, options];T0; @ 3o;H ;II" overload;F;J0;;;K0;#I"4encode(dst_encoding, src_encoding [, options] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ 3;[;I"@return [String];T;0; @ 3;@F;Mi;N0;[[I"dst_encoding;T0[I"src_encoding[, options];T0; @ 3o;H ;II" overload;F;J0;;;K0;#I"encode([options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ 3;[;I"@return [String];T;0; @ 3;@F;Mi;N0;[[I"[options];T0; @ 3;[;I"T 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+ Hash gives details for conversion and can have the following keys: :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; @ 3;@F;Ao;B;CT;Di ;Ei: ;!@;"I"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; ; F; ;,;;;I"String#encode!;F;[[@0;[[@3i ;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 Hash gives details for conversion. See String#encode for details. Returns the string even if no changes were made. ;T;[o;H ;II" overload;F;J0;;;K0;#I"#encode!(encoding [, options] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I3;[;I"@return [String];T;0; @I3;@F;Mi;N0;[[I"encoding[, options];T0; @I3o;H ;II" overload;F;J0;;;K0;#I"5encode!(dst_encoding, src_encoding [, options] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I3;[;I"@return [String];T;0; @I3;@F;Mi;N0;[[I"dst_encoding;T0[I"src_encoding[, options];T0; @I3;[;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 Hash gives 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; @I3;@F;Ao;B;CT;Di ;Ei ;!@;"I"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;$To; ; F; ;,;;;I"String#to_d;F;[;[[I"ext/bigdecimal/util/util.c;Ti;T;: to_d;0;[;{;IC;" ;T;[;[;@;0; @x3;!@;"I"5RUBY_EXTERN VALUE rmpd_util_str_to_d(VALUE str);;T;#I"5RUBY_EXTERN VALUE rmpd_util_str_to_d(VALUE str);;T;$T;&@;'IC;[;&@;(IC;[o;2 ;30;40;50;;;!@;7@;F0;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i,+;F;;;;0;;;[;{;IC;"A String object holds and manipulates an arbitrary sequence of bytes, typically representing characters. String objects may be created using String::new or as literals. Because of aliasing issues, users of strings should be aware of the methods that modify the contents of a String object. Typically, methods with names ending in ``!'' modify their receiver, while those without a ``!'' return a new String. However, there are exceptions, such as String#[]=.;T;[;[;I"A String object holds and manipulates an arbitrary sequence of bytes, typically representing characters. String objects may be created using String::new or as literals. Because of aliasing issues, users of strings should be aware of the methods that modify the contents of a String object. Typically, methods with names ending in ``!'' modify their receiver, while those without a ``!'' return a new String. However, there are exceptions, such as String#[]=. ;T;0; @;@F;Ao;B;CT;Di+;Ei#+;Mi;!@;I" String;F;1@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; ; F; ;;;;I"Bug.unp_st_foreach;F;[[I" test;T0;[[@w5i;T;:unp_st_foreach;0;[;{;IC;" ;T;[;[;@;0; @5;!@;"I"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; ; F; ;,;;;I"Bug::Win32#dlntest;F;[;[[I"#ext/-test-/win32/dln/dlntest.c;Ti ;T;: dlntest;0;[;{;IC;" ;T;[;[;I";F;0; @5;@F;N0;!@5;"I"Ustatic VALUE dln_dlntest(VALUE self) { dlntest_ordinal(); return self; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Bug::Win32.dlntest;F;@5;@5;T;;;0;@5;{;IC;" ;T;[;[;@;0; @5;Mi;!@5;"@5;#@5;$T;&@5;'IC;[;&@5;(IC;[;&@5;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"$ext/-test-/win32/console/init.c;Ti;F;: Win32;;0;;;[;{;IC;" ;T;[;[;@;0; @5;!@;I"Bug::Win32;Fo; ;IC;[o; ; F; ;,;;;I"Bug::Exception#enc_raise;F;[[I" encoding;T0[I" mesg;T0;[[I"%ext/-test-/exception/enc_raise.c;Ti ;T;:enc_raise;0;[;{;IC;" ;T;[;[;I";F;0; @5;@F;N0;!@5;"I"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; ; T; ;;;;I"Bug::Exception.enc_raise;F;@5;@5;T;;;0;@5;{;IC;" ;T;[;[;@;0; @5;Mi;!@5;"@5;#@5;$T;&@5;'IC;[;&@5;(IC;[;&@5;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I" ext/-test-/exception/init.c;Ti;F;;#;;0;;;[;{;IC;" ;T;[;[;@;0; @5;!@;I"Bug::Exception;F;1o;2 ;30;40;50;;;!@;7@7;F;o; ;IC;[o; ; F; ;;;;I"Bug::VM.register_at_exit;F;[[I"t;T0;[[I"ext/-test-/vm/at_exit.c;Ti;T;:register_at_exit;0;[;{;IC;" ;T;[;[;@;0; @5;!@5;"I"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;&@5;'IC;[;&@5;(IC;[;&@5;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@5i/;F;:VM;;0;;;[;{;IC;" ;T;[;[;@;0; @5;!@;I" Bug::VM;F;1@ 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; ;IC;[o; ; F; ;,;;;I"#Bug::String::Yield#yield_block;F;[[@0;[[I"ext/-test-/iter/yield.c;Ti;T;:yield_block;0;[;{;IC;" ;T;[;[;@;0; @6;!@6;"I"static VALUE yield_block(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); return rb_block_call(self, rb_to_id(argv[0]), argc-1, argv+1, rb_yield_block, 0); };T;#I"static VALUE;T;$T;&@6;'IC;[;&@6;(IC;[;&@6;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@6i;F;: Yield;;0;;;[;{;IC;" ;T;[;[;@;0; @6;Mi;!@g6;I"Bug::String::Yield;Fo; ;IC;[ o; ; F; ;,;;;I"&Bug::String::Breakable#iter_break;F;[;[[I"ext/-test-/iter/break.c;Ti;T;:iter_break;0;[;{;IC;" ;T;[;[;I";F;0; @6;@F;N0;!@6;"I"`static VALUE iter_break(VALUE self) { rb_iter_break(); UNREACHABLE_RETURN(Qnil); };T;#I"static VALUE;T;$To; ; T; ;;;;I"&Bug::String::Breakable.iter_break;F;@6;@6;T;;;0;@6;{;IC;" ;T;[;[;@;0; @6;Mi;!@6;"@6;#@6;$To; ; F; ;,;;;I",Bug::String::Breakable#iter_break_value;F;[[I"val;T0;[[@6i;T;:iter_break_value;0;[;{;IC;" ;T;[;[;I";F;0; @6;@F;N0;!@6;"I"zstatic VALUE iter_break_value(VALUE self, VALUE val) { rb_iter_break_value(val); UNREACHABLE_RETURN(Qnil); };T;#I"static VALUE;T;$To; ; T; ;;;;I",Bug::String::Breakable.iter_break_value;F;@6;@6;T;;;0;@6;{;IC;" ;T;[;[;@;0; @6;Mi;!@6;"@6;#@6;$T;&@6;'IC;[;&@6;(IC;[;&@6;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@6i;F;:Breakable;;0;;;[;{;IC;" ;T;[;[;@;0; @6;!@g6;I"Bug::String::Breakable;F;&@g6;'IC;[;&@g6;(IC;[;&@g6;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/string/init.c;Ti;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @g6;Mi;!@;I"Bug::String;F;1@o; ; F; ;,;;;I"Bug#start;F;[[I" hash;T0;[[I"ext/-test-/bug-3571/bug.c;Ti;T;: start;0;[;{;IC;" ;T;[;[;I";F;0; @7;@F;N0;!@;"I"static VALUE bug_start(VALUE self, VALUE hash) { VALUE ary = rb_ary_new3(1, Qnil); rb_block_call(ary, rb_intern("map"), 0, 0, bug_i, self); return ary; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Bug.start;F;@7;@ 7;T;;;0;@#7;{;IC;" ;T;[;[;@;0; @+7;Mi;!@;"@)7;#@*7;$To; ; F; ;;;;I" Bug.s;F;[[I"obj;T0;[[I"ext/-test-/printf/printf.c;Ti ;T;:s;0;[;{;IC;" ;T;[;[;@;0; @17;!@;"I"~static VALUE printf_test_s(VALUE self, VALUE obj) { return rb_enc_sprintf(rb_usascii_encoding(), "<%"PRIsVALUE">", obj); };T;#I"static VALUE;T;$To; ; F; ;;;;I" Bug.v;F;[[I"obj;T0;[[@87i;T;:v;0;[;{;IC;" ;T;[;[;@;0; @@7;!@;"I"static VALUE printf_test_v(VALUE self, VALUE obj) { return rb_enc_sprintf(rb_usascii_encoding(), "{%+"PRIsVALUE"}", obj); };T;#I"static VALUE;T;$To; ; F; ;;;;I" Bug.q;F;[[I"obj;T0;[[@87i;T;:q;0;[;{;IC;" ;T;[;[;@;0; @N7;!@;"I"static VALUE printf_test_q(VALUE self, VALUE obj) { return rb_enc_sprintf(rb_usascii_encoding(), "[% "PRIsVALUE"]", obj); };T;#I"static VALUE;T;$To; ; F; ;;;;I" Bug.call;F;[[@0;[[@87i';T;: call;0;[;{;IC;" ;T;[;[;@;0; @\7;!@;"I"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; ; F; ;;;;I"Bug.sncount;F;[[I"str;T0;[[@87ib;T;: sncount;0;[;{;IC;" ;T;[;[;@;0; @i7;!@;"I"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;$To; ;IC;[o; ; F; ;,;;;I"Bug::Iter#delete!;F;[[I"key;T0;[[I"ext/-test-/hash/delete.c;Ti ;T;;u;0;[;{;IC;" ;T;[;[;@;0; @y7;!@w7;"I"static VALUE hash_delete(VALUE hash, VALUE key) { VALUE ret = rb_hash_delete_entry(hash, key); return ret == Qundef ? Qnil : rb_ary_new_from_values(1, &ret); };T;#I"static VALUE;T;$T;&@w7;'IC;[;&@w7;(IC;[;&@w7;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/iter/init.c;Ti;F;: Iter;;0;;;[;{;IC;" ;T;[;[;@;0; @w7;!@;I"Bug::Iter;Fo; ;IC;[ o; ; F; ;;;;I"Bug::Hash.nano_new;F;[[I"sec;T0[I" nsec;T0;[[I"ext/-test-/time/new.c;Ti;T;: nano_new;0;[;{;IC;" ;T;[;[;@;0; @7;!@7;"I"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; ; F; ;;;;I"Bug::Hash.timespec_new;F;[[I"sec;T0[I" nsec;T0[I" gmtoff;T0;[[@7i;T;:timespec_new;0;[;{;IC;" ;T;[;[;@;0; @7;!@7;"I"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; ; F; ;;;;I"Bug::Hash.timespec_now;F;[;[[@7i;T;:timespec_now;0;[;{;IC;" ;T;[;[;@;0; @7;!@7;"I"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; ; F; ;;;;I"%Bug::Hash.reset_leap_second_info;F;[;[[I""ext/-test-/time/leap_second.c;Ti ;T;:reset_leap_second_info;0;[;{;IC;" ;T;[;[;@;0; @7;!@7;"I"xstatic VALUE bug_time_s_reset_leap_second_info(VALUE klass) { ruby_reset_leap_second_info(); return Qnil; };T;#I"static VALUE;T;$T;&@7;'IC;[;&@7;(IC;[;&@7;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/hash/init.c;Ti;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @7;!@;I"Bug::Hash;F;1o;2 ;30;40;50;;;!@;7o; ;IC;[Po; ; F; ;;;;I" Hash.[];F;[[@0;[[I" hash.c;Ti;T;;;0;[;{;IC;"Creates a new hash populated with the given objects. Similar to the literal { _key_ => _value_, ... }. In the first form, keys and values occur in pairs, so there must be an even number of arguments. The second and third form take a single argument which is either an array of key-value pairs or an object convertible to a hash. Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200} Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200} Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200} ;T;[o;H ;II" overload;F;J0;;;K0;#I"[]( key, value, ... );T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I"key;T0[I" value;T0[I"...;T0; @7o;H ;II" overload;F;J0;;;K0;#I"[]( [ [key, value);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I"[ [key, value);T0; @7o;H ;II" overload;F;J0;;;K0;#I"[]( object );T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I" object;T0; @7;[;I"qCreates a new hash populated with the given objects. Similar to the literal { _key_ => _value_, ... }. In the first form, keys and values occur in pairs, so there must be an even number of arguments. The second and third form take a single argument which is either an array of key-value pairs or an object convertible to a hash. Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200} Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200} Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200} @overload []( key, value, ... ) @overload []( [ [key, value) @overload []( object );T;0; @7;@F;Ao;B;CT;Di;Ei ;!@7;"I"Vstatic 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); if (RHASH_AR_TABLE_P(tmp)) { ar_copy(hash, tmp); } else { RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(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)) { #if 0 /* refix in the next release */ rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)", rb_builtin_class_name(e), i); #else rb_warn("wrong element type %s at %ld (expected array)", rb_builtin_class_name(e), i); rb_warn("ignoring wrong elements is deprecated, remove them explicitly"); rb_warn("this causes ArgumentError in the next release"); continue; #endif } 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; ; F; ;;;;I"Hash.try_convert;F;[[I" hash;T0;[[@7ig;T;; ;0;[;{;IC;"Try to convert obj into a hash, using to_hash method. Returns converted hash or nil if obj cannot be converted for any reason. Hash.try_convert({1=>2}) # => {1=>2} Hash.try_convert("1=>2") # => nil ;T;[o;H ;II" overload;F;J0;; ;K0;#I"try_convert(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;TI"nil;T; @8;[;I"@return [Hash, nil];T;0; @8;@F;Mi;N0;[[I"obj;T0; @8;[;I"Try to convert obj into a hash, using to_hash method. Returns converted hash or nil if obj cannot be converted for any reason. Hash.try_convert({1=>2}) # => {1=>2} Hash.try_convert("1=>2") # => nil @overload try_convert(obj) @return [Hash, nil];T;0; @8;@F;Ao;B;CT;Di\;Eie;!@7;"I"istatic VALUE rb_hash_s_try_convert(VALUE dummy, VALUE hash) { return rb_check_hash_type(hash); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#initialize;F;[[@0;[[@7i;T;;;0;[;{;IC;"8Returns a new, empty hash. If this hash is subsequently accessed by a key that doesn't correspond to a hash entry, the value returned depends on the style of new used to create the hash. In the first form, the access returns nil. If obj is specified, this single object will be used for all default values. If a block is specified, it will be called with the hash object and the key, and should return the default value. It is the block's responsibility to store the value in the hash if required. h = Hash.new("Go Fish") h["a"] = 100 h["b"] = 200 h["a"] #=> 100 h["c"] #=> "Go Fish" # The following alters the single default object h["c"].upcase! #=> "GO FISH" h["d"] #=> "GO FISH" h.keys #=> ["a", "b"] # While this creates a new default object each time h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" } h["c"] #=> "Go Fish: c" h["c"].upcase! #=> "GO FISH: C" h["d"] #=> "Go Fish: d" h.keys #=> ["c", "d"] ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[;[;I";T;0; @;8;@F;Mi;N0;[; @;8o;H ;II" overload;F;J0;; ;K0;#I" new(obj);T;IC;";T;[;[;I";T;0; @;8;@F;Mi;N0;[[I"obj;T0; @;8o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" hash;TI"key;T; @;8;[;I"@yield [hash, key];T;0; @;8;@F;Mi;N0;[; @;8;[;I"Returns a new, empty hash. If this hash is subsequently accessed by a key that doesn't correspond to a hash entry, the value returned depends on the style of new used to create the hash. In the first form, the access returns nil. If obj is specified, this single object will be used for all default values. If a block is specified, it will be called with the hash object and the key, and should return the default value. It is the block's responsibility to store the value in the hash if required. h = Hash.new("Go Fish") h["a"] = 100 h["b"] = 200 h["a"] #=> 100 h["c"] #=> "Go Fish" # The following alters the single default object h["c"].upcase! #=> "GO FISH" h["d"] #=> "GO FISH" h.keys #=> ["a", "b"] # While this creates a new default object each time h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" } h["c"] #=> "Go Fish: c" h["c"].upcase! #=> "GO FISH: C" h["d"] #=> "Go Fish: d" h.keys #=> ["c", "d"] @overload new @overload new(obj) @overload new @yield [hash, key];T;0; @;8;@F;Ao;B;CT;Di;Ei;!@7;"I"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; ; F; ;,;;;I"Hash#initialize_copy;F;[[I" hash2;T0;[[@7i' ;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @j8;@F;Ao;B;CT;Di& ;Ei& ;!@7;"I"estatic VALUE rb_hash_initialize_copy(VALUE hash, VALUE hash2) { rb_hash_modify_check(hash); hash2 = to_hash(hash2); Check_Type(hash2, T_HASH); if (hash == hash2) return hash; if (RHASH_AR_TABLE_P(hash2)) { if (RHASH_AR_TABLE_P(hash)) ar_free_and_clear_table(hash); ar_copy(hash, hash2); if (RHASH_AR_TABLE_SIZE(hash)) rb_hash_rehash(hash); } else if (RHASH_ST_TABLE_P(hash2)) { if (RHASH_ST_TABLE_P(hash)) st_free_table(RHASH_ST_TABLE(hash)); RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(hash2))); if (RHASH_ST_TABLE(hash)->num_entries) rb_hash_rehash(hash); } else if (RHASH_AR_TABLE_P(hash)) { ar_clear(hash); } else if (RHASH_ST_TABLE_P(hash)) { st_clear(RHASH_ST_TABLE(hash)); } COPY_DEFAULT(hash, hash2); return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#rehash;F;[;[[@7i;T;: rehash;0;[;{;IC;"Rebuilds the hash based on the current hash values for each key. If values of key objects have changed since they were inserted, this method will reindex hsh. If Hash#rehash is called while an iterator is traversing the hash, a RuntimeError will be raised in the iterator. a = [ "a", "b" ] c = [ "c", "d" ] h = { a => 100, c => 300 } h[a] #=> 100 a[0] = "z" h[a] #=> nil h.rehash #=> {["z", "b"]=>100, ["c", "d"]=>300} h[a] #=> 100 ;T;[o;H ;II" overload;F;J0;;;K0;#I" rehash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @z8;[;I"@return [Hash];T;0; @z8;@F;Mi;N0;[; @z8;[;I"!Rebuilds the hash based on the current hash values for each key. If values of key objects have changed since they were inserted, this method will reindex hsh. If Hash#rehash is called while an iterator is traversing the hash, a RuntimeError will be raised in the iterator. a = [ "a", "b" ] c = [ "c", "d" ] h = { a => 100, c => 300 } h[a] #=> 100 a[0] = "z" h[a] #=> nil h.rehash #=> {["z", "b"]=>100, ["c", "d"]=>300} h[a] #=> 100 @overload rehash @return [Hash];T;0; @z8;@F;Ao;B;CT;Di~;Ei;!@7;"I"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; ; F; ;,;;;I"Hash#to_hash;F;[;[[@7i ;T;: to_hash;0;[;{;IC;"Returns +self+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @8;[;I"@return [Hash];T;0; @8;@F;Mi;N0;[; @8;[;I"9Returns +self+. @overload to_hash @return [Hash];T;0; @8;@F;Ao;B;CT;Di ;Ei ;!@7;"I"Bstatic VALUE rb_hash_to_hash(VALUE hash) { return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#to_h;F;[;[[@7i1 ;T;: to_h;0;[;{;IC;"Returns +self+. If called on a subclass of Hash, converts the receiver to a Hash object. If a block is given, the results of the block on each pair of the receiver will be used as pairs. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_h;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @8;[;I"@return [Hash];T;0; @8;@F;Mi;N0;[; @8o;H ;II" overload;F;J0;;;K0;#I" to_h;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @8;[;I"@yield [key, value];T;0; @8;@F;Mi;N0;[; @8;[;I"Returns +self+. If called on a subclass of Hash, converts the receiver to a Hash object. If a block is given, the results of the block on each pair of the receiver will be used as pairs. @overload to_h @return [Hash] @overload to_h @yield [key, value];T;0; @8;@F;Ao;B;CT;Di% ;Ei/ ;!@7;"I"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 & HASH_PROC_DEFAULT); } return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#to_a;F;[;[[@7i ;T;: to_a;0;[;{;IC;"Converts hsh to a nested array of [ key, value ] arrays. h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_a #=> [["c", 300], ["a", 100], ["d", 400]] ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @8;[;I"@return [Array];T;0; @8;@F;Mi;N0;[; @8;[;I"Converts hsh to a nested array of [ key, value ] arrays. h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_a #=> [["c", 300], ["a", 100], ["d", 400]] @overload to_a @return [Array];T;0; @8;@F;Ao;B;CT;Di ;Ei ;!@7;"I"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); OBJ_INFECT(ary, hash); return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#inspect;F;[;[[@7i ;T;;i;0;[;{;IC;"Return the contents of this hash as a string. h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_s #=> "{\"c\"=>300, \"a\"=>100, \"d\"=>400}" ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @8;[;I"@return [String];T;0; @8;@F;Mi;N0;[; @8o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @8;[;I"@return [String];T;0; @8;@F;Mi;N0;[; @8;[;I"Return the contents of this hash as a string. h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_s #=> "{\"c\"=>300, \"a\"=>100, \"d\"=>400}" @overload to_s @return [String] @overload inspect @return [String];T;0; o; ; F; ;,;;;I"Hash#to_s;F;[;[[@7i;F;;h;;0;[;{;@8;!@7;"I"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;Ao;B;CT;Di ;Ei ;!@7;"I"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;#@!9;$T@9o; ; F; ;,;;;I"Hash#to_proc;F;[;[[@7i;T;;;0;[;{;IC;"Returns a Proc which maps keys to values. h = {a:1, b:2} hp = h.to_proc hp.call(:a) #=> 1 hp.call(:b) #=> 2 hp.call(:c) #=> nil [:a, :b, :c].map(&h) #=> [1, 2, nil] ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_proc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @$9;[;I"@return [Proc];T;0; @$9;@F;Mi;N0;[; @$9;[;I"Returns a Proc which maps keys to values. h = {a:1, b:2} hp = h.to_proc hp.call(:a) #=> 1 hp.call(:b) #=> 2 hp.call(:c) #=> nil [:a, :b, :c].map(&h) #=> [1, 2, nil] @overload to_proc @return [Proc];T;0; @$9;@F;Ao;B;CT;Di;Ei;!@7;"I"dstatic VALUE rb_hash_to_proc(VALUE hash) { return rb_func_proc_new(hash_proc_call, hash); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Hash#==;F;[[I" hash2;T0;[[@7iP ;T;;S;0;[;{;IC;"+Equality---Two hashes are equal if they each contain the same number of keys and if each key-value pair is equal to (according to Object#==) the corresponding elements in the other hash. h1 = { "a" => 1, "c" => 2 } h2 = { 7 => 35, "c" => 2, "a" => 1 } h3 = { "a" => 1, "c" => 2, 7 => 35 } h4 = { "a" => 1, "d" => 2, "f" => 35 } h1 == h2 #=> false h2 == h3 #=> true h3 == h4 #=> false The orders of each hashes are not compared. h1 = { "a" => 1, "c" => 2 } h2 = { "c" => 2, "a" => 1 } h1 == h2 #=> true ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other_hash);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @?9;[;I"@return [Boolean];T;0; @?9;@F;Mi;N0;[[I"other_hash;T0; @?9;[;I"[Equality---Two hashes are equal if they each contain the same number of keys and if each key-value pair is equal to (according to Object#==) the corresponding elements in the other hash. h1 = { "a" => 1, "c" => 2 } h2 = { 7 => 35, "c" => 2, "a" => 1 } h3 = { "a" => 1, "c" => 2, 7 => 35 } h4 = { "a" => 1, "d" => 2, "f" => 35 } h1 == h2 #=> false h2 == h3 #=> true h3 == h4 #=> false The orders of each hashes are not compared. h1 = { "a" => 1, "c" => 2 } h2 = { "c" => 2, "a" => 1 } h1 == h2 #=> true @overload ==(other_hash) @return [Boolean];T;0; @?9;@F;Ao;B;CT;Di7 ;EiM ;!@7;"I"istatic VALUE rb_hash_equal(VALUE hash1, VALUE hash2) { return hash_equal(hash1, hash2, FALSE); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Hash#[];F;[[I"key;T0;[[@7i;T;;;0;[;{;IC;"Element Reference---Retrieves the value object corresponding to the key object. If not found, returns the default value (see Hash::new for details). h = { "a" => 100, "b" => 200 } h["a"] #=> 100 h["c"] #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I" [](key);T;IC;";T;[;[;I";T;0; @^9;@F;Mi;N0;[[I"key;T0; @^9;[;I"Element Reference---Retrieves the value object corresponding to the key object. If not found, returns the default value (see Hash::new for details). h = { "a" => 100, "b" => 200 } h["a"] #=> 100 h["c"] #=> nil @overload [](key);T;0; @^9;@F;Ao;B;CT;Di;Ei;!@7;"I"\VALUE rb_hash_aref(VALUE hash, VALUE key) { st_data_t val; if (RHASH_AR_TABLE_P(hash) && ar_lookup(hash, key, &val)) { return (VALUE)val; } else if (RHASH_ST_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, &val)) { return (VALUE)val; } hash_verify(hash); return rb_hash_default_value(hash, key); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Hash#hash;F;[;[[@7i{ ;T;;U;0;[;{;IC;"Compute a hash-code for this hash. Two hashes with the same content will have the same hash code (and will compare using eql?). See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @x9;[;I"@return [Integer];T;0; @x9;@F;Mi;N0;[; @x9;[;I"Compute a hash-code for this hash. Two hashes with the same content will have the same hash code (and will compare using eql?). See also Object#hash. @overload hash @return [Integer];T;0; @x9;@F;Ao;B;CT;Diq ;Eix ;!@7;"I"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; ; F; ;,;;;I"Hash#eql?;F;[[I" hash2;T0;[[@7i_ ;T;;R;0;[;{;IC;"Returns true if hash and other are both hashes with the same content. The orders of each hashes are not compared.;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @9;[;I"@return [Boolean];T;0; @9;@F;Mi;N0;[[I" other;T0; @9;[;I"Returns true if hash and other are both hashes with the same content. The orders of each hashes are not compared. @overload eql?(other) @return [Boolean];T;0; @9;@F;Ao;B;CT;DiV ;Ei\ ;Mi;!@7;"I"fstatic VALUE rb_hash_eql(VALUE hash1, VALUE hash2) { return hash_equal(hash1, hash2, TRUE); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#fetch;F;[[@0;[[@7i;T;: fetch;0;[;{;IC;"Returns a value from the hash 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. h = { "a" => 100, "b" => 200 } h.fetch("a") #=> 100 h.fetch("z", "go fish") #=> "go fish" h.fetch("z") { |el| "go fish, #{el}"} #=> "go fish, z" The following example shows that an exception is raised if the key is not found and a default value is not supplied. h = { "a" => 100, "b" => 200 } h.fetch("z") produces: prog.rb:2:in `fetch': key not found (KeyError) from prog.rb:2 ;T;[o;H ;II" overload;F;J0;;;K0;#I"fetch(key [, default] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @9;[;I"@return [Object];T;0; @9;@F;Mi;N0;[[I"key[, default];T0; @9o;H ;II" overload;F;J0;;;K0;#I"fetch(key);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @9o;L ;II" return;F;JI";T;0;K[I" Object;T; @9;[;I"$@yield [ key ] @return [Object];T;0; @9;@F;Mi;N0;[[I"key;T0; @9;[;I"Returns a value from the hash 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. h = { "a" => 100, "b" => 200 } h.fetch("a") #=> 100 h.fetch("z", "go fish") #=> "go fish" h.fetch("z") { |el| "go fish, #{el}"} #=> "go fish, z" The following example shows that an exception is raised if the key is not found and a default value is not supplied. h = { "a" => 100, "b" => 200 } h.fetch("z") produces: prog.rb:2:in `fetch': key not found (KeyError) from prog.rb:2 @overload fetch(key [, default] ) @return [Object] @overload fetch(key) @yield [ key ] @return [Object];T;0; @9;@F;Ao;B;CT;Di;Ei;!@7;"I"tstatic 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 (RHASH_AR_TABLE_P(hash) && ar_lookup(hash, key, &val)) { return (VALUE)val; } else if (RHASH_ST_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, &val)) { return (VALUE)val; } if (block_given) return rb_yield(key); 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); } hash_verify(hash); return argv[1]; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Hash#[]=;F;[;[;F;;+;;0;[;{;IC;" ;T;[;[;@;0; @9;!@7;$To; ; F; ;,;;;I"Hash#store;F;[;[;F;: store;;0;[;{;IC;" ;T;[;[;@;0; @9;!@7;$To; ; F; ;,;;;I"Hash#default;F;[[@0;[[@7iV;T;: default;0;[;{;IC;"Returns the default value, the value that would be returned by hsh[key] if key did not exist in hsh. See also Hash::new and Hash#default=. h = Hash.new #=> {} h.default #=> nil h.default(2) #=> nil h = Hash.new("cat") #=> {} h.default #=> "cat" h.default(2) #=> "cat" h = Hash.new {|h,k| h[k] = k.to_i*10} #=> {} h.default #=> nil h.default(2) #=> 20 ;T;[o;H ;II" overload;F;J0;;;K0;#I"default(key=nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @9;[;I"@return [Object];T;0; @9;@F;Mi;N0;[[I"key;TI"nil;T; @9;[;I"Returns the default value, the value that would be returned by hsh[key] if key did not exist in hsh. See also Hash::new and Hash#default=. h = Hash.new #=> {} h.default #=> nil h.default(2) #=> nil h = Hash.new("cat") #=> {} h.default #=> "cat" h.default(2) #=> "cat" h = Hash.new {|h,k| h[k] = k.to_i*10} #=> {} h.default #=> nil h.default(2) #=> 20 @overload default(key=nil) @return [Object];T;0; @9;@F;Ao;B;CT;DiA;EiS;!@7;"I"Wstatic VALUE rb_hash_default(int argc, VALUE *argv, VALUE hash) { VALUE args[2], ifnone; rb_check_arity(argc, 0, 1); ifnone = RHASH_IFNONE(hash); if (FL_TEST(hash, HASH_PROC_DEFAULT)) { if (argc == 0) return Qnil; args[0] = hash; args[1] = argv[0]; return rb_funcallv(ifnone, id_yield, 2, args); } return ifnone; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#default=;F;[[I" ifnone;T0;[[@7iz;T;: default=;0;[;{;IC;"Sets the default value, the value returned for a key that does not exist in the hash. It is not possible to set the default to a Proc that will be executed on each key lookup. h = { "a" => 100, "b" => 200 } h.default = "Go fish" h["a"] #=> 100 h["z"] #=> "Go fish" # This doesn't do what you might hope... h.default = proc do |hash, key| hash[key] = key + key end h[2] #=> # h["cat"] #=> # ;T;[o;H ;II" overload;F;J0;;;K0;#I"default=(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @:;[;I"@return [Object];T;0; @:;@F;Mi;N0;[[I"obj;T0; @:;[;I"Sets the default value, the value returned for a key that does not exist in the hash. It is not possible to set the default to a Proc that will be executed on each key lookup. h = { "a" => 100, "b" => 200 } h.default = "Go fish" h["a"] #=> 100 h["z"] #=> "Go fish" # This doesn't do what you might hope... h.default = proc do |hash, key| hash[key] = key + key end h[2] #=> # h["cat"] #=> # @overload default=(obj) @return [Object];T;0; @:;@F;Ao;B;CT;Dif;Eiw;!@7;"I"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; ; F; ;,;;;I"Hash#default_proc;F;[;[[@7i;T;:default_proc;0;[;{;IC;"MIf Hash::new was invoked with a block, return that block, otherwise return nil. h = Hash.new {|h,k| h[k] = k*k } #=> {} p = h.default_proc #=> # a = [] #=> [] p.call(a, 2) a #=> [nil, nil, 4] ;T;[o;H ;II" overload;F;J0;;;K0;#I"default_proc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @4:;[;I"@return [Object];T;0; @4:;@F;Mi;N0;[; @4:;[;I"yIf Hash::new was invoked with a block, return that block, otherwise return nil. h = Hash.new {|h,k| h[k] = k*k } #=> {} p = h.default_proc #=> # a = [] #=> [] p.call(a, 2) a #=> [nil, nil, 4] @overload default_proc @return [Object];T;0; @4:;@F;Ao;B;CT;Di;Ei;!@7;"I"static VALUE rb_hash_default_proc(VALUE hash) { if (FL_TEST(hash, HASH_PROC_DEFAULT)) { return RHASH_IFNONE(hash); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#default_proc=;F;[[I" proc;T0;[[@7i;T;:default_proc=;0;[;{;IC;"Sets the default proc to be executed on each failed key lookup. h.default_proc = proc do |hash, key| hash[key] = key + key end h[2] #=> 4 h["cat"] #=> "catcat" ;T;[o;H ;II" overload;F;J0;;;K0;#I"default_proc=(proc_obj);T;IC;";T;[;[;I";T;0; @O:;@F;Mi;N0;[[I" proc_obj;T0; @O:;[;I"Sets the default proc to be executed on each failed key lookup. h.default_proc = proc do |hash, key| hash[key] = key + key end h[2] #=> 4 h["cat"] #=> "catcat" @overload default_proc=(proc_obj);T;0; @O:;@F;Ao;B;CT;Di;Ei;!@7;"I"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; ; F; ;,;;;I" Hash#key;F;[[I" value;T0;[[@7i;T;:key;0;[;{;IC;"Returns the key of an occurrence of a given value. If the value is not found, returns nil. h = { "a" => 100, "b" => 200, "c" => 300, "d" => 300 } h.key(200) #=> "b" h.key(300) #=> "c" h.key(999) #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"key(value);T;IC;";T;[;[;I";T;0; @i:;@F;Mi;N0;[[I" value;T0; @i:;[;I"Returns the key of an occurrence of a given value. If the value is not found, returns nil. h = { "a" => 100, "b" => 200, "c" => 300, "d" => 300 } h.key(200) #=> "b" h.key(300) #=> "c" h.key(999) #=> nil @overload key(value);T;0; @i:;@F;Ao;B;CT;Di;Ei;!@7;"I"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; ; F; ;,;;;I"Hash#index;F;[[I" value;T0;[[@7i;T;;1;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @:;@F;Ao;B;CT;Di;Ei;!@7;"I"static VALUE rb_hash_index(VALUE hash, VALUE value) { rb_warn("Hash#index is deprecated; use Hash#key"); return rb_hash_key(hash, value); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#size;F;[;[[@7i ;T;;;0;[;{;IC;"Returns the number of key-value pairs in the hash. h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 } h.size #=> 4 h.delete("a") #=> 200 h.size #=> 3 h.length #=> 3 Hash#length is an alias for Hash#size. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @:;[;I"@return [Integer];T;0; @:;@F;Mi;N0;[; @:o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @:;[;I"@return [Integer];T;0; @:;@F;Mi;N0;[; @:;[;I"EReturns the number of key-value pairs in the hash. h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 } h.size #=> 4 h.delete("a") #=> 200 h.size #=> 3 h.length #=> 3 Hash#length is an alias for Hash#size. @overload length @return [Integer] @overload size @return [Integer];T;0; @:;@F;Ao;B;CT;Dir ;Ei ;!@7;"I"MVALUE rb_hash_size(VALUE hash) { return INT2FIX(RHASH_SIZE(hash)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Hash#length;F;[;[[@7i ;T;;;0;[;{;IC;"Returns the number of key-value pairs in the hash. h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 } h.size #=> 4 h.delete("a") #=> 200 h.size #=> 3 h.length #=> 3 Hash#length is an alias for Hash#size. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @:;[;I"@return [Integer];T;0; @:;@F;Mi;N0;[; @:o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @:;[;I"@return [Integer];T;0; @:;@F;Mi;N0;[; @:;[;@:;0; @:;@F;Ao;B;CT;Dir ;Ei ;!@7;"I"MVALUE rb_hash_size(VALUE hash) { return INT2FIX(RHASH_SIZE(hash)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Hash#empty?;F;[;[[@7i ;T;;;0;[;{;IC;"bReturns true if hsh contains no key-value pairs. {}.empty? #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @:;[;I"@return [Boolean];T;0; @:;@F;Mi;N0;[; @:;[;I"Returns true if hsh contains no key-value pairs. {}.empty? #=> true @overload empty? @return [Boolean];T;0; @:;@F;Ao;B;CT;Di ;Ei ;Mi;!@7;"I"bstatic VALUE rb_hash_empty_p(VALUE hash) { return RHASH_EMPTY_P(hash) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#each_value;F;[;[[@7i ;T;:each_value;0;[;{;IC;"Calls block once for each key in hsh, passing the value as a parameter. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200 } h.each_value {|value| puts value } produces: 100 200 ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_value;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" value;T; @:o;L ;II" return;F;JI";T;0;K[I" Hash;T; @:;[;I"$@yield [ value ] @return [Hash];T;0; @:;@F;Mi;N0;[; @:o;H ;II" overload;F;J0;;;K0;#I"each_value;T;IC;";T;[;[;I";T;0; @:;@F;Mi;N0;[; @:;[;I"KCalls block once for each key in hsh, passing the value as a parameter. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200 } h.each_value {|value| puts value } produces: 100 200 @overload each_value @yield [ value ] @return [Hash] @overload each_value;T;0; @:;@F;Ao;B;CT;Di ;Ei ;!@7;"I"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; ; F; ;,;;;I"Hash#each_key;F;[;[[@7i ;T;: each_key;0;[;{;IC;"Calls block once for each key in hsh, passing the key as a parameter. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200 } h.each_key {|key| puts key } produces: a b ;T;[o;H ;II" overload;F;J0;;;K0;#I" each_key;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @%;o;L ;II" return;F;JI";T;0;K[I" Hash;T; @%;;[;I""@yield [ key ] @return [Hash];T;0; @%;;@F;Mi;N0;[; @%;o;H ;II" overload;F;J0;;;K0;#I" each_key;T;IC;";T;[;[;I";T;0; @%;;@F;Mi;N0;[; @%;;[;I"9Calls block once for each key in hsh, passing the key as a parameter. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200 } h.each_key {|key| puts key } produces: a b @overload each_key @yield [ key ] @return [Hash] @overload each_key;T;0; @%;;@F;Ao;B;CT;Di ;Ei ;!@7;"I"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; ; F; ;,;;;I"Hash#each_pair;F;[;[[@7i ;T;:each_pair;0;[;{;IC;"Calls block once for each key in hsh, passing the key-value pair as parameters. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200 } h.each {|key, value| puts "#{key} is #{value}" } produces: a is 100 b is 200 ;T;[ o;H ;II" overload;F;J0;: each;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @M;o;L ;II" return;F;JI";T;0;K[I" Hash;T; @M;;[;I")@yield [ key, value ] @return [Hash];T;0; @M;;@F;Mi;N0;[; @M;o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @M;o;L ;II" return;F;JI";T;0;K[I" Hash;T; @M;;[;I")@yield [ key, value ] @return [Hash];T;0; @M;;@F;Mi;N0;[; @M;o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @M;;@F;Mi;N0;[; @M;o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[;[;I";T;0; @M;;@F;Mi;N0;[; @M;;[;I"Calls block once for each key in hsh, passing the key-value pair as parameters. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200 } h.each {|key, value| puts "#{key} is #{value}" } produces: a is 100 b is 200 @overload each @yield [ key, value ] @return [Hash] @overload each_pair @yield [ key, value ] @return [Hash] @overload each @overload each_pair;T;0; @M;;@F;Ao;B;CT;Di ;Ei ;!@7;"I"static VALUE rb_hash_each_pair(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); if (rb_block_arity() > 1) 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; ; F; ;,;;;I"Hash#each;F;[;[[@7i ;T;;;0;[;{;IC;"Calls block once for each key in hsh, passing the key-value pair as parameters. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200 } h.each {|key, value| puts "#{key} is #{value}" } produces: a is 100 b is 200 ;T;[ o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;;[;I")@yield [ key, value ] @return [Hash];T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;;[;I")@yield [ key, value ] @return [Hash];T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[; @;;[;@;;0; @;;@F;Ao;B;CT;Di ;Ei ;!@7;"I"static VALUE rb_hash_each_pair(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); if (rb_block_arity() > 1) 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; ; F; ;,;;;I"Hash#transform_keys;F;[;[[@7i, ;T;:transform_keys;0;[;{;IC;"Returns a new hash with the results of running the block once for every key. This method does not change the values. h = { a: 1, b: 2, c: 3 } h.transform_keys {|k| k.to_s } #=> { "a" => 1, "b" => 2, "c" => 3 } h.transform_keys(&:to_s) #=> { "a" => 1, "b" => 2, "c" => 3 } h.transform_keys.with_index {|k, i| "#{k}.#{i}" } #=> { "a.0" => 1, "b.1" => 2, "c.2" => 3 } If no block is given, an enumerator is returned instead. ;T;[o;H ;II" overload;F;J0;;;K0;#I"transform_keys;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @;;[;I"@yield [key];T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;;;K0;#I"transform_keys;T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[; @;;[;I"!Returns a new hash with the results of running the block once for every key. This method does not change the values. h = { a: 1, b: 2, c: 3 } h.transform_keys {|k| k.to_s } #=> { "a" => 1, "b" => 2, "c" => 3 } h.transform_keys(&:to_s) #=> { "a" => 1, "b" => 2, "c" => 3 } h.transform_keys.with_index {|k, i| "#{k}.#{i}" } #=> { "a.0" => 1, "b.1" => 2, "c.2" => 3 } If no block is given, an enumerator is returned instead. @overload transform_keys @yield [key] @overload transform_keys;T;0; @;;@F;Ao;B;CT;Di ;Ei* ;!@7;"I"static VALUE rb_hash_transform_keys(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = rb_hash_new(); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(hash, transform_keys_i, result); } return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#transform_keys!;F;[;[[@7iM ;T;:transform_keys!;0;[;{;IC;"Invokes the given block once for each key in hsh, replacing it with the new key returned by the block, and then returns hsh. This method does not change the values. h = { a: 1, b: 2, c: 3 } h.transform_keys! {|k| k.to_s } #=> { "a" => 1, "b" => 2, "c" => 3 } h.transform_keys!(&:to_sym) #=> { a: 1, b: 2, c: 3 } h.transform_keys!.with_index {|k, i| "#{k}.#{i}" } #=> { "a.0" => 1, "b.1" => 2, "c.2" => 3 } If no block is given, an enumerator is returned instead. ;T;[o;H ;II" overload;F;J0;;;K0;#I"transform_keys!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @;o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;;[;I" @yield [key] @return [Hash];T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;;;K0;#I"transform_keys!;T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[; @;;[;I"jInvokes the given block once for each key in hsh, replacing it with the new key returned by the block, and then returns hsh. This method does not change the values. h = { a: 1, b: 2, c: 3 } h.transform_keys! {|k| k.to_s } #=> { "a" => 1, "b" => 2, "c" => 3 } h.transform_keys!(&:to_sym) #=> { a: 1, b: 2, c: 3 } h.transform_keys!.with_index {|k, i| "#{k}.#{i}" } #=> { "a.0" => 1, "b.1" => 2, "c.2" => 3 } If no block is given, an enumerator is returned instead. @overload transform_keys! @yield [key] @return [Hash] @overload transform_keys!;T;0; @;;@F;Ao;B;CT;Di< ;EiL ;!@7;"I"static VALUE rb_hash_transform_keys_bang(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify_check(hash); if (!RHASH_TABLE_EMPTY_P(hash)) { long i; VALUE pairs = rb_hash_flatten(0, NULL, hash); rb_hash_clear(hash); for (i = 0; i < RARRAY_LEN(pairs); i += 2) { VALUE key = RARRAY_AREF(pairs, i), new_key = rb_yield(key), val = RARRAY_AREF(pairs, i+1); rb_hash_aset(hash, new_key, val); } } return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#transform_values;F;[;[[@7ix ;T;:transform_values;0;[;{;IC;"Returns a new hash with the results of running the block once for every value. This method does not change the keys. h = { a: 1, b: 2, c: 3 } h.transform_values {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 } h.transform_values(&:to_s) #=> { a: "1", b: "2", c: "3" } h.transform_values.with_index {|v, i| "#{v}.#{i}" } #=> { a: "1.0", b: "2.1", c: "3.2" } If no block is given, an enumerator is returned instead. ;T;[o;H ;II" overload;F;J0;;;K0;#I"transform_values;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" value;T; @<;[;I"@yield [value];T;0; @<;@F;Mi;N0;[; @ { a: 2, b: 5, c: 10 } h.transform_values(&:to_s) #=> { a: "1", b: "2", c: "3" } h.transform_values.with_index {|v, i| "#{v}.#{i}" } #=> { a: "1.0", b: "2.1", c: "3.2" } If no block is given, an enumerator is returned instead. @overload transform_values @yield [value] @overload transform_values;T;0; @<;@F;Ao;B;CT;Dig ;Eiv ;!@7;"I",static VALUE rb_hash_transform_values(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = rb_hash_new_with_size(RHASH_SIZE(hash)); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(hash, transform_values_i, result); } return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#transform_values!;F;[;[[@7i ;T;:transform_values!;0;[;{;IC;"Invokes the given block once for each value in hsh, replacing it with the new value returned by the block, and then returns hsh. This method does not change the keys. h = { a: 1, b: 2, c: 3 } h.transform_values! {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 } h.transform_values!(&:to_s) #=> { a: "2", b: "5", c: "10" } h.transform_values!.with_index {|v, i| "#{v}.#{i}" } #=> { a: "2.0", b: "5.1", c: "10.2" } If no block is given, an enumerator is returned instead. ;T;[o;H ;II" overload;F;J0;;;K0;#I"transform_values!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" value;T; @Bhsh, replacing it with the new value returned by the block, and then returns hsh. This method does not change the keys. h = { a: 1, b: 2, c: 3 } h.transform_values! {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 } h.transform_values!(&:to_s) #=> { a: "2", b: "5", c: "10" } h.transform_values!.with_index {|v, i| "#{v}.#{i}" } #=> { a: "2.0", b: "5.1", c: "10.2" } If no block is given, an enumerator is returned instead. @overload transform_values! @yield [value] @return [Hash] @overload transform_values!;T;0; @B<;@F;Ao;B;CT;Di ;Ei ;!@7;"I"static 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_foreach(hash, transform_values_i, hash); return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#keys;F;[;[[@7iQ ;T;: keys;0;[;{;IC;"Returns a new array populated with the keys from this hash. See also Hash#values. h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 } h.keys #=> ["a", "b", "c", "d"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" keys;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @j<;[;I"@return [Array];T;0; @j<;@F;Mi;N0;[; @j<;[;I"Returns a new array populated with the keys from this hash. See also Hash#values. h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 } h.keys #=> ["a", "b", "c", "d"] @overload keys @return [Array];T;0; @j<;@F;Ao;B;CT;DiE ;EiN ;!@7;"I"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; ; F; ;,;;;I"Hash#values;F;[;[[@7i ;T;: values;0;[;{;IC;"Returns a new array populated with the values from hsh. See also Hash#keys. h = { "a" => 100, "b" => 200, "c" => 300 } h.values #=> [100, 200, 300] ;T;[o;H ;II" overload;F;J0;;;K0;#I" values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @<;[;I"@return [Array];T;0; @<;@F;Mi;N0;[; @<;[;I"Returns a new array populated with the values from hsh. See also Hash#keys. h = { "a" => 100, "b" => 200, "c" => 300 } h.values #=> [100, 200, 300] @overload values @return [Array];T;0; @<;@F;Ao;B;CT;Dit ;Ei} ;!@7;"I"+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; ; F; ;,;;;I"Hash#values_at;F;[[@0;[[@7i ;T;:values_at;0;[;{;IC;"Return an array containing the values associated with the given keys. Also see Hash.select. h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } h.values_at("cow", "cat") #=> ["bovine", "feline"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"values_at(key, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @<;[;I"@return [Array];T;0; @<;@F;Mi;N0;[[I"key;T0[I"...;T0; @<;[;I"Return an array containing the values associated with the given keys. Also see Hash.select. h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } h.values_at("cow", "cat") #=> ["bovine", "feline"] @overload values_at(key, ...) @return [Array];T;0; @<;@F;Ao;B;CT;Di ;Ei ;!@7;"I"VALUE rb_hash_values_at(int argc, VALUE *argv, VALUE hash) { VALUE result = rb_ary_new2(argc); long i; for (i=0; iKeyError when one of keys can't be found. Also see Hash#values_at and Hash#fetch. h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } h.fetch_values("cow", "cat") #=> ["bovine", "feline"] h.fetch_values("cow", "bird") # raises KeyError h.fetch_values("cow", "bird") { |k| k.upcase } #=> ["bovine", "BIRD"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"fetch_values(key, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @<;[;I"@return [Array];T;0; @<;@F;Mi;N0;[[I"key;T0[I"...;T0; @KeyError when one of keys can't be found. Also see Hash#values_at and Hash#fetch. h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } h.fetch_values("cow", "cat") #=> ["bovine", "feline"] h.fetch_values("cow", "bird") # raises KeyError h.fetch_values("cow", "bird") { |k| k.upcase } #=> ["bovine", "BIRD"] @overload fetch_values(key, ...) @return [Array] @overload fetch_values(key, ...) @yield [key] @return [Array];T;0; @<;@F;Ao;B;CT;Di% ;Ei4 ;!@7;"I"VALUE rb_hash_fetch_values(int argc, VALUE *argv, VALUE hash) { VALUE result = rb_ary_new2(argc); long i; for (i=0; ihsh and returns it as the two-item array [ key, value ], or the hash's default value if the hash is empty. h = { 1 => "a", 2 => "b", 3 => "c" } h.shift #=> [1, "a"] h #=> {2=>"b", 3=>"c"} ;T;[o;H ;II" overload;F;J0;;;K0;#I" shift;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI" Object;T; @<;[;I"@return [Array, Object];T;0; @<;@F;Mi;N0;[; @<;[;I"ARemoves a key-value pair from hsh and returns it as the two-item array [ key, value ], or the hash's default value if the hash is empty. h = { 1 => "a", 2 => "b", 3 => "c" } h.shift #=> [1, "a"] h #=> {2=>"b", 3=>"c"} @overload shift @return [Array, Object];T;0; @<;@F;Ao;B;CT;DiP;EiZ;!@7;"I"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; ; F; ;,;;;I"Hash#delete;F;[[I"key;T0;[[@7i,;T;;p;0;[;{;IC;"Deletes the key-value pair and returns the value from hsh whose key is equal to key. If the key is not found, it returns nil. If the optional code block is given and the key is not found, pass in the key and return the result of block. h = { "a" => 100, "b" => 200 } h.delete("a") #=> 100 h.delete("z") #=> nil h.delete("z") { |el| "#{el} not found" } #=> "z not found" ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete(key);T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[[I"key;T0; @=o;H ;II" overload;F;J0;;p;K0;#I"delete(key);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @=;[;I"@yield [ key ];T;0; @=;@F;Mi;N0;[[I"key;T0; @=;[;I"Deletes the key-value pair and returns the value from hsh whose key is equal to key. If the key is not found, it returns nil. If the optional code block is given and the key is not found, pass in the key and return the result of block. h = { "a" => 100, "b" => 200 } h.delete("a") #=> 100 h.delete("z") #=> nil h.delete("z") { |el| "#{el} not found" } #=> "z not found" @overload delete(key) @overload delete(key) @yield [ key ];T;0; @=;@F;Ao;B;CT;Di;Ei);!@7;"I"'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; ; F; ;,;;;I"Hash#delete_if;F;[;[[@7i;T;:delete_if;0;[;{;IC;"Deletes every key-value pair from hsh for which block evaluates to true. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.delete_if {|key, value| key >= "b" } #=> {"a"=>100} ;T;[o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;=o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;=;[;I")@yield [ key, value ] @return [Hash];T;0; @;=;@F;Mi;N0;[; @;=o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[;[;I";T;0; @;=;@F;Mi;N0;[; @;=;[;I"[Deletes every key-value pair from hsh for which block evaluates to true. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.delete_if {|key, value| key >= "b" } #=> {"a"=>100} @overload delete_if @yield [ key, value ] @return [Hash] @overload delete_if;T;0; @;=;@F;Ao;B;CT;Di;Ei;!@7;"I"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; ; F; ;,;;;I"Hash#keep_if;F;[;[[@7i ;T;: keep_if;0;[;{;IC;"Deletes every key-value pair from hsh for which block evaluates to +false+. If no block is given, an enumerator is returned instead. See also Hash#select!. ;T;[o;H ;II" overload;F;J0;;;K0;#I" keep_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @d=o;L ;II" return;F;JI";T;0;K[I" Hash;T; @d=;[;I")@yield [ key, value ] @return [Hash];T;0; @d=;@F;Mi;N0;[; @d=o;H ;II" overload;F;J0;;;K0;#I" keep_if;T;IC;";T;[;[;I";T;0; @d=;@F;Mi;N0;[; @d=;[;I"Deletes every key-value pair from hsh for which block evaluates to +false+. If no block is given, an enumerator is returned instead. See also Hash#select!. @overload keep_if @yield [ key, value ] @return [Hash] @overload keep_if;T;0; @d=;@F;Ao;B;CT;Di ;Ei ;!@7;"I"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" VALUE;T;$To; ; F; ;,;;;I"Hash#select;F;[;[[@7i\ ;T;;;0;[;{;IC;"EReturns a new hash consisting of entries for which the block returns true. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300} h.select {|k,v| v < 200} #=> {"a" => 100} Hash#filter is an alias for Hash#select. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @=o;L ;II" return;F;JI";T;0;K[I" Hash;T; @=;[;I"'@yield [key, value] @return [Hash];T;0; @=;@F;Mi;N0;[; @=o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[; @=o;H ;II" overload;F;J0;: filter;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @=o;L ;II" return;F;JI";T;0;K[I" Hash;T; @=;[;I"'@yield [key, value] @return [Hash];T;0; @=;@F;Mi;N0;[; @=o;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[; @=;[;I"Returns a new hash consisting of entries for which the block returns true. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300} h.select {|k,v| v < 200} #=> {"a" => 100} Hash#filter is an alias for Hash#select. @overload select @yield [key, value] @return [Hash] @overload select @overload filter @yield [key, value] @return [Hash] @overload filter;T;0; @=;@F;Ao;B;CT;DiJ ;Ei\ ;!@7;"I"VALUE rb_hash_select(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = rb_hash_new(); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(hash, select_i, result); } return result; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Hash#select!;F;[;[[@7i ;T;: select!;0;[;{;IC;"wEquivalent to Hash#keep_if, but returns +nil+ if no changes were made. Hash#filter! is an alias for Hash#select!. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @=o;L ;II" return;F;JI";T;0;K[I" Hash;TI"nil;T; @=;[;I".@yield [ key, value ] @return [Hash, nil];T;0; @=;@F;Mi;N0;[; @=o;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[; @=o;H ;II" overload;F;J0;: filter!;K0;#I" filter!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @=o;L ;II" return;F;JI";T;0;K[I" Hash;TI"nil;T; @=;[;I".@yield [ key, value ] @return [Hash, nil];T;0; @=;@F;Mi;N0;[; @=o;H ;II" overload;F;J0;;;K0;#I" filter!;T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[; @=;[;I"Equivalent to Hash#keep_if, but returns +nil+ if no changes were made. Hash#filter! is an alias for Hash#select!. @overload select! @yield [ key, value ] @return [Hash, nil] @overload select! @overload filter! @yield [ key, value ] @return [Hash, nil] @overload filter!;T;0; @=;@F;Ao;B;CT;Dir ;Ei ;!@7;"I"1VALUE 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" VALUE;T;$To; ; F; ;,;;;I"Hash#filter;F;[;[[@7i\ ;T;;;0;[;{;IC;"EReturns a new hash consisting of entries for which the block returns true. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300} h.select {|k,v| v < 200} #=> {"a" => 100} Hash#filter is an alias for Hash#select. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @>o;L ;II" return;F;JI";T;0;K[I" Hash;T; @>;[;I"'@yield [key, value] @return [Hash];T;0; @>;@F;Mi;N0;[; @>o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[;[;I";T;0; @>;@F;Mi;N0;[; @>o;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @>o;L ;II" return;F;JI";T;0;K[I" Hash;T; @>;[;I"'@yield [key, value] @return [Hash];T;0; @>;@F;Mi;N0;[; @>o;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[;[;I";T;0; @>;@F;Mi;N0;[; @>;[;@=;0; @>;@F;Ao;B;CT;DiJ ;Ei\ ;!@7;"I"VALUE rb_hash_select(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = rb_hash_new(); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(hash, select_i, result); } return result; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Hash#filter!;F;[;[[@7i ;T;;;0;[;{;IC;"wEquivalent to Hash#keep_if, but returns +nil+ if no changes were made. Hash#filter! is an alias for Hash#select!. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @Z>o;L ;II" return;F;JI";T;0;K[I" Hash;TI"nil;T; @Z>;[;I".@yield [ key, value ] @return [Hash, nil];T;0; @Z>;@F;Mi;N0;[; @Z>o;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[;[;I";T;0; @Z>;@F;Mi;N0;[; @Z>o;H ;II" overload;F;J0;;;K0;#I" filter!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @Z>o;L ;II" return;F;JI";T;0;K[I" Hash;TI"nil;T; @Z>;[;I".@yield [ key, value ] @return [Hash, nil];T;0; @Z>;@F;Mi;N0;[; @Z>o;H ;II" overload;F;J0;;;K0;#I" filter!;T;IC;";T;[;[;I";T;0; @Z>;@F;Mi;N0;[; @Z>;[;@>;0; @Z>;@F;Ao;B;CT;Dir ;Ei ;!@7;"I"1VALUE 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" VALUE;T;$To; ; F; ;,;;;I"Hash#reject;F;[;[[@7i;T;: reject;0;[;{;IC;"Returns a new hash consisting of entries for which the block returns false. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.reject {|k,v| k < "b"} #=> {"b" => 200, "c" => 300} h.reject {|k,v| v > 100} #=> {"a" => 100} ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @>o;L ;II" return;F;JI";T;0;K[I" Hash;T; @>;[;I"'@yield [key, value] @return [Hash];T;0; @>;@F;Mi;N0;[; @>o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[;[;I";T;0; @>;@F;Mi;N0;[; @>;[;I"gReturns a new hash consisting of entries for which the block returns false. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.reject {|k,v| k < "b"} #=> {"b" => 200, "c" => 300} h.reject {|k,v| v > 100} #=> {"a" => 100} @overload reject @yield [key, value] @return [Hash] @overload reject;T;0; @>;@F;Ao;B;CT;Di;Ei;!@7;"I"VALUE rb_hash_reject(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); if (RTEST(ruby_verbose)) { VALUE klass; if (HAS_EXTRA_STATES(hash, klass)) { rb_warn("extra states are no longer copied: %+"PRIsVALUE, hash); } } result = rb_hash_new(); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(hash, reject_i, result); } return result; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Hash#reject!;F;[;[[@7i;T;: reject!;0;[;{;IC;"eEquivalent to Hash#delete_if, but returns nil if no changes were made. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @>o;L ;II" return;F;JI";T;0;K[I" Hash;TI"nil;T; @>;[;I".@yield [ key, value ] @return [Hash, nil];T;0; @>;@F;Mi;N0;[; @>o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[;[;I";T;0; @>;@F;Mi;N0;[; @>;[;I"Equivalent to Hash#delete_if, but returns nil if no changes were made. @overload reject! @yield [ key, value ] @return [Hash, nil] @overload reject!;T;0; @>;@F;Ao;B;CT;Di;Ei;!@7;"I"-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" VALUE;T;$To; ; F; ;,;;;I"Hash#slice;F;[[@0;[[@7i;T;;;0;[;{;IC;"Returns a hash containing only the given keys and their values. h = { a: 100, b: 200, c: 300 } h.slice(:a) #=> {:a=>100} h.slice(:b, :c, :d) #=> {:b=>200, :c=>300} ;T;[o;H ;II" overload;F;J0;;;K0;#I"slice(*keys);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @>;[;I"@return [Hash];T;0; @>;@F;Mi;N0;[[I" *keys;T0; @>;[;I"Returns a hash containing only the given keys and their values. h = { a: 100, b: 200, c: 300 } h.slice(:a) #=> {:a=>100} h.slice(:b, :c, :d) #=> {:b=>200, :c=>300} @overload slice(*keys) @return [Hash];T;0; @>;@F;Ao;B;CT;Di;Ei;!@7;"I"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 rb_hash_new(); } result = rb_hash_new_with_size(argc); 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; ; F; ;,;;;I"Hash#clear;F;[;[[@7i ;T;;3;0;[;{;IC;"Removes all key-value pairs from hsh. h = { "a" => 100, "b" => 200 } #=> {"a"=>100, "b"=>200} h.clear #=> {} ;T;[o;H ;II" overload;F;J0;;3;K0;#I" clear;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @?;[;I"@return [Hash];T;0; @?;@F;Mi;N0;[; @?;[;I"Removes all key-value pairs from hsh. h = { "a" => 100, "b" => 200 } #=> {"a"=>100, "b"=>200} h.clear #=> {} @overload clear @return [Hash];T;0; @?;@F;Ao;B;CT;Di ;Ei ;!@7;"I")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; ; F; ;,;;;I"Hash#invert;F;[;[[@7i ;T;: invert;0;[;{;IC;"Returns a new hash created by using hsh's values as keys, and the keys as values. If a key with the same value already exists in the hsh, then the last one defined will be used, the earlier value(s) will be discarded. h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 } h.invert #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"} If there is no key with the same value, Hash#invert is involutive. h = { a: 1, b: 3, c: 4 } h.invert.invert == h #=> true The condition, no key with the same value, can be tested by comparing the size of inverted hash. # no key with the same value h = { a: 1, b: 3, c: 4 } h.size == h.invert.size #=> true # two (or more) keys has the same value h = { a: 1, b: 3, c: 1 } h.size == h.invert.size #=> false ;T;[o;H ;II" overload;F;J0;;;K0;#I" invert;T;IC;";T;[;[;I";T;0; @+?;@F;Mi;N0;[; @+?;[;I"#Returns a new hash created by using hsh's values as keys, and the keys as values. If a key with the same value already exists in the hsh, then the last one defined will be used, the earlier value(s) will be discarded. h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 } h.invert #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"} If there is no key with the same value, Hash#invert is involutive. h = { a: 1, b: 3, c: 4 } h.invert.invert == h #=> true The condition, no key with the same value, can be tested by comparing the size of inverted hash. # no key with the same value h = { a: 1, b: 3, c: 4 } h.size == h.invert.size #=> true # two (or more) keys has the same value h = { a: 1, b: 3, c: 1 } h.size == h.invert.size #=> false @overload invert;T;0; @+?;@F;Ao;B;CT;Di ;Ei ;!@7;"I"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; ; F; ;,;;;I"Hash#update;F;[[@0;[[@7i;T;: update;0;[;{;IC;"Adds the contents of the given hashes to the receiver. If no block is given, entries with duplicate keys are overwritten with the values from each +other_hash+ successively, otherwise the value for each duplicate key is determined by calling the block with the key, its value in the receiver and its value in each +other_hash+. h1 = { "a" => 100, "b" => 200 } h1.merge! #=> {"a"=>100, "b"=>200} h1 #=> {"a"=>100, "b"=>200} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300} h1 #=> {"a"=>100, "b"=>246, "c"=>300} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge!(h2, h3) {|key, v1, v2| v1 } #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400} Hash#update is an alias for Hash#merge!. ;T;[ o;H ;II" overload;F;J0;: merge!;K0;#I"*merge!(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @A?;[;I"@return [Hash];T;0; @A?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @A?o;H ;II" overload;F;J0;;;K0;#I"*update(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @A?;[;I"@return [Hash];T;0; @A?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @A?o;H ;II" overload;F;J0;;;K0;#I"*merge!(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" oldval;TI" newval;T; @A?;[;I"!@yield [key, oldval, newval];T;0; @A?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @A?o;H ;II" overload;F;J0;;<;K0;#I" -> hsh;T;IC;";T;[;[;I";T;0; @A?;@F;Mi;N0;[; @A?o;H ;II" overload;F;J0;;;K0;#I"*update(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" oldval;TI" newval;T; @A?;[;I"!@yield [key, oldval, newval];T;0; @A?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @A?o;H ;II" overload;F;J0;;<;K0;#I" -> hsh;T;IC;";T;[;[;I";T;0; @A?;@F;Mi;N0;[; @A?;[;I"Adds the contents of the given hashes to the receiver. If no block is given, entries with duplicate keys are overwritten with the values from each +other_hash+ successively, otherwise the value for each duplicate key is determined by calling the block with the key, its value in the receiver and its value in each +other_hash+. h1 = { "a" => 100, "b" => 200 } h1.merge! #=> {"a"=>100, "b"=>200} h1 #=> {"a"=>100, "b"=>200} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300} h1 #=> {"a"=>100, "b"=>246, "c"=>300} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge!(h2, h3) {|key, v1, v2| v1 } #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400} Hash#update is an alias for Hash#merge!. @overload merge!(other_hash1, other_hash2, ...) @return [Hash] @overload update(other_hash1, other_hash2, ...) @return [Hash] @overload merge!(other_hash1, other_hash2, ...) @yield [key, oldval, newval] @overload -> hsh @overload update(other_hash1, other_hash2, ...) @yield [key, oldval, newval] @overload -> hsh;T;0; @A?;@F;Ao;B;CT;Di ;Ei;!@7;"I"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; ; F; ;,;;;I"Hash#replace;F;[[I" hash2;T0;[[@7iU ;T;;';0;[;{;IC;"Replaces the contents of hsh with the contents of other_hash. h = { "a" => 100, "b" => 200 } h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400} ;T;[o;H ;II" overload;F;J0;;';K0;#I"replace(other_hash);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @?;[;I"@return [Hash];T;0; @?;@F;Mi;N0;[[I"other_hash;T0; @?;[;I"Replaces the contents of hsh with the contents of other_hash. h = { "a" => 100, "b" => 200 } h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400} @overload replace(other_hash) @return [Hash];T;0; @?;@F;Ao;B;CT;DiI ;EiR ;!@7;"I"static VALUE rb_hash_replace(VALUE hash, VALUE hash2) { rb_hash_modify_check(hash); if (hash == hash2) return hash; hash2 = to_hash(hash2); COPY_DEFAULT(hash, hash2); rb_hash_clear(hash); if (RHASH_AR_TABLE_P(hash)) { if (RHASH_AR_TABLE_P(hash2)) { ar_copy(hash, hash2); } else { goto st_to_st; } } else { if (RHASH_AR_TABLE_P(hash2)) ar_force_convert_table(hash2, __FILE__, __LINE__); st_to_st: RHASH_TBL_RAW(hash)->type = RHASH_ST_TABLE(hash2)->type; rb_hash_foreach(hash2, replace_i, hash); } return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#merge!;F;[[@0;[[@7i;T;;;0;[;{;IC;"Adds the contents of the given hashes to the receiver. If no block is given, entries with duplicate keys are overwritten with the values from each +other_hash+ successively, otherwise the value for each duplicate key is determined by calling the block with the key, its value in the receiver and its value in each +other_hash+. h1 = { "a" => 100, "b" => 200 } h1.merge! #=> {"a"=>100, "b"=>200} h1 #=> {"a"=>100, "b"=>200} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300} h1 #=> {"a"=>100, "b"=>246, "c"=>300} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge!(h2, h3) {|key, v1, v2| v1 } #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400} Hash#update is an alias for Hash#merge!. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"*merge!(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @?;[;I"@return [Hash];T;0; @?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @?o;H ;II" overload;F;J0;;;K0;#I"*update(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @?;[;I"@return [Hash];T;0; @?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @?o;H ;II" overload;F;J0;;;K0;#I"*merge!(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" oldval;TI" newval;T; @?;[;I"!@yield [key, oldval, newval];T;0; @?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @?o;H ;II" overload;F;J0;;<;K0;#I" -> hsh;T;IC;";T;[;[;I";T;0; @?;@F;Mi;N0;[; @?o;H ;II" overload;F;J0;;;K0;#I"*update(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" oldval;TI" newval;T; @?;[;I"!@yield [key, oldval, newval];T;0; @?;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @?o;H ;II" overload;F;J0;;<;K0;#I" -> hsh;T;IC;";T;[;[;I";T;0; @?;@F;Mi;N0;[; @?;[;@?;0; @?;@F;Ao;B;CT;Di ;Ei;!@7;"I"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; ; F; ;,;;;I"Hash#merge;F;[[@0;[[@7i{;T;: merge;0;[;{;IC;"Returns a new hash that combines the contents of the receiver and the contents of the given hashes. If no block is given, entries with duplicate keys are overwritten with the values from each +other_hash+ successively, otherwise the value for each duplicate key is determined by calling the block with the key, its value in the receiver and its value in each +other_hash+. When called without any argument, returns a copy of the receiver. h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge #=> {"a"=>100, "b"=>200} h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300} h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1.merge(h2) {|key, oldval, newval| newval - oldval} #=> {"a"=>100, "b"=>46, "c"=>300} h1.merge(h2, h3) {|key, oldval, newval| newval - oldval} #=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>200} ;T;[o;H ;II" overload;F;J0;;;K0;#I")merge(other_hash1, other_hash2, ...);T;IC;";T;[;[;I";T;0; @=@;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @=@o;H ;II" overload;F;J0;;;K0;#I")merge(other_hash1, other_hash2, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" oldval;TI" newval;T; @=@;[;I"!@yield [key, oldval, newval];T;0; @=@;@F;Mi;N0;[[I"other_hash1;T0[I"other_hash2;T0[I"...;T0; @=@o;H ;II" overload;F;J0;;<;K0;#I"-> new_hash;T;IC;";T;[;[;I";T;0; @=@;@F;Mi;N0;[; @=@;[;I"|Returns a new hash that combines the contents of the receiver and the contents of the given hashes. If no block is given, entries with duplicate keys are overwritten with the values from each +other_hash+ successively, otherwise the value for each duplicate key is determined by calling the block with the key, its value in the receiver and its value in each +other_hash+. When called without any argument, returns a copy of the receiver. h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 246, "c" => 300 } h3 = { "b" => 357, "d" => 400 } h1.merge #=> {"a"=>100, "b"=>200} h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300} h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400} h1.merge(h2) {|key, oldval, newval| newval - oldval} #=> {"a"=>100, "b"=>46, "c"=>300} h1.merge(h2, h3) {|key, oldval, newval| newval - oldval} #=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400} h1 #=> {"a"=>100, "b"=>200} @overload merge(other_hash1, other_hash2, ...) @overload merge(other_hash1, other_hash2, ...) @yield [key, oldval, newval] @overload -> new_hash;T;0; @=@;@F;Ao;B;CT;Di\;Eix;!@7;"I"{static VALUE rb_hash_merge(int argc, VALUE *argv, VALUE self) { return rb_hash_update(argc, argv, rb_hash_dup(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#assoc;F;[[I"key;T0;[[@7i;T;: assoc;0;[;{;IC;"iSearches through the hash comparing _obj_ with the key using ==. Returns the key-value pair (two elements array) or +nil+ if no match is found. See Array#assoc. h = {"colors" => ["red", "blue", "green"], "letters" => ["a", "b", "c" ]} h.assoc("letters") #=> ["letters", ["a", "b", "c"]] h.assoc("foo") #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"assoc(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @w@;[;I"@return [Array, nil];T;0; @w@;@F;Mi;N0;[[I"obj;T0; @w@;[;I"Searches through the hash comparing _obj_ with the key using ==. Returns the key-value pair (two elements array) or +nil+ if no match is found. See Array#assoc. h = {"colors" => ["red", "blue", "green"], "letters" => ["a", "b", "c" ]} h.assoc("letters") #=> ["letters", ["a", "b", "c"]] h.assoc("foo") #=> nil @overload assoc(obj) @return [Array, nil];T;0; @w@;@F;Ao;B;CT;Di;Ei;!@7;"I"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" VALUE;T;$To; ; F; ;,;;;I"Hash#rassoc;F;[[I"obj;T0;[[@7i;T;: rassoc;0;[;{;IC;"6Searches through the hash comparing _obj_ with the value using ==. Returns the first key-value pair (two-element array) that matches. See also Array#rassoc. a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"} a.rassoc("two") #=> [2, "two"] a.rassoc("four") #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"rassoc(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @@;[;I"@return [Array, nil];T;0; @@;@F;Mi;N0;[[I"obj;T0; @@;[;I"eSearches through the hash comparing _obj_ with the value using ==. Returns the first key-value pair (two-element array) that matches. See also Array#rassoc. a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"} a.rassoc("two") #=> [2, "two"] a.rassoc("four") #=> nil @overload rassoc(obj) @return [Array, nil];T;0; @@;@F;Ao;B;CT;Di;Ei;!@7;"I"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" VALUE;T;$To; ; F; ;,;;;I"Hash#flatten;F;[[@0;[[@7i;T;: flatten;0;[;{;IC;"Returns a new array that is a one-dimensional flattening of this hash. That is, for every key or value that is an array, extract its elements into the new array. Unlike Array#flatten, this method does not flatten recursively by default. The optional level argument determines the level of recursion to flatten. a = {1=> "one", 2 => [2,"two"], 3 => "three"} a.flatten # => [1, "one", 2, [2, "two"], 3, "three"] a.flatten(2) # => [1, "one", 2, 2, "two", 3, "three"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" flatten;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @@;[;I"@return [Array];T;0; @@;@F;Mi;N0;[; @@o;H ;II" overload;F;J0;;;K0;#I"flatten(level);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @@;[;I"@return [Array];T;0; @@;@F;Mi;N0;[[I" level;T0; @@;[;I"7Returns a new array that is a one-dimensional flattening of this hash. That is, for every key or value that is an array, extract its elements into the new array. Unlike Array#flatten, this method does not flatten recursively by default. The optional level argument determines the level of recursion to flatten. a = {1=> "one", 2 => [2,"two"], 3 => "three"} a.flatten # => [1, "one", 2, [2, "two"], 3, "three"] a.flatten(2) # => [1, "one", 2, 2, "two", 3, "three"] @overload flatten @return [Array] @overload flatten(level) @return [Array];T;0; @@;@F;Ao;B;CT;Di ;Ei;!@7;"I"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; ; F; ;,;;;I"Hash#compact;F;[;[[@7iY;T;: compact;0;[;{;IC;"Returns a new hash with the nil values/key pairs removed h = { a: 1, b: false, c: nil } h.compact #=> { a: 1, b: false } h #=> { a: 1, b: false, c: nil } ;T;[o;H ;II" overload;F;J0;;;K0;#I" compact;T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[; @@;[;I"Returns a new hash with the nil values/key pairs removed h = { a: 1, b: false, c: nil } h.compact #=> { a: 1, b: false } h #=> { a: 1, b: false, c: nil } @overload compact;T;0; @@;@F;Ao;B;CT;DiM;EiU;!@7;"I"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; ; F; ;,;;;I"Hash#compact!;F;[;[[@7io;T;: compact!;0;[;{;IC;"Removes all nil values from the hash. Returns nil if no changes were made, otherwise returns the hash. h = { a: 1, b: false, c: nil } h.compact! #=> { a: 1, b: false } ;T;[o;H ;II" overload;F;J0;;;K0;#I" compact!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;TI"nil;T; @@;[;I"@return [Hash, nil];T;0; @@;@F;Mi;N0;[; @@;[;I"Removes all nil values from the hash. Returns nil if no changes were made, otherwise returns the hash. h = { a: 1, b: false, c: nil } h.compact! #=> { a: 1, b: false } @overload compact! @return [Hash, nil];T;0; @@;@F;Ao;B;CT;Dic;Eil;!@7;"I"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; ; F; ;,;;;I"Hash#include?;F;[[I"key;T0;[[@7i ;T;;U;0;[;{;IC;"GReturns true if the given key is present in hsh. h = { "a" => 100, "b" => 200 } h.has_key?("a") #=> true h.has_key?("z") #=> false Note that include? and member? do not test member equality using == as do other Enumerables. See also Enumerable#include?;T;[ o;H ;II" overload;F;J0;: has_key?;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @Ao;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @Ao;H ;II" overload;F;J0;: key?;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @Ao;H ;II" overload;F;J0;: member?;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @A;[;I"Returns true if the given key is present in hsh. h = { "a" => 100, "b" => 200 } h.has_key?("a") #=> true h.has_key?("z") #=> false Note that include? and member? do not test member equality using == as do other Enumerables. See also Enumerable#include? @overload has_key?(key) @return [Boolean] @overload include?(key) @return [Boolean] @overload key?(key) @return [Boolean] @overload member?(key) @return [Boolean];T;0; @A;@F;Ao;B;CT;Di ;Ei ;Mi;!@7;"I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { if (RHASH_AR_TABLE_P(hash) && ar_lookup(hash, key, 0)) { return Qtrue; } else if (RHASH_ST_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, 0)) { return Qtrue; } return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"Hash#member?;F;[[I"key;T0;[[@7i ;T;;;0;[;{;IC;"GReturns true if the given key is present in hsh. h = { "a" => 100, "b" => 200 } h.has_key?("a") #=> true h.has_key?("z") #=> false Note that include? and member? do not test member equality using == as do other Enumerables. See also Enumerable#include?;T;[ o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`A;[;I"@return [Boolean];T;0; @`A;@F;Mi;N0;[[I"key;T0; @`Ao;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`A;[;I"@return [Boolean];T;0; @`A;@F;Mi;N0;[[I"key;T0; @`Ao;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`A;[;I"@return [Boolean];T;0; @`A;@F;Mi;N0;[[I"key;T0; @`Ao;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`A;[;I"@return [Boolean];T;0; @`A;@F;Mi;N0;[[I"key;T0; @`A;[;@\A;0; @`A;@F;Ao;B;CT;Di ;Ei ;Mi;!@7;"I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { if (RHASH_AR_TABLE_P(hash) && ar_lookup(hash, key, 0)) { return Qtrue; } else if (RHASH_ST_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, 0)) { return Qtrue; } return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"Hash#has_key?;F;[[I"key;T0;[[@7i ;T;;;0;[;{;IC;"GReturns true if the given key is present in hsh. h = { "a" => 100, "b" => 200 } h.has_key?("a") #=> true h.has_key?("z") #=> false Note that include? and member? do not test member equality using == as do other Enumerables. See also Enumerable#include?;T;[ o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @Ao;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @Ao;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @Ao;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I"key;T0; @A;[;@\A;0; @A;@F;Ao;B;CT;Di ;Ei ;Mi;!@7;"I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { if (RHASH_AR_TABLE_P(hash) && ar_lookup(hash, key, 0)) { return Qtrue; } else if (RHASH_ST_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, 0)) { return Qtrue; } return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"Hash#has_value?;F;[[I"val;T0;[[@7i ;T;:has_value?;0;[;{;IC;"Returns true if the given value is present for some key in hsh. h = { "a" => 100, "b" => 200 } h.value?(100) #=> true h.value?(999) #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I"has_value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I" value;T0; @Ao;H ;II" overload;F;J0;: value?;K0;#I"value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[[I" value;T0; @A;[;I" Returns true if the given value is present for some key in hsh. h = { "a" => 100, "b" => 200 } h.value?(100) #=> true h.value?(999) #=> false @overload has_value?(value) @return [Boolean] @overload value?(value) @return [Boolean];T;0; @A;@F;Ao;B;CT;Di ;Ei ;Mi;!@7;"I"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; ; F; ;,;;;I"Hash#key?;F;[[I"key;T0;[[@7i ;T;;;0;[;{;IC;"GReturns true if the given key is present in hsh. h = { "a" => 100, "b" => 200 } h.has_key?("a") #=> true h.has_key?("z") #=> false Note that include? and member? do not test member equality using == as do other Enumerables. See also Enumerable#include?;T;[ o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$B;[;I"@return [Boolean];T;0; @$B;@F;Mi;N0;[[I"key;T0; @$Bo;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$B;[;I"@return [Boolean];T;0; @$B;@F;Mi;N0;[[I"key;T0; @$Bo;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$B;[;I"@return [Boolean];T;0; @$B;@F;Mi;N0;[[I"key;T0; @$Bo;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$B;[;I"@return [Boolean];T;0; @$B;@F;Mi;N0;[[I"key;T0; @$B;[;@\A;0; @$B;@F;Ao;B;CT;Di ;Ei ;Mi;!@7;"I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { if (RHASH_AR_TABLE_P(hash) && ar_lookup(hash, key, 0)) { return Qtrue; } else if (RHASH_ST_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, 0)) { return Qtrue; } return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"Hash#value?;F;[[I"val;T0;[[@7i ;T;;;0;[;{;IC;"Returns true if the given value is present for some key in hsh. h = { "a" => 100, "b" => 200 } h.value?(100) #=> true h.value?(999) #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I"has_value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @oB;[;I"@return [Boolean];T;0; @oB;@F;Mi;N0;[[I" value;T0; @oBo;H ;II" overload;F;J0;;;K0;#I"value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @oB;[;I"@return [Boolean];T;0; @oB;@F;Mi;N0;[[I" value;T0; @oB;[;@ B;0; @oB;@F;Ao;B;CT;Di ;Ei ;Mi;!@7;"I"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; ; F; ;,;;;I"Hash#compare_by_identity;F;[;[[@7i;T;:compare_by_identity;0;[;{;IC;"ZMakes hsh compare its keys by their identity, i.e. it will consider exact same objects as same keys. h1 = { "a" => 100, "b" => 200, :c => "c" } h1["a"] #=> 100 h1.compare_by_identity h1.compare_by_identity? #=> true h1["a".dup] #=> nil # different objects. h1[:c] #=> "c" # same symbols are all same. ;T;[o;H ;II" overload;F;J0;;;K0;#I"compare_by_identity;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @B;[;I"@return [Hash];T;0; @B;@F;Mi;N0;[; @B;[;I"Makes hsh compare its keys by their identity, i.e. it will consider exact same objects as same keys. h1 = { "a" => 100, "b" => 200, :c => "c" } h1["a"] #=> 100 h1.compare_by_identity h1.compare_by_identity? #=> true h1["a".dup] #=> nil # different objects. h1[:c] #=> "c" # same symbols are all same. @overload compare_by_identity @return [Hash];T;0; @B;@F;Ao;B;CT;Di};Ei;!@7;"I"istatic VALUE 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); rb_gc_force_recycle(tmp); return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Hash#compare_by_identity?;F;[;[[@7i;T;:compare_by_identity?;0;[;{;IC;"Returns true if hsh will compare its keys by their identity. Also see Hash#compare_by_identity.;T;[o;H ;II" overload;F;J0;;;K0;#I"compare_by_identity?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @B;[;I"@return [Boolean];T;0; @B;@F;Mi;N0;[; @B;[;I"Returns true if hsh will compare its keys by their identity. Also see Hash#compare_by_identity. @overload compare_by_identity? @return [Boolean];T;0; @B;@F;Ao;B;CT;Di;Ei;Mi;!@7;"I"MJIT_FUNC_EXPORTED VALUE rb_hash_compare_by_id_p(VALUE hash) { if (RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash) { return Qtrue; } else { return Qfalse; } };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"Hash#any?;F;[[@0;[[@7i;T;: any?;0;[;{;IC;"See also Enumerable#any?;T;[o;H ;II" overload;F;J0;;;K0;#I" any?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"(key, value);T; @Bo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @B;[;I",@yield [(key, value)] @return [Boolean];T;0; @B;@F;Mi;N0;[; @Bo;H ;II" overload;F;J0;;;K0;#I"any?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @B;[;I"@return [Boolean];T;0; @B;@F;Mi;N0;[[I" pattern;T0; @B;[;I"See also Enumerable#any? @overload any? @yield [(key, value)] @return [Boolean] @overload any?(pattern) @return [Boolean];T;0; @B;@F;Ao;B;CT;Di;Ei;Mi;!@7;"I"wstatic 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_arity() > 1) 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; ; F; ;,;;;I" Hash#dig;F;[[@0;[[@7i&;T;:dig;0;[;{;IC;"Extracts the nested value specified by the sequence of key objects by calling +dig+ at each step, returning +nil+ if any intermediate step is +nil+. h = { foo: {bar: {baz: 1}}} h.dig(:foo, :bar, :baz) #=> 1 h.dig(:foo, :zot, :xyz) #=> nil g = { foo: [10, 11, 12] } g.dig(:foo, 1) #=> 11 g.dig(:foo, 1, 0) #=> TypeError: Integer does not have #dig method g.dig(:foo, :bar) #=> TypeError: no implicit conversion of Symbol into Integer ;T;[o;H ;II" overload;F;J0;;;K0;#I"dig(key, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @C;[;I"@return [Object];T;0; @C;@F;Mi;N0;[[I"key;T0[I"...;T0; @C;[;I"Extracts the nested value specified by the sequence of key objects by calling +dig+ at each step, returning +nil+ if any intermediate step is +nil+. h = { foo: {bar: {baz: 1}}} h.dig(:foo, :bar, :baz) #=> 1 h.dig(:foo, :zot, :xyz) #=> nil g = { foo: [10, 11, 12] } g.dig(:foo, 1) #=> 11 g.dig(:foo, 1, 0) #=> TypeError: Integer does not have #dig method g.dig(:foo, :bar) #=> TypeError: no implicit conversion of Symbol into Integer @overload dig(key, ...) @return [Object];T;0; @C;@F;Ao;B;CT;Di;Ei#;!@7;"I"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; ; F; ;,;;;I" Hash#<=;F;[[I" other;T0;[[@7iQ;T;;;0;[;{;IC;"Returns true if hash is subset of other or equals to other. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 <= h2 #=> true h2 <= h1 #=> false h1 <= h1 #=> true ;T;[o;H ;II" overload;F;J0;;;K0;#I"<=(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @"C;[;I"@return [Boolean];T;0; @"C;@F;Mi;N0;[[I" other;T0; @"C;[;I"Returns true if hash is subset of other or equals to other. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 <= h2 #=> true h2 <= h1 #=> false h1 <= h1 #=> true @overload <=(other) @return [Boolean];T;0; @"C;@F;Ao;B;CT;DiD;EiO;!@7;"I"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; ; F; ;,;;;I" Hash#<;F;[[I" other;T0;[[@7if;T;;;0;[;{;IC;"Returns true if hash is subset of other. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 < h2 #=> true h2 < h1 #=> false h1 < h1 #=> false ;T;[o;H ;II" overload;F;J0;;;K0;#I" <(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @AC;[;I"@return [Boolean];T;0; @AC;@F;Mi;N0;[[I" other;T0; @AC;[;I"Returns true if hash is subset of other. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 < h2 #=> true h2 < h1 #=> false h1 < h1 #=> false @overload <(other) @return [Boolean];T;0; @AC;@F;Ao;B;CT;DiY;Eid;!@7;"I"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; ; F; ;,;;;I" Hash#>=;F;[[I" other;T0;[[@7i{;T;;;0;[;{;IC;"Returns true if other is subset of hash or equals to hash. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 >= h2 #=> false h2 >= h1 #=> true h1 >= h1 #=> true ;T;[o;H ;II" overload;F;J0;;;K0;#I">=(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`C;[;I"@return [Boolean];T;0; @`C;@F;Mi;N0;[[I" other;T0; @`C;[;I"Returns true if other is subset of hash or equals to hash. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 >= h2 #=> false h2 >= h1 #=> true h1 >= h1 #=> true @overload >=(other) @return [Boolean];T;0; @`C;@F;Ao;B;CT;Din;Eiy;!@7;"I"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; ; F; ;,;;;I" Hash#>;F;[[I" other;T0;[[@7i;T;;;0;[;{;IC;"Returns true if other is subset of hash. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 > h2 #=> false h2 > h1 #=> true h1 > h1 #=> false ;T;[o;H ;II" overload;F;J0;;;K0;#I" >(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @C;[;I"@return [Boolean];T;0; @C;@F;Mi;N0;[[I" other;T0; @C;[;I"Returns true if other is subset of hash. h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} h1 > h2 #=> false h2 > h1 #=> true h1 > h1 #=> false @overload >(other) @return [Boolean];T;0; @C;@F;Ao;B;CT;Di;Ei;!@7;"I"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;$T;&@7;'IC;[;&@7;(IC;[o; ;IC;[>o; ; F; ;,;;;I"Enumerable#chain;F;[[@0;[[@iv ;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;H ;II" overload;F;J0;;;K0;#I"chain(*enums);T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[[I" *enums;T0; @C;[;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; @C;@F;Ao;B;CT;Dil ;Eis ;!@C;"I"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 enum_chain_initialize(enum_chain_allocate(rb_cEnumChain), enums); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#lazy;F;[;[[@i;T;: lazy;0;[;{;IC;"FReturns a lazy enumerator, whose methods map/collect, flat_map/collect_concat, select/find_all, reject, grep, grep_v, zip, take, take_while, drop, and drop_while enumerate values only on an as-needed basis. However, if a block is given to zip, values are enumerated immediately. === 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;H ;II" overload;F;J0;;;K0;#I" lazy;T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[; @C;[;I"WReturns a lazy enumerator, whose methods map/collect, flat_map/collect_concat, select/find_all, reject, grep, grep_v, zip, take, take_while, drop, and drop_while enumerate values only on an as-needed basis. However, if a block is given to zip, values are enumerated immediately. === 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; @C;@F;Ao;B;CT;Di;Ei;!@C;"I"static VALUE enumerable_lazy(VALUE obj) { VALUE result = lazy_to_enum_i(obj, sym_each, 0, 0, lazyenum_size); /* 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; ; F; ;,;;;I"Enumerable#to_a;F;[[@0;[[I" enum.c;Ti[;T;;;0;[;{;IC;"Returns an array containing the items in enum. (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7] { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]] require 'prime' Prime.entries 10 #=> [2, 3, 5, 7] ;T;[o;H ;II" overload;F;J0;;;K0;#I"to_a(*args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @C;[;I"@return [Array];T;0; @C;@F;Mi;N0;[[I" *args;T0; @Co;H ;II" overload;F;J0;: entries;K0;#I"entries(*args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @C;[;I"@return [Array];T;0; @C;@F;Mi;N0;[[I" *args;T0; @C;[;I"\Returns an array containing the items in enum. (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7] { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]] require 'prime' Prime.entries 10 #=> [2, 3, 5, 7] @overload to_a(*args) @return [Array] @overload entries(*args) @return [Array];T;0; @C;@F;Ao;B;CT;DiN;EiZ;!@C;"I"static VALUE enum_to_a(int argc, VALUE *argv, VALUE obj) { VALUE ary = rb_ary_new(); rb_block_call(obj, id_each, argc, argv, collect_all, ary); OBJ_INFECT(ary, obj); return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#entries;F;[[@0;[[@Ci[;T;;;0;[;{;IC;"Returns an array containing the items in enum. (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7] { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]] require 'prime' Prime.entries 10 #=> [2, 3, 5, 7] ;T;[o;H ;II" overload;F;J0;;;K0;#I"to_a(*args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @C;[;I"@return [Array];T;0; @C;@F;Mi;N0;[[I" *args;T0; @Co;H ;II" overload;F;J0;;;K0;#I"entries(*args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @C;[;I"@return [Array];T;0; @C;@F;Mi;N0;[[I" *args;T0; @C;[;@C;0; @C;@F;Ao;B;CT;DiN;EiZ;!@C;"I"static VALUE enum_to_a(int argc, VALUE *argv, VALUE obj) { VALUE ary = rb_ary_new(); rb_block_call(obj, id_each, argc, argv, collect_all, ary); OBJ_INFECT(ary, obj); return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#to_h;F;[[@0;[[@Ci;T;;;0;[;{;IC;"TReturns the result of interpreting enum as a list of [key, value] pairs. %i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1} If a block is given, the results of the block on each element of the enum will be used as pairs. (1..5).to_h {|x| [x, x ** 2]} #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25} ;T;[o;H ;II" overload;F;J0;;;K0;#I"to_h(*args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @+D;[;I"@return [Hash];T;0; @+D;@F;Mi;N0;[[I" *args;T0; @+Do;H ;II" overload;F;J0;;;K0;#I"to_h(*args);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @+Do;L ;II" return;F;JI";T;0;K[I" Hash;T; @+D;[;I"@yield [] @return [Hash];T;0; @+D;@F;Mi;N0;[[I" *args;T0; @+D;[;I"Returns the result of interpreting enum as a list of [key, value] pairs. %i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1} If a block is given, the results of the block on each element of the enum will be used as pairs. (1..5).to_h {|x| [x, x ** 2]} #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25} @overload to_h(*args) @return [Hash] @overload to_h(*args) @yield [] @return [Hash];T;0; @+D;@F;Ao;B;CT;Diu;Ei;!@C;"I"static VALUE enum_to_h(int argc, VALUE *argv, VALUE obj) { VALUE hash = rb_hash_new(); rb_block_call_func *iter = rb_block_given_p() ? enum_to_h_ii : enum_to_h_i; rb_block_call(obj, id_each, argc, argv, iter, hash); OBJ_INFECT(hash, obj); return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#sort;F;[;[[@Ci;T;: sort;0;[;{;IC;"Returns an array containing the items in enum sorted. Comparisons for the sort will be done using the items' own <=> operator or using an optional code block. The block must implement a comparison between +a+ and +b+ and return an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ are equivalent, or an integer greater than 0 when +a+ follows +b+. The result is not guaranteed to be stable. When the comparison of two elements returns +0+, the order of the elements is unpredictable. %w(rhea kea flea).sort #=> ["flea", "kea", "rhea"] (1..10).sort { |a, b| b <=> a } #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] See also Enumerable#sort_by. It implements a Schwartzian transform which is useful when key computation or comparison is expensive. ;T;[o;H ;II" overload;F;J0;;;K0;#I" sort;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @[D;[;I"@return [Array];T;0; @[D;@F;Mi;N0;[; @[Do;H ;II" overload;F;J0;;;K0;#I" sort;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @[Do;L ;II" return;F;JI";T;0;K[I" Array;T; @[D;[;I""@yield [a, b] @return [Array];T;0; @[D;@F;Mi;N0;[; @[D;[;I"jReturns an array containing the items in enum sorted. Comparisons for the sort will be done using the items' own <=> operator or using an optional code block. The block must implement a comparison between +a+ and +b+ and return an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ are equivalent, or an integer greater than 0 when +a+ follows +b+. The result is not guaranteed to be stable. When the comparison of two elements returns +0+, the order of the elements is unpredictable. %w(rhea kea flea).sort #=> ["flea", "kea", "rhea"] (1..10).sort { |a, b| b <=> a } #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] See also Enumerable#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; @[D;@F;Ao;B;CT;Di;Ei;!@C;"I"]static VALUE enum_sort(VALUE obj) { return rb_ary_sort_bang(enum_to_a(0, 0, obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#sort_by;F;[;[[@Civ;T;: sort_by;0;[;{;IC;"Z Sorts enum using a set of keys generated by mapping the values in enum through the given block. The result is not guaranteed to be stable. When two keys are equal, the order of the corresponding elements is unpredictable. If no block is given, an enumerator is returned instead. %w{apple pear fig}.sort_by { |word| word.length } #=> ["fig", "pear", "apple"] 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"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" sort_by;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Do;L ;II" return;F;JI";T;0;K[I" Array;T; @D;[;I"!@yield [obj] @return [Array];T;0; @D;@F;Mi;N0;[; @Do;H ;II" overload;F;J0;;;K0;#I" sort_by;T;IC;";T;[;[;I";T;0; @D;@F;Mi;N0;[; @D;[;I" Sorts enum using a set of keys generated by mapping the values in enum through the given block. The result is not guaranteed to be stable. When two keys are equal, the order of the corresponding elements is unpredictable. If no block is given, an enumerator is returned instead. %w{apple pear fig}.sort_by { |word| word.length } #=> ["fig", "pear", "apple"] 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"] @overload sort_by @yield [obj] @return [Array] @overload sort_by;T;0; @D;@F;Ao;B;CT;Di,;Eit;!@C;"I"Mstatic 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); OBJ_INFECT(memo, obj); 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; ienum for which Pattern === element. If the optional block is supplied, each matching element is passed to it, and the block's result is stored in the output array. (1..100).grep 38..44 #=> [38, 39, 40, 41, 42, 43, 44] c = IO.constants c.grep(/SEEK/) #=> [:SEEK_SET, :SEEK_CUR, :SEEK_END] res = c.grep(/SEEK/) { |v| IO.const_get(v) } res #=> [0, 1, 2] ;T;[o;H ;II" overload;F;J0;; ;K0;#I"grep(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @D;[;I"@return [Array];T;0; @D;@F;Mi;N0;[[I" pattern;T0; @Do;H ;II" overload;F;J0;; ;K0;#I"grep(pattern);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Do;L ;II" return;F;JI";T;0;K[I" Array;T; @D;[;I"!@yield [obj] @return [Array];T;0; @D;@F;Mi;N0;[[I" pattern;T0; @D;[;I"3Returns an array of every element in enum for which Pattern === element. If the optional block is supplied, each matching element is passed to it, and the block's result is stored in the output array. (1..100).grep 38..44 #=> [38, 39, 40, 41, 42, 43, 44] c = IO.constants c.grep(/SEEK/) #=> [:SEEK_SET, :SEEK_CUR, :SEEK_END] res = c.grep(/SEEK/) { |v| IO.const_get(v) } res #=> [0, 1, 2] @overload grep(pattern) @return [Array] @overload grep(pattern) @yield [obj] @return [Array];T;0; @D;@F;Ao;B;CT;Di`;Eiq;!@C;"I"static VALUE enum_grep(VALUE obj, VALUE pat) { VALUE ary = rb_ary_new(); struct MEMO *memo = MEMO_NEW(pat, ary, Qtrue); rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)memo); return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#grep_v;F;[[I"pat;T0;[[@Ci;T;: grep_v;0;[;{;IC;"Inverted version of Enumerable#grep. Returns an array of every element in enum for which not Pattern === element. (1..10).grep_v 2..5 #=> [1, 6, 7, 8, 9, 10] res =(1..10).grep_v(2..5) { |v| v * 2 } res #=> [2, 12, 14, 16, 18, 20] ;T;[o;H ;II" overload;F;J0;; ;K0;#I"grep_v(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @D;[;I"@return [Array];T;0; @D;@F;Mi;N0;[[I" pattern;T0; @Do;H ;II" overload;F;J0;; ;K0;#I"grep_v(pattern);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Do;L ;II" return;F;JI";T;0;K[I" Array;T; @D;[;I"!@yield [obj] @return [Array];T;0; @D;@F;Mi;N0;[[I" pattern;T0; @D;[;I"Inverted version of Enumerable#grep. Returns an array of every element in enum for which not Pattern === element. (1..10).grep_v 2..5 #=> [1, 6, 7, 8, 9, 10] res =(1..10).grep_v(2..5) { |v| v * 2 } res #=> [2, 12, 14, 16, 18, 20] @overload grep_v(pattern) @return [Array] @overload grep_v(pattern) @yield [obj] @return [Array];T;0; @D;@F;Ao;B;CT;Di};Ei;!@C;"I"static VALUE enum_grep_v(VALUE obj, VALUE pat) { VALUE ary = rb_ary_new(); struct MEMO *memo = MEMO_NEW(pat, ary, Qfalse); rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)memo); return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#count;F;[[@0;[[@Ci;T;;r;0;[;{;IC;"_Returns the number of items in +enum+ through enumeration. If an argument is given, the number of items in +enum+ that are equal to +item+ are counted. If a block is given, it counts the number of elements yielding a true value. ary = [1, 2, 4, 2] ary.count #=> 4 ary.count(2) #=> 2 ary.count{ |x| x%2==0 } #=> 3 ;T;[o;H ;II" overload;F;J0;;r;K0;#I" count;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @E;[;I"@return [Integer];T;0; @E;@F;Mi;N0;[; @Eo;H ;II" overload;F;J0;;r;K0;#I"count(item);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @E;[;I"@return [Integer];T;0; @E;@F;Mi;N0;[[I" item;T0; @Eo;H ;II" overload;F;J0;;r;K0;#I" count;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Eo;L ;II" return;F;JI";T;0;K[I" Integer;T; @E;[;I"#@yield [obj] @return [Integer];T;0; @E;@F;Mi;N0;[; @E;[;I"Returns the number of items in +enum+ through enumeration. If an argument is given, the number of items in +enum+ that are equal to +item+ are counted. If a block is given, it counts the number of elements yielding a true value. ary = [1, 2, 4, 2] ary.count #=> 4 ary.count(2) #=> 2 ary.count{ |x| x%2==0 } #=> 3 @overload count @return [Integer] @overload count(item) @return [Integer] @overload count @yield [obj] @return [Integer];T;0; @E;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#find;F;[[@0;[[@Ci#;T;;;0;[;{;IC;"Passes each entry in enum to block. Returns the first for which block is not false. If no object matches, calls ifnone and returns its result when it is specified, or returns nil otherwise. If no block is given, an enumerator is returned instead. (1..100).detect #=> # (1..100).find #=> # (1..10).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..10).find { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..100).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 (1..100).find { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 ;T;[ o;H ;II" overload;F;J0;: detect;K0;#I"detect(ifnone = nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @TEo;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @TE;[;I"'@yield [obj] @return [Object, nil];T;0; @TE;@F;Mi;N0;[[I" ifnone;TI"nil;T; @TEo;H ;II" overload;F;J0;;;K0;#I"find(ifnone = nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @TEo;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @TE;[;I"'@yield [obj] @return [Object, nil];T;0; @TE;@F;Mi;N0;[[I" ifnone;TI"nil;T; @TEo;H ;II" overload;F;J0;; ;K0;#I"detect(ifnone = nil);T;IC;";T;[;[;I";T;0; @TE;@F;Mi;N0;[[I" ifnone;TI"nil;T; @TEo;H ;II" overload;F;J0;;;K0;#I"find(ifnone = nil);T;IC;";T;[;[;I";T;0; @TE;@F;Mi;N0;[[I" ifnone;TI"nil;T; @TE;[;I"VPasses each entry in enum to block. Returns the first for which block is not false. If no object matches, calls ifnone and returns its result when it is specified, or returns nil otherwise. If no block is given, an enumerator is returned instead. (1..100).detect #=> # (1..100).find #=> # (1..10).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..10).find { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..100).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 (1..100).find { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 @overload detect(ifnone = nil) @yield [obj] @return [Object, nil] @overload find(ifnone = nil) @yield [obj] @return [Object, nil] @overload detect(ifnone = nil) @overload find(ifnone = nil);T;0; @TE;@F;Ao;B;CT;Di ;Ei#;!@C;"I"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; ; F; ;,;;;I"Enumerable#detect;F;[[@0;[[@Ci#;T;; ;0;[;{;IC;"Passes each entry in enum to block. Returns the first for which block is not false. If no object matches, calls ifnone and returns its result when it is specified, or returns nil otherwise. If no block is given, an enumerator is returned instead. (1..100).detect #=> # (1..100).find #=> # (1..10).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..10).find { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..100).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 (1..100).find { |i| i % 5 == 0 and i % 7 == 0 } #=> 35 ;T;[ o;H ;II" overload;F;J0;; ;K0;#I"detect(ifnone = nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Eo;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @E;[;I"'@yield [obj] @return [Object, nil];T;0; @E;@F;Mi;N0;[[I" ifnone;TI"nil;T; @Eo;H ;II" overload;F;J0;;;K0;#I"find(ifnone = nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Eo;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @E;[;I"'@yield [obj] @return [Object, nil];T;0; @E;@F;Mi;N0;[[I" ifnone;TI"nil;T; @Eo;H ;II" overload;F;J0;; ;K0;#I"detect(ifnone = nil);T;IC;";T;[;[;I";T;0; @E;@F;Mi;N0;[[I" ifnone;TI"nil;T; @Eo;H ;II" overload;F;J0;;;K0;#I"find(ifnone = nil);T;IC;";T;[;[;I";T;0; @E;@F;Mi;N0;[[I" ifnone;TI"nil;T; @E;[;@E;0; @E;@F;Ao;B;CT;Di ;Ei#;!@C;"I"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; ; F; ;,;;;I"Enumerable#find_index;F;[[@0;[[@Cie;T;:find_index;0;[;{;IC;"Compares each entry in enum with value or passes to block. Returns the index for the first for which the evaluated value is non-false. If no object matches, returns nil If neither block nor argument is given, an enumerator is returned instead. (1..10).find_index { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..100).find_index { |i| i % 5 == 0 and i % 7 == 0 } #=> 34 (1..100).find_index(50) #=> 49 ;T;[o;H ;II" overload;F;J0;; ;K0;#I"find_index(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @E;[;I"@return [Integer, nil];T;0; @E;@F;Mi;N0;[[I" value;T0; @Eo;H ;II" overload;F;J0;; ;K0;#I"find_index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Eo;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @E;[;I"(@yield [obj] @return [Integer, nil];T;0; @E;@F;Mi;N0;[; @Eo;H ;II" overload;F;J0;; ;K0;#I"find_index;T;IC;";T;[;[;I";T;0; @E;@F;Mi;N0;[; @E;[;I"kCompares each entry in enum with value or passes to block. Returns the index for the first for which the evaluated value is non-false. If no object matches, returns nil If neither block nor argument is given, an enumerator is returned instead. (1..10).find_index { |i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..100).find_index { |i| i % 5 == 0 and i % 7 == 0 } #=> 34 (1..100).find_index(50) #=> 49 @overload find_index(value) @return [Integer, nil] @overload find_index @yield [obj] @return [Integer, nil] @overload find_index;T;0; @E;@F;Ao;B;CT;DiR;Eid;!@C;"I"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; ; F; ;,;;;I"Enumerable#find_all;F;[;[[@Ci;T;: find_all;0;[;{;IC;"fReturns an array containing all elements of +enum+ for which the given +block+ returns a true value. If no block is given, an Enumerator is returned instead. (1..10).find_all { |i| i % 3 == 0 } #=> [3, 6, 9] [1,2,3,4,5].select { |num| num.even? } #=> [2, 4] [:foo, :bar].filter { |x| x == :foo } #=> [:foo] See also Enumerable#reject. ;T;[ o;H ;II" overload;F;J0;; ;K0;#I" find_all;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @/Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @/F;[;I"!@yield [obj] @return [Array];T;0; @/F;@F;Mi;N0;[; @/Fo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @/Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @/F;[;I"!@yield [obj] @return [Array];T;0; @/F;@F;Mi;N0;[; @/Fo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @/Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @/F;[;I"!@yield [obj] @return [Array];T;0; @/F;@F;Mi;N0;[; @/Fo;H ;II" overload;F;J0;; ;K0;#I" find_all;T;IC;";T;[;[;I";T;0; @/F;@F;Mi;N0;[; @/Fo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[;[;I";T;0; @/F;@F;Mi;N0;[; @/Fo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[;[;I";T;0; @/F;@F;Mi;N0;[; @/F;[;I"5Returns an array containing all elements of +enum+ for which the given +block+ returns a true value. If no block is given, an Enumerator is returned instead. (1..10).find_all { |i| i % 3 == 0 } #=> [3, 6, 9] [1,2,3,4,5].select { |num| num.even? } #=> [2, 4] [:foo, :bar].filter { |x| x == :foo } #=> [:foo] See also Enumerable#reject. @overload find_all @yield [obj] @return [Array] @overload select @yield [obj] @return [Array] @overload filter @yield [obj] @return [Array] @overload find_all @overload select @overload filter;T;0; @/F;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#select;F;[;[[@Ci;T;;;0;[;{;IC;"fReturns an array containing all elements of +enum+ for which the given +block+ returns a true value. If no block is given, an Enumerator is returned instead. (1..10).find_all { |i| i % 3 == 0 } #=> [3, 6, 9] [1,2,3,4,5].select { |num| num.even? } #=> [2, 4] [:foo, :bar].filter { |x| x == :foo } #=> [:foo] See also Enumerable#reject. ;T;[ o;H ;II" overload;F;J0;; ;K0;#I" find_all;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @F;[;I"!@yield [obj] @return [Array];T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @F;[;I"!@yield [obj] @return [Array];T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @F;[;I"!@yield [obj] @return [Array];T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;; ;K0;#I" find_all;T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[; @F;[;@F;0; @F;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#filter;F;[;[[@Ci;T;;;0;[;{;IC;"fReturns an array containing all elements of +enum+ for which the given +block+ returns a true value. If no block is given, an Enumerator is returned instead. (1..10).find_all { |i| i % 3 == 0 } #=> [3, 6, 9] [1,2,3,4,5].select { |num| num.even? } #=> [2, 4] [:foo, :bar].filter { |x| x == :foo } #=> [:foo] See also Enumerable#reject. ;T;[ o;H ;II" overload;F;J0;; ;K0;#I" find_all;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @F;[;I"!@yield [obj] @return [Array];T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @F;[;I"!@yield [obj] @return [Array];T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Fo;L ;II" return;F;JI";T;0;K[I" Array;T; @F;[;I"!@yield [obj] @return [Array];T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;; ;K0;#I" find_all;T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[; @Fo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[; @F;[;@F;0; @F;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#reject;F;[;[[@Ci;T;;;0;[;{;IC;"=Returns an array for all elements of +enum+ for which the given +block+ returns false. If no block is given, an Enumerator is returned instead. (1..10).reject { |i| i % 3 == 0 } #=> [1, 2, 4, 5, 7, 8, 10] [1, 2, 3, 4, 5].reject { |num| num.even? } #=> [1, 3, 5] See also Enumerable#find_all. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @AGo;L ;II" return;F;JI";T;0;K[I" Array;T; @AG;[;I"!@yield [obj] @return [Array];T;0; @AG;@F;Mi;N0;[; @AGo;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[;[;I";T;0; @AG;@F;Mi;N0;[; @AG;[;I"Returns an array for all elements of +enum+ for which the given +block+ returns false. If no block is given, an Enumerator is returned instead. (1..10).reject { |i| i % 3 == 0 } #=> [1, 2, 4, 5, 7, 8, 10] [1, 2, 3, 4, 5].reject { |num| num.even? } #=> [1, 3, 5] See also Enumerable#find_all. @overload reject @yield [obj] @return [Array] @overload reject;T;0; @AG;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#collect;F;[;[[@Ci;T;: collect;0;[;{;IC;"Returns a new array with the results of running block once for every element in enum. If no block is given, an enumerator is returned instead. (1..4).map { |i| i*i } #=> [1, 4, 9, 16] (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @iGo;L ;II" return;F;JI";T;0;K[I" Array;T; @iG;[;I"!@yield [obj] @return [Array];T;0; @iG;@F;Mi;N0;[; @iGo;H ;II" overload;F;J0;:map;K0;#I"map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @iGo;L ;II" return;F;JI";T;0;K[I" Array;T; @iG;[;I"!@yield [obj] @return [Array];T;0; @iG;@F;Mi;N0;[; @iGo;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[;[;I";T;0; @iG;@F;Mi;N0;[; @iGo;H ;II" overload;F;J0;;;K0;#I"map;T;IC;";T;[;[;I";T;0; @iG;@F;Mi;N0;[; @iG;[;I"Returns a new array with the results of running block once for every element in enum. If no block is given, an enumerator is returned instead. (1..4).map { |i| i*i } #=> [1, 4, 9, 16] (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"] @overload collect @yield [obj] @return [Array] @overload map @yield [obj] @return [Array] @overload collect @overload map;T;0; @iG;@F;Ao;B;CT;Di;Ei;!@C;"I"/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; ; F; ;,;;;I"Enumerable#map;F;[;[[@Ci;T;;;0;[;{;IC;"Returns a new array with the results of running block once for every element in enum. If no block is given, an enumerator is returned instead. (1..4).map { |i| i*i } #=> [1, 4, 9, 16] (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Go;L ;II" return;F;JI";T;0;K[I" Array;T; @G;[;I"!@yield [obj] @return [Array];T;0; @G;@F;Mi;N0;[; @Go;H ;II" overload;F;J0;;;K0;#I"map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Go;L ;II" return;F;JI";T;0;K[I" Array;T; @G;[;I"!@yield [obj] @return [Array];T;0; @G;@F;Mi;N0;[; @Go;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[;[;I";T;0; @G;@F;Mi;N0;[; @Go;H ;II" overload;F;J0;;;K0;#I"map;T;IC;";T;[;[;I";T;0; @G;@F;Mi;N0;[; @G;[;@G;0; @G;@F;Ao;B;CT;Di;Ei;!@C;"I"/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; ; F; ;,;;;I"Enumerable#flat_map;F;[;[[@CiA;T;: flat_map;0;[;{;IC;"AReturns a new array with the concatenated results of running block once for every element in enum. If no block is given, an enumerator is returned instead. [1, 2, 3, 4].flat_map { |e| [e, -e] } #=> [1, -1, 2, -2, 3, -3, 4, -4] [[1, 2], [3, 4]].flat_map { |e| e + [100] } #=> [1, 2, 100, 3, 4, 100] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" flat_map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Go;L ;II" return;F;JI";T;0;K[I" Array;T; @G;[;I"!@yield [obj] @return [Array];T;0; @G;@F;Mi;N0;[; @Go;H ;II" overload;F;J0;:collect_concat;K0;#I"collect_concat;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Go;L ;II" return;F;JI";T;0;K[I" Array;T; @G;[;I"!@yield [obj] @return [Array];T;0; @G;@F;Mi;N0;[; @Go;H ;II" overload;F;J0;;;K0;#I" flat_map;T;IC;";T;[;[;I";T;0; @G;@F;Mi;N0;[; @Go;H ;II" overload;F;J0;;;K0;#I"collect_concat;T;IC;";T;[;[;I";T;0; @G;@F;Mi;N0;[; @G;[;I"Returns a new array with the concatenated results of running block once for every element in enum. If no block is given, an enumerator is returned instead. [1, 2, 3, 4].flat_map { |e| [e, -e] } #=> [1, -1, 2, -2, 3, -3, 4, -4] [[1, 2], [3, 4]].flat_map { |e| e + [100] } #=> [1, 2, 100, 3, 4, 100] @overload flat_map @yield [obj] @return [Array] @overload collect_concat @yield [obj] @return [Array] @overload flat_map @overload collect_concat;T;0; @G;@F;Ao;B;CT;Di0;EiA;!@C;"I"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; ; F; ;,;;;I"Enumerable#collect_concat;F;[;[[@CiA;T;;;0;[;{;IC;"AReturns a new array with the concatenated results of running block once for every element in enum. If no block is given, an enumerator is returned instead. [1, 2, 3, 4].flat_map { |e| [e, -e] } #=> [1, -1, 2, -2, 3, -3, 4, -4] [[1, 2], [3, 4]].flat_map { |e| e + [100] } #=> [1, 2, 100, 3, 4, 100] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" flat_map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @.Ho;L ;II" return;F;JI";T;0;K[I" Array;T; @.H;[;I"!@yield [obj] @return [Array];T;0; @.H;@F;Mi;N0;[; @.Ho;H ;II" overload;F;J0;;;K0;#I"collect_concat;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @.Ho;L ;II" return;F;JI";T;0;K[I" Array;T; @.H;[;I"!@yield [obj] @return [Array];T;0; @.H;@F;Mi;N0;[; @.Ho;H ;II" overload;F;J0;;;K0;#I" flat_map;T;IC;";T;[;[;I";T;0; @.H;@F;Mi;N0;[; @.Ho;H ;II" overload;F;J0;;;K0;#I"collect_concat;T;IC;";T;[;[;I";T;0; @.H;@F;Mi;N0;[; @.H;[;@*H;0; @.H;@F;Ao;B;CT;Di0;EiA;!@C;"I"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; ; F; ;,;;;I"Enumerable#inject;F;[[@0;[[@Ci ;T;: inject;0;[;{;IC;"ICombines all elements of enum by applying a binary operation, specified by a block or a symbol that names a method or operator. The inject and reduce methods are aliases. There is no performance benefit to either. If you specify a block, then for each element in enum the block is passed an accumulator value (memo) and the element. If you specify a symbol instead, then each element in the collection will be passed to the named method of memo. In either case, the result becomes the new value for memo. At the end of the iteration, the final value of memo is the return value for the method. If you do not explicitly specify an initial value for memo, then the first element of collection is used as the initial value of memo. # Sum some numbers (5..10).reduce(:+) #=> 45 # Same using a block and inject (5..10).inject { |sum, n| sum + n } #=> 45 # Multiply some numbers (5..10).reduce(1, :*) #=> 151200 # Same using a block (5..10).inject(1) { |product, n| product * n } #=> 151200 # find the longest word longest = %w{ cat sheep bear }.inject do |memo, word| memo.length > word.length ? memo : word end longest #=> "sheep" ;T;[ o;H ;II" overload;F;J0;;;K0;#I"inject(initial, sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"@return [Object];T;0; @oH;@F;Mi;N0;[[I" initial;T0[I"sym;T0; @oHo;H ;II" overload;F;J0;;;K0;#I"inject(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"@return [Object];T;0; @oH;@F;Mi;N0;[[I"sym;T0; @oHo;H ;II" overload;F;J0;;;K0;#I"inject(initial);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @oHo;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"(@yield [memo, obj] @return [Object];T;0; @oH;@F;Mi;N0;[[I" initial;T0; @oHo;H ;II" overload;F;J0;;;K0;#I" inject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @oHo;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"(@yield [memo, obj] @return [Object];T;0; @oH;@F;Mi;N0;[; @oHo;H ;II" overload;F;J0;: reduce;K0;#I"reduce(initial, sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"@return [Object];T;0; @oH;@F;Mi;N0;[[I" initial;T0[I"sym;T0; @oHo;H ;II" overload;F;J0;;;K0;#I"reduce(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"@return [Object];T;0; @oH;@F;Mi;N0;[[I"sym;T0; @oHo;H ;II" overload;F;J0;;;K0;#I"reduce(initial);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @oHo;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"(@yield [memo, obj] @return [Object];T;0; @oH;@F;Mi;N0;[[I" initial;T0; @oHo;H ;II" overload;F;J0;;;K0;#I" reduce;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @oHo;L ;II" return;F;JI";T;0;K[I" Object;T; @oH;[;I"(@yield [memo, obj] @return [Object];T;0; @oH;@F;Mi;N0;[; @oH;[;I"Combines all elements of enum by applying a binary operation, specified by a block or a symbol that names a method or operator. The inject and reduce methods are aliases. There is no performance benefit to either. If you specify a block, then for each element in enum the block is passed an accumulator value (memo) and the element. If you specify a symbol instead, then each element in the collection will be passed to the named method of memo. In either case, the result becomes the new value for memo. At the end of the iteration, the final value of memo is the return value for the method. If you do not explicitly specify an initial value for memo, then the first element of collection is used as the initial value of memo. # Sum some numbers (5..10).reduce(:+) #=> 45 # Same using a block and inject (5..10).inject { |sum, n| sum + n } #=> 45 # Multiply some numbers (5..10).reduce(1, :*) #=> 151200 # Same using a block (5..10).inject(1) { |product, n| product * n } #=> 151200 # find the longest word longest = %w{ cat sheep bear }.inject do |memo, word| memo.length > word.length ? memo : word end longest #=> "sheep" @overload inject(initial, sym) @return [Object] @overload inject(sym) @return [Object] @overload inject(initial) @yield [memo, obj] @return [Object] @overload inject @yield [memo, obj] @return [Object] @overload reduce(initial, sym) @return [Object] @overload reduce(sym) @return [Object] @overload reduce(initial) @yield [memo, obj] @return [Object] @overload reduce @yield [memo, obj] @return [Object];T;0; @oH;@F;Ao;B;CT;Di;Ei);!@C;"I"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; ; F; ;,;;;I"Enumerable#reduce;F;[[@0;[[@Ci ;T;;;0;[;{;IC;"ICombines all elements of enum by applying a binary operation, specified by a block or a symbol that names a method or operator. The inject and reduce methods are aliases. There is no performance benefit to either. If you specify a block, then for each element in enum the block is passed an accumulator value (memo) and the element. If you specify a symbol instead, then each element in the collection will be passed to the named method of memo. In either case, the result becomes the new value for memo. At the end of the iteration, the final value of memo is the return value for the method. If you do not explicitly specify an initial value for memo, then the first element of collection is used as the initial value of memo. # Sum some numbers (5..10).reduce(:+) #=> 45 # Same using a block and inject (5..10).inject { |sum, n| sum + n } #=> 45 # Multiply some numbers (5..10).reduce(1, :*) #=> 151200 # Same using a block (5..10).inject(1) { |product, n| product * n } #=> 151200 # find the longest word longest = %w{ cat sheep bear }.inject do |memo, word| memo.length > word.length ? memo : word end longest #=> "sheep" ;T;[ o;H ;II" overload;F;J0;;;K0;#I"inject(initial, sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"@return [Object];T;0; @I;@F;Mi;N0;[[I" initial;T0[I"sym;T0; @Io;H ;II" overload;F;J0;;;K0;#I"inject(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"@return [Object];T;0; @I;@F;Mi;N0;[[I"sym;T0; @Io;H ;II" overload;F;J0;;;K0;#I"inject(initial);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @Io;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"(@yield [memo, obj] @return [Object];T;0; @I;@F;Mi;N0;[[I" initial;T0; @Io;H ;II" overload;F;J0;;;K0;#I" inject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @Io;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"(@yield [memo, obj] @return [Object];T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;;K0;#I"reduce(initial, sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"@return [Object];T;0; @I;@F;Mi;N0;[[I" initial;T0[I"sym;T0; @Io;H ;II" overload;F;J0;;;K0;#I"reduce(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"@return [Object];T;0; @I;@F;Mi;N0;[[I"sym;T0; @Io;H ;II" overload;F;J0;;;K0;#I"reduce(initial);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @Io;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"(@yield [memo, obj] @return [Object];T;0; @I;@F;Mi;N0;[[I" initial;T0; @Io;H ;II" overload;F;J0;;;K0;#I" reduce;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" memo;TI"obj;T; @Io;L ;II" return;F;JI";T;0;K[I" Object;T; @I;[;I"(@yield [memo, obj] @return [Object];T;0; @I;@F;Mi;N0;[; @I;[;@ I;0; @I;@F;Ao;B;CT;Di;Ei);!@C;"I"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; ; F; ;,;;;I"Enumerable#partition;F;[;[[@Cil;T;;~;0;[;{;IC;"Returns two arrays, the first containing the elements of enum for which the block evaluates to true, the second containing the rest. If no block is given, an enumerator is returned instead. (1..6).partition { |v| v.even? } #=> [[2, 4, 6], [1, 3, 5]] ;T;[o;H ;II" overload;F;J0;;~;K0;#I"partition;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Io;L ;II" return;F;JI";T;0;K[I" Array;T; @I;[;I"!@yield [obj] @return [Array];T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;~;K0;#I"partition;T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[; @I;[;I"RReturns two arrays, the first containing the elements of enum for which the block evaluates to true, the second containing the rest. If no block is given, an enumerator is returned instead. (1..6).partition { |v| v.even? } #=> [[2, 4, 6], [1, 3, 5]] @overload partition @yield [obj] @return [Array] @overload partition;T;0; @I;@F;Ao;B;CT;Di];Eij;!@C;"I"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; ; F; ;,;;;I"Enumerable#group_by;F;[;[[@Ci;T;: group_by;0;[;{;IC;"AGroups the collection by result of the block. Returns a hash where the keys are the evaluated result from the block and the values are arrays of elements in the collection that correspond to the key. If no block is given an enumerator is returned. (1..6).group_by { |i| i%3 } #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]} ;T;[o;H ;II" overload;F;J0;;;K0;#I" group_by;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Io;L ;II" return;F;JI";T;0;K[I" Hash;T; @I;[;I" @yield [obj] @return [Hash];T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;;K0;#I" group_by;T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[; @I;[;I"Groups the collection by result of the block. Returns a hash where the keys are the evaluated result from the block and the values are arrays of elements in the collection that correspond to the key. If no block is given an enumerator is returned. (1..6).group_by { |i| i%3 } #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]} @overload group_by @yield [obj] @return [Hash] @overload group_by;T;0; @I;@F;Ao;B;CT;Di;Ei;!@C;"I"static VALUE enum_group_by(VALUE obj) { VALUE hash; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); hash = rb_hash_new(); rb_block_call(obj, id_each, 0, 0, group_by_i, hash); OBJ_INFECT(hash, obj); return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#first;F;[[@0;[[@Ci;T;: first;0;[;{;IC;"Returns the first element, or the first +n+ elements, of the enumerable. If the enumerable is empty, the first form returns nil, and the second form returns an empty array. %w[foo bar baz].first #=> "foo" %w[foo bar baz].first(2) #=> ["foo", "bar"] %w[foo bar baz].first(10) #=> ["foo", "bar", "baz"] [].first #=> nil [].first(10) #=> [] ;T;[o;H ;II" overload;F;J0;;;K0;#I" first;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @I;[;I"@return [Object, nil];T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;;K0;#I" first(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @I;[;I"@return [Array];T;0; @I;@F;Mi;N0;[[I"n;T0; @I;[;I"Returns the first element, or the first +n+ elements, of the enumerable. If the enumerable is empty, the first form returns nil, and the second form returns an empty array. %w[foo bar baz].first #=> "foo" %w[foo bar baz].first(2) #=> ["foo", "bar"] %w[foo bar baz].first(10) #=> ["foo", "bar", "baz"] [].first #=> nil [].first(10) #=> [] @overload first @return [Object, nil] @overload first(n) @return [Array];T;0; @I;@F;Ao;B;CT;Di;Ei;!@C;"I"*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; ; F; ;,;;;I"Enumerable#all?;F;[[@0;[[@Ci;T;: all?;0;[;{;IC;"LPasses each element of the collection to the given block. The method returns true if the block never returns false or nil. If the block is not given, Ruby adds an implicit block of { |obj| obj } which will cause #all? to return +true+ when none of the collection members are +false+ or +nil+. If instead a pattern is supplied, the method returns whether pattern === element for every collection member. %w[ant bear cat].all? { |word| word.length >= 3 } #=> true %w[ant bear cat].all? { |word| word.length >= 4 } #=> false %w[ant bear cat].all?(/t/) #=> false [1, 2i, 3.14].all?(Numeric) #=> true [nil, true, 99].all? #=> false [].all? #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I" all?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @(Jo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @(J;[;I"#@yield [obj] @return [Boolean];T;0; @(J;@F;Mi;N0;[; @(Jo;H ;II" overload;F;J0;;;K0;#I"all?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @(J;[;I"@return [Boolean];T;0; @(J;@F;Mi;N0;[[I" pattern;T0; @(J;[;I"Passes each element of the collection to the given block. The method returns true if the block never returns false or nil. If the block is not given, Ruby adds an implicit block of { |obj| obj } which will cause #all? to return +true+ when none of the collection members are +false+ or +nil+. If instead a pattern is supplied, the method returns whether pattern === element for every collection member. %w[ant bear cat].all? { |word| word.length >= 3 } #=> true %w[ant bear cat].all? { |word| word.length >= 4 } #=> false %w[ant bear cat].all?(/t/) #=> false [1, 2i, 3.14].all?(Numeric) #=> true [nil, true, 99].all? #=> false [].all? #=> true @overload all? @yield [obj] @return [Boolean] @overload all?(pattern) @return [Boolean];T;0; @(J;@F;Ao;B;CT;Di;Ei;Mi;!@C;"I"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; ; F; ;,;;;I"Enumerable#any?;F;[[@0;[[@Ci;T;;;0;[;{;IC;"cPasses each element of the collection to the given block. The method returns true if the block ever returns a value other than false or nil. If the block is not given, Ruby adds an implicit block of { |obj| obj } that will cause #any? to return +true+ if at least one of the collection members is not +false+ or +nil+. If instead a pattern is supplied, the method returns whether pattern === element for any collection member. %w[ant bear cat].any? { |word| word.length >= 3 } #=> true %w[ant bear cat].any? { |word| word.length >= 4 } #=> true %w[ant bear cat].any?(/d/) #=> false [nil, true, 99].any?(Integer) #=> true [nil, true, 99].any? #=> true [].any? #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I" any?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @XJo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @XJ;[;I"#@yield [obj] @return [Boolean];T;0; @XJ;@F;Mi;N0;[; @XJo;H ;II" overload;F;J0;;;K0;#I"any?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @XJ;[;I"@return [Boolean];T;0; @XJ;@F;Mi;N0;[[I" pattern;T0; @XJ;[;I"Passes each element of the collection to the given block. The method returns true if the block ever returns a value other than false or nil. If the block is not given, Ruby adds an implicit block of { |obj| obj } that will cause #any? to return +true+ if at least one of the collection members is not +false+ or +nil+. If instead a pattern is supplied, the method returns whether pattern === element for any collection member. %w[ant bear cat].any? { |word| word.length >= 3 } #=> true %w[ant bear cat].any? { |word| word.length >= 4 } #=> true %w[ant bear cat].any?(/d/) #=> false [nil, true, 99].any?(Integer) #=> true [nil, true, 99].any? #=> true [].any? #=> false @overload any? @yield [obj] @return [Boolean] @overload any?(pattern) @return [Boolean];T;0; @XJ;@F;Ao;B;CT;Di;Ei;Mi;!@C;"I"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; ; F; ;,;;;I"Enumerable#one?;F;[[@0;[[@Ci#;T;: one?;0;[;{;IC;"Passes each element of the collection to the given block. The method returns true if the block returns true exactly once. If the block is not given, one? will return true only if exactly one of the collection members is true. If instead a pattern is supplied, the method returns whether pattern === element for exactly one collection member. %w{ant bear cat}.one? { |word| word.length == 4 } #=> true %w{ant bear cat}.one? { |word| word.length > 4 } #=> false %w{ant bear cat}.one? { |word| word.length < 4 } #=> false %w{ant bear cat}.one?(/t/) #=> false [ nil, true, 99 ].one? #=> false [ nil, true, false ].one? #=> true [ nil, true, 99 ].one?(Integer) #=> true [].one? #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I" one?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Jo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @J;[;I"#@yield [obj] @return [Boolean];T;0; @J;@F;Mi;N0;[; @Jo;H ;II" overload;F;J0;;;K0;#I"one?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @J;[;I"@return [Boolean];T;0; @J;@F;Mi;N0;[[I" pattern;T0; @J;[;I"Passes each element of the collection to the given block. The method returns true if the block returns true exactly once. If the block is not given, one? will return true only if exactly one of the collection members is true. If instead a pattern is supplied, the method returns whether pattern === element for exactly one collection member. %w{ant bear cat}.one? { |word| word.length == 4 } #=> true %w{ant bear cat}.one? { |word| word.length > 4 } #=> false %w{ant bear cat}.one? { |word| word.length < 4 } #=> false %w{ant bear cat}.one?(/t/) #=> false [ nil, true, 99 ].one? #=> false [ nil, true, false ].one? #=> true [ nil, true, 99 ].one?(Integer) #=> true [].one? #=> false @overload one? @yield [obj] @return [Boolean] @overload one?(pattern) @return [Boolean];T;0; @J;@F;Ao;B;CT;Di ;Ei#;Mi;!@C;"I"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; ; F; ;,;;;I"Enumerable#none?;F;[[@0;[[@CiO;T;: none?;0;[;{;IC;"Passes each element of the collection to the given block. The method returns true if the block never returns true for all elements. If the block is not given, none? will return true only if none of the collection members is true. If instead a pattern is supplied, the method returns whether pattern === element for none of the collection members. %w{ant bear cat}.none? { |word| word.length == 5 } #=> true %w{ant bear cat}.none? { |word| word.length >= 4 } #=> false %w{ant bear cat}.none?(/d/) #=> true [1, 3.14, 42].none?(Float) #=> false [].none? #=> true [nil].none? #=> true [nil, false].none? #=> true [nil, false, true].none? #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I" none?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Jo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @J;[;I"#@yield [obj] @return [Boolean];T;0; @J;@F;Mi;N0;[; @Jo;H ;II" overload;F;J0;;;K0;#I"none?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @J;[;I"@return [Boolean];T;0; @J;@F;Mi;N0;[[I" pattern;T0; @J;[;I"Passes each element of the collection to the given block. The method returns true if the block never returns true for all elements. If the block is not given, none? will return true only if none of the collection members is true. If instead a pattern is supplied, the method returns whether pattern === element for none of the collection members. %w{ant bear cat}.none? { |word| word.length == 5 } #=> true %w{ant bear cat}.none? { |word| word.length >= 4 } #=> false %w{ant bear cat}.none?(/d/) #=> true [1, 3.14, 42].none?(Float) #=> false [].none? #=> true [nil].none? #=> true [nil, false].none? #=> true [nil, false, true].none? #=> false @overload none? @yield [obj] @return [Boolean] @overload none?(pattern) @return [Boolean];T;0; @J;@F;Ao;B;CT;Di9;EiO;Mi;!@C;"I"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; ; F; ;,;;;I"Enumerable#min;F;[[@0;[[@Ci;T;:min;0;[;{;IC;"wReturns the object in _enum_ with the minimum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. a = %w(albatross dog horse) a.min #=> "albatross" a.min { |a, b| a.length <=> b.length } #=> "dog" If the +n+ argument is given, minimum +n+ elements are returned as a sorted array. a = %w[albatross dog horse] a.min(2) #=> ["albatross", "dog"] a.min(2) {|a, b| a.length <=> b.length } #=> ["dog", "horse"] [5, 1, 3, 4, 2].min(3) #=> [1, 2, 3] ;T;[ o;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @J;[;I"@return [Object];T;0; @J;@F;Mi;N0;[; @Jo;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @Jo;L ;II" return;F;JI";T;0;K[I" Object;T; @J;[;I"#@yield [a, b] @return [Object];T;0; @J;@F;Mi;N0;[; @Jo;H ;II" overload;F;J0;;;K0;#I" min(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @J;[;I"@return [Array];T;0; @J;@F;Mi;N0;[[I"n;T0; @Jo;H ;II" overload;F;J0;;;K0;#I" min(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @Jo;L ;II" return;F;JI";T;0;K[I" Array;T; @J;[;I""@yield [a, b] @return [Array];T;0; @J;@F;Mi;N0;[[I"n;T0; @J;[;I"!Returns the object in _enum_ with the minimum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. a = %w(albatross dog horse) a.min #=> "albatross" a.min { |a, b| a.length <=> b.length } #=> "dog" If the +n+ argument is given, minimum +n+ elements are returned as a sorted array. a = %w[albatross dog horse] a.min(2) #=> ["albatross", "dog"] a.min(2) {|a, b| a.length <=> b.length } #=> ["dog", "horse"] [5, 1, 3, 4, 2].min(3) #=> [1, 2, 3] @overload min @return [Object] @overload min @yield [a, b] @return [Object] @overload min(n) @return [Array] @overload min(n) @yield [a, b] @return [Array];T;0; @J;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#max;F;[[@0;[[@Ci;T;:max;0;[;{;IC;"Returns the object in _enum_ with the maximum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. a = %w(albatross dog horse) a.max #=> "horse" a.max { |a, b| a.length <=> b.length } #=> "albatross" If the +n+ argument is given, maximum +n+ elements are returned as an array, sorted in descending order. a = %w[albatross dog horse] a.max(2) #=> ["horse", "dog"] a.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"] [5, 1, 3, 4, 2].max(3) #=> [5, 4, 3] ;T;[ o;H ;II" overload;F;J0;;;K0;#I"max;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;K;[;I"@return [Object];T;0; @;K;@F;Mi;N0;[; @;Ko;H ;II" overload;F;J0;;;K0;#I"max;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @;Ko;L ;II" return;F;JI";T;0;K[I" Object;T; @;K;[;I"#@yield [a, b] @return [Object];T;0; @;K;@F;Mi;N0;[; @;Ko;H ;II" overload;F;J0;;;K0;#I" max(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;K;[;I"@return [Array];T;0; @;K;@F;Mi;N0;[[I"n;T0; @;Ko;H ;II" overload;F;J0;;;K0;#I" max(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @;Ko;L ;II" return;F;JI";T;0;K[I" Array;T; @;K;[;I""@yield [a, b] @return [Array];T;0; @;K;@F;Mi;N0;[[I"n;T0; @;K;[;I";Returns the object in _enum_ with the maximum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. a = %w(albatross dog horse) a.max #=> "horse" a.max { |a, b| a.length <=> b.length } #=> "albatross" If the +n+ argument is given, maximum +n+ elements are returned as an array, sorted in descending order. a = %w[albatross dog horse] a.max(2) #=> ["horse", "dog"] a.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"] [5, 1, 3, 4, 2].max(3) #=> [5, 4, 3] @overload max @return [Object] @overload max @yield [a, b] @return [Object] @overload max(n) @return [Array] @overload max(n) @yield [a, b] @return [Array];T;0; @;K;@F;Ao;B;CT;Di;Ei;!@C;"I"^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; ; F; ;,;;;I"Enumerable#minmax;F;[;[[@Ci;T;: minmax;0;[;{;IC;"Returns a two element array which contains the minimum and the maximum value in the enumerable. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. a = %w(albatross dog horse) a.minmax #=> ["albatross", "horse"] a.minmax { |a, b| a.length <=> b.length } #=> ["dog", "albatross"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" minmax;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @K;[;I"@return [Array];T;0; @K;@F;Mi;N0;[; @Ko;H ;II" overload;F;J0;;;K0;#I" minmax;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @Ko;L ;II" return;F;JI";T;0;K[I" Array;T; @K;[;I""@yield [a, b] @return [Array];T;0; @K;@F;Mi;N0;[; @K;[;I"Returns a two element array which contains the minimum and the maximum value in the enumerable. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. a = %w(albatross dog horse) a.minmax #=> ["albatross", "horse"] a.minmax { |a, b| a.length <=> b.length } #=> ["dog", "albatross"] @overload minmax @return [Array] @overload minmax @yield [a, b] @return [Array];T;0; @K;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#min_by;F;[[@0;[[@Ci;T;: min_by;0;[;{;IC;"Returns the object in enum that gives the minimum value from the given block. If no block is given, an enumerator is returned instead. a = %w(albatross dog horse) a.min_by { |x| x.length } #=> "dog" If the +n+ argument is given, minimum +n+ elements are returned as an array. These +n+ elements are sorted by the value from the given block. a = %w[albatross dog horse] p a.min_by(2) {|x| x.length } #=> ["dog", "horse"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" min_by;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Ko;L ;II" return;F;JI";T;0;K[I" Object;T; @K;[;I""@yield [obj] @return [Object];T;0; @K;@F;Mi;N0;[; @Ko;H ;II" overload;F;J0;;;K0;#I" min_by;T;IC;";T;[;[;I";T;0; @K;@F;Mi;N0;[; @Ko;H ;II" overload;F;J0;;;K0;#I"min_by(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Ko;L ;II" return;F;JI";T;0;K[I" Array;T; @K;[;I"!@yield [obj] @return [Array];T;0; @K;@F;Mi;N0;[[I"n;T0; @Ko;H ;II" overload;F;J0;;;K0;#I"min_by(n);T;IC;";T;[;[;I";T;0; @K;@F;Mi;N0;[[I"n;T0; @K;[;I"KReturns the object in enum that gives the minimum value from the given block. If no block is given, an enumerator is returned instead. a = %w(albatross dog horse) a.min_by { |x| x.length } #=> "dog" If the +n+ argument is given, minimum +n+ elements are returned as an array. These +n+ elements are sorted by the value from the given block. a = %w[albatross dog horse] p a.min_by(2) {|x| x.length } #=> ["dog", "horse"] @overload min_by @yield [obj] @return [Object] @overload min_by @overload min_by(n) @yield [obj] @return [Array] @overload min_by(n);T;0; @K;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#max_by;F;[[@0;[[@CiA;T;: max_by;0;[;{;IC;"Returns the object in enum that gives the maximum value from the given block. If no block is given, an enumerator is returned instead. a = %w(albatross dog horse) a.max_by { |x| x.length } #=> "albatross" If the +n+ argument is given, maximum +n+ elements are returned as an array. These +n+ elements are sorted by the value from the given block, in descending order. a = %w[albatross dog horse] a.max_by(2) {|x| x.length } #=> ["albatross", "horse"] enum.max_by(n) can be used to implement weighted random sampling. Following example implements and use Enumerable#wsample. module Enumerable # weighted random sampling. # # Pavlos S. Efraimidis, Paul G. Spirakis # Weighted random sampling with a reservoir # Information Processing Letters # Volume 97, Issue 5 (16 March 2006) def wsample(n) self.max_by(n) {|v| rand ** (1.0/yield(v)) } end end e = (-20..20).to_a*10000 a = e.wsample(20000) {|x| Math.exp(-(x/5.0)**2) # normal distribution } # a is 20000 samples from e. p a.length #=> 20000 h = a.group_by {|x| x } -10.upto(10) {|x| puts "*" * (h[x].length/30.0).to_i if h[x] } #=> * # *** # ****** # *********** # ****************** # ***************************** # ***************************************** # **************************************************** # *************************************************************** # ******************************************************************** # *********************************************************************** # *********************************************************************** # ************************************************************** # **************************************************** # *************************************** # *************************** # ****************** # *********** # ******* # *** # * ;T;[ o;H ;II" overload;F;J0;;;K0;#I" max_by;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Lo;L ;II" return;F;JI";T;0;K[I" Object;T; @L;[;I""@yield [obj] @return [Object];T;0; @L;@F;Mi;N0;[; @Lo;H ;II" overload;F;J0;;;K0;#I" max_by;T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[; @Lo;H ;II" overload;F;J0;;;K0;#I"max_by(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @Lo;L ;II" return;F;JI";T;0;K[I" Object;T; @L;[;I""@yield [obj] @return [Object];T;0; @L;@F;Mi;N0;[[I"n;T0; @Lo;H ;II" overload;F;J0;;;K0;#I"max_by(n);T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[[I"n;T0; @L;[;I"gReturns the object in enum that gives the maximum value from the given block. If no block is given, an enumerator is returned instead. a = %w(albatross dog horse) a.max_by { |x| x.length } #=> "albatross" If the +n+ argument is given, maximum +n+ elements are returned as an array. These +n+ elements are sorted by the value from the given block, in descending order. a = %w[albatross dog horse] a.max_by(2) {|x| x.length } #=> ["albatross", "horse"] enum.max_by(n) can be used to implement weighted random sampling. Following example implements and use Enumerable#wsample. module Enumerable # weighted random sampling. # # Pavlos S. Efraimidis, Paul G. Spirakis # Weighted random sampling with a reservoir # Information Processing Letters # Volume 97, Issue 5 (16 March 2006) def wsample(n) self.max_by(n) {|v| rand ** (1.0/yield(v)) } end end e = (-20..20).to_a*10000 a = e.wsample(20000) {|x| Math.exp(-(x/5.0)**2) # normal distribution } # a is 20000 samples from e. p a.length #=> 20000 h = a.group_by {|x| x } -10.upto(10) {|x| puts "*" * (h[x].length/30.0).to_i if h[x] } #=> * # *** # ****** # *********** # ****************** # ***************************** # ***************************************** # **************************************************** # *************************************************************** # ******************************************************************** # *********************************************************************** # *********************************************************************** # ************************************************************** # **************************************************** # *************************************** # *************************** # ****************** # *********** # ******* # *** # * @overload max_by @yield [obj] @return [Object] @overload max_by @overload max_by(n) @yield [obj] @return [Object] @overload max_by(n);T;0; @L;@F;Ao;B;CT;Di;EiA;!@C;"I"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; ; F; ;,;;;I"Enumerable#minmax_by;F;[;[[@Ci;T;:minmax_by;0;[;{;IC;"+Returns a two element array containing the objects in enum that correspond to the minimum and maximum values respectively from the given block. If no block is given, an enumerator is returned instead. a = %w(albatross dog horse) a.minmax_by { |x| x.length } #=> ["dog", "albatross"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"minmax_by;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @JLo;L ;II" return;F;JI";T;0;K[I" Array;T; @JL;[;I"!@yield [obj] @return [Array];T;0; @JL;@F;Mi;N0;[; @JLo;H ;II" overload;F;J0;;;K0;#I"minmax_by;T;IC;";T;[;[;I";T;0; @JL;@F;Mi;N0;[; @JL;[;I"vReturns a two element array containing the objects in enum that correspond to the minimum and maximum values respectively from the given block. If no block is given, an enumerator is returned instead. a = %w(albatross dog horse) a.minmax_by { |x| x.length } #=> ["dog", "albatross"] @overload minmax_by @yield [obj] @return [Array] @overload minmax_by;T;0; @JL;@F;Ao;B;CT;Di;Ei;!@C;"I".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; ; F; ;,;;;I"Enumerable#member?;F;[[I"val;T0;[[@Ci;T;;;0;[;{;IC;"HReturns true if any member of enum equals obj. Equality is tested using ==. IO.constants.include? :SEEK_SET #=> true IO.constants.include? :SEEK_NO_FURTHER #=> false IO.constants.member? :SEEK_SET #=> true IO.constants.member? :SEEK_NO_FURTHER #=> false;T;[o;H ;II" overload;F;J0;;U;K0;#I"include?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @rL;[;I"@return [Boolean];T;0; @rL;@F;Mi;N0;[[I"obj;T0; @rLo;H ;II" overload;F;J0;;;K0;#I"member?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @rL;[;I"@return [Boolean];T;0; @rL;@F;Mi;N0;[[I"obj;T0; @rL;[;I"Returns true if any member of enum equals obj. Equality is tested using ==. IO.constants.include? :SEEK_SET #=> true IO.constants.include? :SEEK_NO_FURTHER #=> false IO.constants.member? :SEEK_SET #=> true IO.constants.member? :SEEK_NO_FURTHER #=> false @overload include?(obj) @return [Boolean] @overload member?(obj) @return [Boolean];T;0; @rL;@F;Ao;B;CT;Di;Ei;Mi;!@C;"I"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; ; F; ;,;;;I"Enumerable#include?;F;[[I"val;T0;[[@Ci;T;;U;0;[;{;IC;"HReturns true if any member of enum equals obj. Equality is tested using ==. IO.constants.include? :SEEK_SET #=> true IO.constants.include? :SEEK_NO_FURTHER #=> false IO.constants.member? :SEEK_SET #=> true IO.constants.member? :SEEK_NO_FURTHER #=> false;T;[o;H ;II" overload;F;J0;;U;K0;#I"include?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @L;[;I"@return [Boolean];T;0; @L;@F;Mi;N0;[[I"obj;T0; @Lo;H ;II" overload;F;J0;;;K0;#I"member?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @L;[;I"@return [Boolean];T;0; @L;@F;Mi;N0;[[I"obj;T0; @L;[;@L;0; @L;@F;Ao;B;CT;Di;Ei;Mi;!@C;"I"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; ; F; ;,;;;I"Enumerable#each_with_index;F;[[@0;[[@Ci ;T;:each_with_index;0;[;{;IC;"_Calls block with two arguments, the item and its index, for each item in enum. Given arguments are passed through to #each(). If no block is given, an enumerator is returned instead. hash = Hash.new %w(cat dog wombat).each_with_index { |item, index| hash[item] = index } hash #=> {"cat"=>0, "dog"=>1, "wombat"=>2} ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_with_index(*args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;TI"i;T; @Lo;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @L;[;I")@yield [obj, i] @return [Enumerator];T;0; @L;@F;Mi;N0;[[I" *args;T0; @Lo;H ;II" overload;F;J0;;;K0;#I"each_with_index(*args);T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[[I" *args;T0; @L;[;I"Calls block with two arguments, the item and its index, for each item in enum. Given arguments are passed through to #each(). If no block is given, an enumerator is returned instead. hash = Hash.new %w(cat dog wombat).each_with_index { |item, index| hash[item] = index } hash #=> {"cat"=>0, "dog"=>1, "wombat"=>2} @overload each_with_index(*args) @yield [obj, i] @return [Enumerator] @overload each_with_index(*args);T;0; @L;@F;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"Enumerable#reverse_each;F;[[@0;[[@Ci ;T;:reverse_each;0;[;{;IC;"Builds a temporary array and traverses that array in reverse order. If no block is given, an enumerator is returned instead. (1..3).reverse_each { |v| p v } produces: 3 2 1 ;T;[o;H ;II" overload;F;J0;; ;K0;#I"reverse_each(*args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @Lo;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @L;[;I"'@yield [item] @return [Enumerator];T;0; @L;@F;Mi;N0;[[I" *args;T0; @Lo;H ;II" overload;F;J0;; ;K0;#I"reverse_each(*args);T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[[I" *args;T0; @L;[;I"!Builds a temporary array and traverses that array in reverse order. If no block is given, an enumerator is returned instead. (1..3).reverse_each { |v| p v } produces: 3 2 1 @overload reverse_each(*args) @yield [item] @return [Enumerator] @overload reverse_each(*args);T;0; @L;@F;Ao;B;CT;Di ;Ei ;!@C;"I"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; ; F; ;,;;;I"Enumerable#each_entry;F;[[@0;[[@Ci] ;T;:each_entry;0;[;{;IC;"zCalls block once for each element in +self+, passing that element as a parameter, converting multiple values from yield to an array. If no block is given, an enumerator is returned instead. class Foo include Enumerable def each yield 1 yield 1, 2 yield end end Foo.new.each_entry{ |o| p o } produces: 1 [1, 2] nil ;T;[o;H ;II" overload;F;J0;;!;K0;#I"each_entry;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @(Mo;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @(M;[;I"&@yield [obj] @return [Enumerator];T;0; @(M;@F;Mi;N0;[; @(Mo;H ;II" overload;F;J0;;!;K0;#I"each_entry;T;IC;";T;[;[;I";T;0; @(M;@F;Mi;N0;[; @(M;[;I"Calls block once for each element in +self+, passing that element as a parameter, converting multiple values from yield to an array. If no block is given, an enumerator is returned instead. class Foo include Enumerable def each yield 1 yield 1, 2 yield end end Foo.new.each_entry{ |o| p o } produces: 1 [1, 2] nil @overload each_entry @yield [obj] @return [Enumerator] @overload each_entry;T;0; @(M;@F;Ao;B;CT;Di@ ;Ei[ ;!@C;"I"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; ; F; ;,;;;I"Enumerable#each_slice;F;[[I"n;T0;[[@Ci ;T;:each_slice;0;[;{;IC;"Iterates the given block for each slice of elements. If no block is given, returns an enumerator. (1..10).each_slice(3) { |a| p a } # outputs below [1, 2, 3] [4, 5, 6] [7, 8, 9] [10] ;T;[o;H ;II" overload;F;J0;;";K0;#I"each_slice(n);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @QMo;L ;II" return;F;JI";T;0;K[I"nil;T; @QM;[;I"@yield [] @return [nil];T;0; @QM;@F;Mi;N0;[[I"n;T0; @QMo;H ;II" overload;F;J0;;";K0;#I"each_slice(n);T;IC;";T;[;[;I";T;0; @QM;@F;Mi;N0;[[I"n;T0; @QM;[;I"#Iterates the given block for each slice of elements. If no block is given, returns an enumerator. (1..10).each_slice(3) { |a| p a } # outputs below [1, 2, 3] [4, 5, 6] [7, 8, 9] [10] @overload each_slice(n) @yield [] @return [nil] @overload each_slice(n);T;0; @QM;@F;Ao;B;CT;Di ;Ei ;!@C;"I"?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 Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#each_cons;F;[[I"n;T0;[[@Ci ;T;:each_cons;0;[;{;IC;"#Iterates the given block for each array of consecutive elements. If no block is given, returns an enumerator. e.g.: (1..10).each_cons(3) { |a| p a } # outputs below [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 6] [5, 6, 7] [6, 7, 8] [7, 8, 9] [8, 9, 10] ;T;[o;H ;II" overload;F;J0;;#;K0;#I"each_cons(n);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @}Mo;L ;II" return;F;JI";T;0;K[I"nil;T; @}M;[;I"@yield [] @return [nil];T;0; @}M;@F;Mi;N0;[[I"n;T0; @}Mo;H ;II" overload;F;J0;;#;K0;#I"each_cons(n);T;IC;";T;[;[;I";T;0; @}M;@F;Mi;N0;[[I"n;T0; @}M;[;I"pIterates the given block for each array of consecutive elements. If no block is given, returns an enumerator. e.g.: (1..10).each_cons(3) { |a| p a } # outputs below [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 6] [5, 6, 7] [6, 7, 8] [7, 8, 9] [8, 9, 10] @overload each_cons(n) @yield [] @return [nil] @overload each_cons(n);T;0; @}M;@F;Ao;B;CT;Di ;Ei ;!@C;"I"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 Qnil; 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 Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Enumerable#each_with_object;F;[[I" memo;T0;[[@Ci$ ;T;:each_with_object;0;[;{;IC;" Iterates the given block for each element with an arbitrary object given, and returns the initially given object. If no block is given, returns an enumerator. evens = (1..10).each_with_object([]) { |i, a| a << i*2 } #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] ;T;[o;H ;II" overload;F;J0;;$;K0;#I"each_with_object(obj);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" (*args);TI" memo_obj;T; @Mo;L ;II" return;F;JI";T;0;K[I" Object;T; @M;[;I"0@yield [(*args), memo_obj] @return [Object];T;0; @M;@F;Mi;N0;[[I"obj;T0; @Mo;H ;II" overload;F;J0;;$;K0;#I"each_with_object(obj);T;IC;";T;[;[;I";T;0; @M;@F;Mi;N0;[[I"obj;T0; @M;[;I"}Iterates the given block for each element with an arbitrary object given, and returns the initially given object. If no block is given, returns an enumerator. evens = (1..10).each_with_object([]) { |i, a| a << i*2 } #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] @overload each_with_object(obj) @yield [(*args), memo_obj] @return [Object] @overload each_with_object(obj);T;0; @M;@F;Ao;B;CT;Di ;Ei# ;!@C;"I"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; ; F; ;,;;;I"Enumerable#zip;F;[[@0;[[@Ci ;T;:zip;0;[;{;IC;"lTakes one element from enum and merges corresponding elements from each args. This generates a sequence of n-element arrays, where n is one more than the count of arguments. The length of the resulting sequence will be enum#size. If the size of any argument is less than enum#size, nil values are supplied. If a block is given, it is invoked for each output array, otherwise an array of arrays is returned. a = [ 4, 5, 6 ] b = [ 7, 8, 9 ] a.zip(b) #=> [[4, 7], [5, 8], [6, 9]] [1, 2, 3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]] a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]] c = [] a.zip(b) { |x, y| c << x + y } #=> nil c #=> [11, 13, 15] ;T;[o;H ;II" overload;F;J0;;%;K0;#I"zip(arg, ...);T;IC;";T;[;[;I";T;0; @M;@F;Mi;N0;[[I"arg;T0[I"...;T0; @Mo;H ;II" overload;F;J0;;%;K0;#I"zip(arg, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"arr;T; @Mo;L ;II" return;F;JI";T;0;K[I"nil;T; @M;[;I"@yield [arr] @return [nil];T;0; @M;@F;Mi;N0;[[I"arg;T0[I"...;T0; @M;[;I"Takes one element from enum and merges corresponding elements from each args. This generates a sequence of n-element arrays, where n is one more than the count of arguments. The length of the resulting sequence will be enum#size. If the size of any argument is less than enum#size, nil values are supplied. If a block is given, it is invoked for each output array, otherwise an array of arrays is returned. a = [ 4, 5, 6 ] b = [ 7, 8, 9 ] a.zip(b) #=> [[4, 7], [5, 8], [6, 9]] [1, 2, 3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]] a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]] c = [] a.zip(b) { |x, y| c << x + y } #=> nil c #=> [11, 13, 15] @overload zip(arg, ...) @overload zip(arg, ...) @yield [arr] @return [nil];T;0; @M;@F;Ao;B;CT;Di ;Ei ;!@C;"I"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; ienum. a = [1, 2, 3, 4, 5, 0] a.take(3) #=> [1, 2, 3] a.take(30) #=> [1, 2, 3, 4, 5, 0] ;T;[o;H ;II" overload;F;J0;;&;K0;#I" take(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ N;[;I"@return [Array];T;0; @ N;@F;Mi;N0;[[I"n;T0; @ N;[;I"Returns first n elements from enum. a = [1, 2, 3, 4, 5, 0] a.take(3) #=> [1, 2, 3] a.take(30) #=> [1, 2, 3, 4, 5, 0] @overload take(n) @return [Array];T;0; @ N;@F;Ao;B;CT;Di ;Ei ;!@C;"I"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; ; F; ;,;;;I"Enumerable#take_while;F;[;[[@Ci ;T;:take_while;0;[;{;IC;"Passes elements to the block until the block returns +nil+ or +false+, then stops iterating and returns an array of all prior elements. If no block is given, an enumerator is returned instead. a = [1, 2, 3, 4, 5, 0] a.take_while { |i| i < 3 } #=> [1, 2] ;T;[o;H ;II" overload;F;J0;;';K0;#I"take_while;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @(No;L ;II" return;F;JI";T;0;K[I" Array;T; @(N;[;I"!@yield [obj] @return [Array];T;0; @(N;@F;Mi;N0;[; @(No;H ;II" overload;F;J0;;';K0;#I"take_while;T;IC;";T;[;[;I";T;0; @(N;@F;Mi;N0;[; @(N;[;I"UPasses elements to the block until the block returns +nil+ or +false+, then stops iterating and returns an array of all prior elements. If no block is given, an enumerator is returned instead. a = [1, 2, 3, 4, 5, 0] a.take_while { |i| i < 3 } #=> [1, 2] @overload take_while @yield [obj] @return [Array] @overload take_while;T;0; @(N;@F;Ao;B;CT;Di ;Ei ;!@C;"I"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; ; F; ;,;;;I"Enumerable#drop;F;[[I"n;T0;[[@Ci+ ;T;: drop;0;[;{;IC;"Drops first n elements from enum, and returns rest elements in an array. a = [1, 2, 3, 4, 5, 0] a.drop(3) #=> [4, 5, 0] ;T;[o;H ;II" overload;F;J0;;(;K0;#I" drop(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @PN;[;I"@return [Array];T;0; @PN;@F;Mi;N0;[[I"n;T0; @PN;[;I"Drops first n elements from enum, and returns rest elements in an array. a = [1, 2, 3, 4, 5, 0] a.drop(3) #=> [4, 5, 0] @overload drop(n) @return [Array];T;0; @PN;@F;Ao;B;CT;Di ;Ei( ;!@C;"I"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; ; F; ;,;;;I"Enumerable#drop_while;F;[;[[@Ci\ ;T;:drop_while;0;[;{;IC;"%Drops elements up to, but not including, the first element for which the block returns +nil+ or +false+ and returns an array containing the remaining elements. If no block is given, an enumerator is returned instead. a = [1, 2, 3, 4, 5, 0] a.drop_while { |i| i < 3 } #=> [3, 4, 5, 0] ;T;[o;H ;II" overload;F;J0;;);K0;#I"drop_while;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @oNo;L ;II" return;F;JI";T;0;K[I" Array;T; @oN;[;I"!@yield [obj] @return [Array];T;0; @oN;@F;Mi;N0;[; @oNo;H ;II" overload;F;J0;;);K0;#I"drop_while;T;IC;";T;[;[;I";T;0; @oN;@F;Mi;N0;[; @oN;[;I"sDrops elements up to, but not including, the first element for which the block returns +nil+ or +false+ and returns an array containing the remaining elements. If no block is given, an enumerator is returned instead. a = [1, 2, 3, 4, 5, 0] a.drop_while { |i| i < 3 } #=> [3, 4, 5, 0] @overload drop_while @yield [obj] @return [Array] @overload drop_while;T;0; @oN;@F;Ao;B;CT;DiL ;EiZ ;!@C;"I"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; ; F; ;,;;;I"Enumerable#cycle;F;[[@0;[[@Ci ;T;: cycle;0;[;{;IC;"@Calls block for each element of enum repeatedly _n_ times or forever if none or +nil+ is given. If a non-positive number is given or the collection is empty, does nothing. Returns +nil+ if the loop has finished without getting interrupted. Enumerable#cycle saves elements in an internal array so changes to enum after the first pass have no effect. If no block is given, an enumerator is returned instead. a = ["a", "b", "c"] a.cycle { |x| puts x } # print, a, b, c, a, b, c,.. forever. a.cycle(2) { |x| puts x } # print, a, b, c, a, b, c. ;T;[o;H ;II" overload;F;J0;;*;K0;#I"cycle(n=nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @No;L ;II" return;F;JI";T;0;K[I"nil;T; @N;[;I"@yield [obj] @return [nil];T;0; @N;@F;Mi;N0;[[I"n;TI"nil;T; @No;H ;II" overload;F;J0;;*;K0;#I"cycle(n=nil);T;IC;";T;[;[;I";T;0; @N;@F;Mi;N0;[[I"n;TI"nil;T; @N;[;I"Calls block for each element of enum repeatedly _n_ times or forever if none or +nil+ is given. If a non-positive number is given or the collection is empty, does nothing. Returns +nil+ if the loop has finished without getting interrupted. Enumerable#cycle saves elements in an internal array so changes to enum after the first pass have no effect. If no block is given, an enumerator is returned instead. a = ["a", "b", "c"] a.cycle { |x| puts x } # print, a, b, c, a, b, c,.. forever. a.cycle(2) { |x| puts x } # print, a, b, c, a, b, c. @overload cycle(n=nil) @yield [obj] @return [nil] @overload cycle(n=nil);T;0; @N;@F;Ao;B;CT;Di ;Ei ;!@C;"I"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 [false, [3, 1]] # [true, [4]] # [false, [1, 5, 9]] # [true, [2, 6]] # [false, [5, 3, 5]] This method is especially useful for sorted series of elements. The following example counts words for each initial letter. open("/usr/share/dict/words", "r:iso-8859-1") { |f| f.chunk { |line| line.ord }.each { |ch, lines| p [ch.chr, lines.length] } } #=> ["\n", 1] # ["A", 1327] # ["B", 1372] # ["C", 1507] # ["D", 791] # ... The following key values have special meaning: - +nil+ and +:_separator+ specifies that the elements should be dropped. - +:_alone+ specifies that the element should be chunked by itself. Any other symbols that begin with an underscore will raise an error: items.chunk { |item| :_underscore } #=> RuntimeError: symbols beginning with an underscore are reserved +nil+ and +:_separator+ can be used to ignore some elements. 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 } +:_alone+ can be used to force items into their own chunk. For example, you can put lines that contain a URL by themselves, and chunk the rest of the lines together, like this: pattern = /http/ open(filename) { |f| f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| pp lines } } If no block is given, an enumerator to `chunk` is returned instead. ;T;[o;H ;II" overload;F;J0;;+;K0;#I" chunk;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"elt;T; @N;[;I"@yield [elt];T;0; @N;@F;Mi;N0;[; @N;[;I" Enumerates over the items, chunking them together based on the return value of the block. Consecutive elements which return the same block value are chunked together. For example, consecutive even numbers and odd numbers can be chunked as follows. [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5].chunk { |n| n.even? }.each { |even, ary| p [even, ary] } #=> [false, [3, 1]] # [true, [4]] # [false, [1, 5, 9]] # [true, [2, 6]] # [false, [5, 3, 5]] This method is especially useful for sorted series of elements. The following example counts words for each initial letter. open("/usr/share/dict/words", "r:iso-8859-1") { |f| f.chunk { |line| line.ord }.each { |ch, lines| p [ch.chr, lines.length] } } #=> ["\n", 1] # ["A", 1327] # ["B", 1372] # ["C", 1507] # ["D", 791] # ... The following key values have special meaning: - +nil+ and +:_separator+ specifies that the elements should be dropped. - +:_alone+ specifies that the element should be chunked by itself. Any other symbols that begin with an underscore will raise an error: items.chunk { |item| :_underscore } #=> RuntimeError: symbols beginning with an underscore are reserved +nil+ and +:_separator+ can be used to ignore some elements. 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 } +:_alone+ can be used to force items into their own chunk. For example, you can put lines that contain a URL by themselves, and chunk the rest of the lines together, like this: pattern = /http/ open(filename) { |f| f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| pp lines } } If no block is given, an enumerator to `chunk` is returned instead. @overload chunk @yield [elt];T;0; @N;@F;Ao;B;CT;Di ;Eia ;!@C;"I"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, rb_intern("chunk_enumerable"), enumerable); rb_ivar_set(enumerator, rb_intern("chunk_categorize"), rb_block_proc()); rb_block_call(enumerator, idInitialize, 0, 0, chunk_i, enumerator); return enumerator; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#slice_before;F;[[@0;[[@Ci8 ;T;:slice_before;0;[;{;IC;"Creates an enumerator for each chunked elements. The beginnings of chunks are defined by _pattern_ and the block. If _pattern_ === _elt_ returns true or the block returns true for the element, the element is beginning of a chunk. The === and _block_ is called from the first element to the last element of _enum_. The result for the first element is ignored. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.slice_before(pattern).each { |ary| ... } enum.slice_before { |elt| bool }.each { |ary| ... } 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;H ;II" overload;F;J0;;,;K0;#I"slice_before(pattern);T;IC;";T;[;[;I";T;0; @N;@F;Mi;N0;[[I" pattern;T0; @No;H ;II" overload;F;J0;;,;K0;#I"slice_before;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"elt;T; @N;[;I"@yield [elt];T;0; @N;@F;Mi;N0;[; @N;[;I"Creates an enumerator for each chunked elements. The beginnings of chunks are defined by _pattern_ and the block. If _pattern_ === _elt_ returns true or the block returns true for the element, the element is beginning of a chunk. The === and _block_ is called from the first element to the last element of _enum_. The result for the first element is ignored. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.slice_before(pattern).each { |ary| ... } enum.slice_before { |elt| bool }.each { |ary| ... } 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 [elt];T;0; @N;@F;Ao;B;CT;Di ;Ei6 ;!@C;"I"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, rb_intern("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, rb_intern("slicebefore_sep_pat"), sep_pat); } rb_ivar_set(enumerator, rb_intern("slicebefore_enumerable"), enumerable); rb_block_call(enumerator, idInitialize, 0, 0, slicebefore_i, enumerator); return enumerator; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#slice_after;F;[[@0;[[@Ci ;T;:slice_after;0;[;{;IC;" Creates an enumerator for each chunked elements. The ends of chunks are defined by _pattern_ and the block. If _pattern_ === _elt_ returns true or the block returns true for the element, the element is end of a chunk. The === and _block_ is called from the first element to the last element of _enum_. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.slice_after(pattern).each { |ary| ... } enum.slice_after { |elt| bool }.each { |ary| ... } 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;H ;II" overload;F;J0;;-;K0;#I"slice_after(pattern);T;IC;";T;[;[;I";T;0; @O;@F;Mi;N0;[[I" pattern;T0; @Oo;H ;II" overload;F;J0;;-;K0;#I"slice_after;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"elt;T; @O;[;I"@yield [elt];T;0; @O;@F;Mi;N0;[; @O;[;I"TCreates an enumerator for each chunked elements. The ends of chunks are defined by _pattern_ and the block. If _pattern_ === _elt_ returns true or the block returns true for the element, the element is end of a chunk. The === and _block_ is called from the first element to the last element of _enum_. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.slice_after(pattern).each { |ary| ... } enum.slice_after { |elt| bool }.each { |ary| ... } 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 [elt];T;0; @O;@F;Ao;B;CT;Di ;Ei ;!@C;"I"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, rb_intern("sliceafter_enum"), enumerable); rb_ivar_set(enumerator, rb_intern("sliceafter_pat"), pat); rb_ivar_set(enumerator, rb_intern("sliceafter_pred"), pred); rb_block_call(enumerator, idInitialize, 0, 0, sliceafter_i, enumerator); return enumerator; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#slice_when;F;[;[[@CiO;T;:slice_when;0;[;{;IC;"UCreates an enumerator for each chunked elements. The beginnings of chunks are defined by the block. This method split each chunk using adjacent elements, _elt_before_ and _elt_after_, in the receiver enumerator. This method split chunks between _elt_before_ and _elt_after_ where the block returns true. The block is called the length of the receiver enumerator minus one. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } Other methods of the Enumerator class and Enumerable module, such as +to_a+, +map+, etc., are also usable. For example, one-by-one increasing subsequence can be chunked as follows: a = [1,2,4,9,10,11,12,15,16,19,20,21] b = a.slice_when {|i, j| i+1 != j } p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] d = c.join(",") p d #=> "1,2,4,9-12,15,16,19-21" Near elements (threshold: 6) in sorted array can be chunked as follows: a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] p a.slice_when {|i, j| 6 < j - i }.to_a #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] Increasing (non-decreasing) subsequence can be chunked as follows: a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] p a.slice_when {|i, j| i > j }.to_a #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is another way to do it.) a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] p a.slice_when {|i, j| i.even? != j.even? }.to_a #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] Paragraphs (non-empty lines with trailing empty lines) can be chunked as follows: (See Enumerable#chunk to ignore empty lines.) lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] Enumerable#chunk_while does the same, except splitting when the block returns false instead of true. ;T;[o;H ;II" overload;F;J0;;.;K0;#I"slice_when;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"elt_before;TI"elt_after;T; @-O;[;I"#@yield [elt_before, elt_after];T;0; @-O;@F;Mi;N0;[; @-O;[;I"Creates an enumerator for each chunked elements. The beginnings of chunks are defined by the block. This method split each chunk using adjacent elements, _elt_before_ and _elt_after_, in the receiver enumerator. This method split chunks between _elt_before_ and _elt_after_ where the block returns true. The block is called the length of the receiver enumerator minus one. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.slice_when { |elt_before, elt_after| bool }.each { |ary| ... } Other methods of the Enumerator class and Enumerable module, such as +to_a+, +map+, etc., are also usable. For example, one-by-one increasing subsequence can be chunked as follows: a = [1,2,4,9,10,11,12,15,16,19,20,21] b = a.slice_when {|i, j| i+1 != j } p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] d = c.join(",") p d #=> "1,2,4,9-12,15,16,19-21" Near elements (threshold: 6) in sorted array can be chunked as follows: a = [3, 11, 14, 25, 28, 29, 29, 41, 55, 57] p a.slice_when {|i, j| 6 < j - i }.to_a #=> [[3], [11, 14], [25, 28, 29, 29], [41], [55, 57]] Increasing (non-decreasing) subsequence can be chunked as follows: a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] p a.slice_when {|i, j| i > j }.to_a #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is another way to do it.) a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] p a.slice_when {|i, j| i.even? != j.even? }.to_a #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] Paragraphs (non-empty lines with trailing empty lines) can be chunked as follows: (See Enumerable#chunk to ignore empty lines.) lines = ["foo\n", "bar\n", "\n", "baz\n", "qux\n"] p lines.slice_when {|l1, l2| /\A\s*\z/ =~ l1 && /\S/ =~ l2 }.to_a #=> [["foo\n", "bar\n", "\n"], ["baz\n", "qux\n"]] Enumerable#chunk_while does the same, except splitting when the block returns false instead of true. @overload slice_when @yield [elt_before, elt_after];T;0; @-O;@F;Ao;B;CT;Di;EiM;!@C;"I"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, rb_intern("slicewhen_enum"), enumerable); rb_ivar_set(enumerator, rb_intern("slicewhen_pred"), pred); rb_ivar_set(enumerator, rb_intern("slicewhen_inverted"), Qfalse); rb_block_call(enumerator, idInitialize, 0, 0, slicewhen_i, enumerator); return enumerator; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#chunk_while;F;[;[[@Ci;T;:chunk_while;0;[;{;IC;"PCreates an enumerator for each chunked elements. The beginnings of chunks are defined by the block. This method split each chunk using adjacent elements, _elt_before_ and _elt_after_, in the receiver enumerator. This method split chunks between _elt_before_ and _elt_after_ where the block returns false. The block is called the length of the receiver enumerator minus one. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } Other methods of the Enumerator class and Enumerable module, such as +to_a+, +map+, etc., are also usable. For example, one-by-one increasing subsequence can be chunked as follows: a = [1,2,4,9,10,11,12,15,16,19,20,21] b = a.chunk_while {|i, j| i+1 == j } p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] d = c.join(",") p d #=> "1,2,4,9-12,15,16,19-21" Increasing (non-decreasing) subsequence can be chunked as follows: a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] p a.chunk_while {|i, j| i <= j }.to_a #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is another way to do it.) a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] p a.chunk_while {|i, j| i.even? == j.even? }.to_a #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] Enumerable#slice_when does the same, except splitting when the block returns true instead of false. ;T;[o;H ;II" overload;F;J0;;/;K0;#I"chunk_while;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"elt_before;TI"elt_after;T; @IO;[;I"#@yield [elt_before, elt_after];T;0; @IO;@F;Mi;N0;[; @IO;[;I"Creates an enumerator for each chunked elements. The beginnings of chunks are defined by the block. This method split each chunk using adjacent elements, _elt_before_ and _elt_after_, in the receiver enumerator. This method split chunks between _elt_before_ and _elt_after_ where the block returns false. The block is called the length of the receiver enumerator minus one. The result enumerator yields the chunked elements as an array. So +each+ method can be called as follows: enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... } Other methods of the Enumerator class and Enumerable module, such as +to_a+, +map+, etc., are also usable. For example, one-by-one increasing subsequence can be chunked as follows: a = [1,2,4,9,10,11,12,15,16,19,20,21] b = a.chunk_while {|i, j| i+1 == j } p b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]] c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" } p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"] d = c.join(",") p d #=> "1,2,4,9-12,15,16,19-21" Increasing (non-decreasing) subsequence can be chunked as follows: a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5] p a.chunk_while {|i, j| i <= j }.to_a #=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]] Adjacent evens and odds can be chunked as follows: (Enumerable#chunk is another way to do it.) a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0] p a.chunk_while {|i, j| i.even? == j.even? }.to_a #=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]] Enumerable#slice_when does the same, except splitting when the block returns true instead of false. @overload chunk_while @yield [elt_before, elt_after];T;0; @IO;@F;Ao;B;CT;Di`;Ei;!@C;"I"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, rb_intern("slicewhen_enum"), enumerable); rb_ivar_set(enumerator, rb_intern("slicewhen_pred"), pred); rb_ivar_set(enumerator, rb_intern("slicewhen_inverted"), Qtrue); rb_block_call(enumerator, idInitialize, 0, 0, slicewhen_i, enumerator); return enumerator; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#sum;F;[[@0;[[@Cij;T;;|;0;[;{;IC;"Returns the sum of elements in an Enumerable. If a block is given, the block is applied to each element before addition. If enum is empty, it returns init. For example: { 1 => 10, 2 => 20 }.sum {|k, v| k * v } #=> 50 (1..10).sum #=> 55 (1..10).sum {|v| v * 2 } #=> 110 [Object.new].each.sum #=> TypeError This method can be used for non-numeric objects by explicit init argument. { 1 => 10, 2 => 20 }.sum([]) #=> [1, 10, 2, 20] "a\nb\nc".each_line.lazy.map(&:chomp).sum("") #=> "abc" Enumerable#sum method may not respect method redefinition of "+" methods such as Integer#+. ;T;[o;H ;II" overload;F;J0;;|;K0;#I"sum(init=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @eO;[;I"@return [Numeric];T;0; @eO;@F;Mi;N0;[[I" init;TI"0;T; @eOo;H ;II" overload;F;J0;;|;K0;#I"sum(init=0);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"e;T; @eOo;L ;II" return;F;JI";T;0;K[I" Numeric;T; @eO;[;I"!@yield [e] @return [Numeric];T;0; @eO;@F;Mi;N0;[[I" init;TI"0;T; @eO;[;I"!Returns the sum of elements in an Enumerable. If a block is given, the block is applied to each element before addition. If enum is empty, it returns init. For example: { 1 => 10, 2 => 20 }.sum {|k, v| k * v } #=> 50 (1..10).sum #=> 55 (1..10).sum {|v| v * 2 } #=> 110 [Object.new].each.sum #=> TypeError This method can be used for non-numeric objects by explicit init argument. { 1 => 10, 2 => 20 }.sum([]) #=> [1, 10, 2, 20] "a\nb\nc".each_line.lazy.map(&:chomp).sum("") #=> "abc" Enumerable#sum method may not respect method redefinition of "+" methods such as Integer#+. @overload sum(init=0) @return [Numeric] @overload sum(init=0) @yield [e] @return [Numeric];T;0; @eO;@F;Ao;B;CT;DiN;Eij;!@C;"I"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; } if (RTEST(rb_range_values(obj, &beg, &end, &excl))) { if (!memo.block_given && !memo.float_value && (FIXNUM_P(beg) || RB_TYPE_P(beg, T_BIGNUM)) && (FIXNUM_P(end) || RB_TYPE_P(end, T_BIGNUM))) { 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) { /* r can be an Integer when mathn is loaded */ if (FIXNUM_P(memo.r)) memo.v = rb_fix_plus(memo.r, memo.v); else if (RB_TYPE_P(memo.r, T_BIGNUM)) memo.v = rb_big_plus(memo.r, memo.v); else memo.v = rb_rational_plus(memo.r, memo.v); } return memo.v; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerable#uniq;F;[;[[@Ci;T;: uniq;0;[;{;IC;"VReturns a new array by removing duplicate values in +self+. See also Array#uniq. ;T;[o;H ;II" overload;F;J0;;0;K0;#I" uniq;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @O;[;I"@return [Array];T;0; @O;@F;Mi;N0;[; @Oo;H ;II" overload;F;J0;;0;K0;#I" uniq;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @Oo;L ;II" return;F;JI";T;0;K[I" Array;T; @O;[;I""@yield [item] @return [Array];T;0; @O;@F;Mi;N0;[; @O;[;I"Returns a new array by removing duplicate values in +self+. See also Array#uniq. @overload uniq @return [Array] @overload uniq @yield [item] @return [Array];T;0; @O;@F;Ao;B;CT;Di;Ei;!@C;"I"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;$T;&@C;'IC;[;&@C;(IC;[;&@C;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Ci;F;:Enumerable;;0;;;[;{;IC;"The Enumerable mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method each, which yields successive members of the collection. If Enumerable#max, #min, or #sort is used, the objects in the collection must also implement a meaningful <=> operator, as these methods rely on an ordering between members of the collection. ;T;[;[;I"The Enumerable mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method each, which yields successive members of the collection. If Enumerable#max, #min, or #sort is used, the objects in the collection must also implement a meaningful <=> operator, as these methods rely on an ordering between members of the collection. ;T;0; @C;@F;Ao;B;CT;Di;Ei;!@;I"Enumerable;F;&@7;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@9;i;.[;[[@7i;F;;;;0;;;[;{;IC;"W A Hash is a dictionary-like collection of unique keys and their values. Also called associative arrays, they are similar to Arrays, but where an Array uses integers as its index, a Hash allows you to use any object type. Hashes enumerate their values in the order that the corresponding keys were inserted. A Hash can be easily created by using its implicit form: grades = { "Jane Doe" => 10, "Jim Doe" => 6 } Hashes allow an alternate syntax for keys that are symbols. Instead of options = { :font_size => 10, :font_family => "Arial" } You could write it as: options = { font_size: 10, font_family: "Arial" } Each named key is a symbol you can access in hash: options[:font_size] # => 10 A Hash can also be created through its ::new method: grades = Hash.new grades["Dorothy Doe"] = 9 Hashes have a default value that is returned when accessing keys that do not exist in the hash. If no default is set +nil+ is used. You can set the default value by sending it as an argument to Hash.new: grades = Hash.new(0) Or by using the #default= method: grades = {"Timmy Doe" => 8} grades.default = 0 Accessing a value in a Hash requires using its key: puts grades["Jane Doe"] # => 0 === Common Uses Hashes are an easy way to represent data structures, such as books = {} books[:matz] = "The Ruby Programming Language" books[:black] = "The Well-Grounded Rubyist" Hashes are also commonly used as a way to have named parameters in functions. Note that no brackets are used below. If a hash is the last argument on a method call, no braces are needed, thus creating a really clean interface: Person.create(name: "John Doe", age: 27) def self.create(params) @name = params[:name] @age = params[:age] end === Hash Keys Two objects refer to the same hash key when their hash value is identical and the two objects are eql? to each other. A user-defined class may be used as a hash key if the hash and eql? methods are overridden to provide meaningful behavior. By default, separate instances refer to separate hash keys. 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 and other.author == @author and 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 See also Object#hash and Object#eql? ;T;[;[;I"X A Hash is a dictionary-like collection of unique keys and their values. Also called associative arrays, they are similar to Arrays, but where an Array uses integers as its index, a Hash allows you to use any object type. Hashes enumerate their values in the order that the corresponding keys were inserted. A Hash can be easily created by using its implicit form: grades = { "Jane Doe" => 10, "Jim Doe" => 6 } Hashes allow an alternate syntax for keys that are symbols. Instead of options = { :font_size => 10, :font_family => "Arial" } You could write it as: options = { font_size: 10, font_family: "Arial" } Each named key is a symbol you can access in hash: options[:font_size] # => 10 A Hash can also be created through its ::new method: grades = Hash.new grades["Dorothy Doe"] = 9 Hashes have a default value that is returned when accessing keys that do not exist in the hash. If no default is set +nil+ is used. You can set the default value by sending it as an argument to Hash.new: grades = Hash.new(0) Or by using the #default= method: grades = {"Timmy Doe" => 8} grades.default = 0 Accessing a value in a Hash requires using its key: puts grades["Jane Doe"] # => 0 === Common Uses Hashes are an easy way to represent data structures, such as books = {} books[:matz] = "The Ruby Programming Language" books[:black] = "The Well-Grounded Rubyist" Hashes are also commonly used as a way to have named parameters in functions. Note that no brackets are used below. If a hash is the last argument on a method call, no braces are needed, thus creating a really clean interface: Person.create(name: "John Doe", age: 27) def self.create(params) @name = params[:name] @age = params[:age] end === Hash Keys Two objects refer to the same hash key when their hash value is identical and the two objects are eql? to each other. A user-defined class may be used as a hash key if the hash and eql? methods are overridden to provide meaningful behavior. By default, separate instances refer to separate hash keys. 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 and other.author == @author and 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 See also Object#hash and Object#eql? ;T;0; @7;@F;Ao;B;CT;DiW;Ei;!@;I" Hash;F;1@<;F;o; ;IC;[;&@O;'IC;[;&@O;(IC;[;&@O;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/time/init.c;Ti;F;: Time;;0;;;[;{;IC;" ;T;[;[;@;0; @O;!@;I"Bug::Time;F;1o;2 ;30;40;50;;2;!@;7o; ;IC;[Io; ; F; ;,;;;I"Time#to_time;F;[;[[I"ext/date/date_core.c;Ti!;T;: to_time;0;[;{;IC;"Returns self. ;T;[o;H ;II" overload;F;J0;;3;K0;#I" to_time;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @O;[;I"@return [Time];T;0; @O;@F;Mi;N0;[; @O;[;I"7Returns self. @overload to_time @return [Time];T;0; @O;@F;Ao;B;CT;Di!;Ei!;!@O;"I"?static VALUE time_to_time(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#to_date;F;[;[[@Pi&!;T;: to_date;0;[;{;IC;".Returns a Date object which denotes self. ;T;[o;H ;II" overload;F;J0;;4;K0;#I" to_date;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @P;[;I"BReturns a Date object which denotes self. @overload to_date;T;0; @P;@F;Ao;B;CT;Di !;Ei#!;!@O;"I"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; ; F; ;,;;;I"Time#to_datetime;F;[;[[@PiD!;T;:to_datetime;0;[;{;IC;"2Returns a DateTime object which denotes self. ;T;[o;H ;II" overload;F;J0;;5;K0;#I"to_datetime;T;IC;";T;[;[;I";T;0; @-P;@F;Mi;N0;[; @-P;[;I"JReturns a DateTime object which denotes self. @overload to_datetime;T;0; @-P;@F;Ao;B;CT;Di>!;EiA!;!@O;"I"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;[;&@CP;'IC;[;&@CP;(IC;[;&@CP;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I" time.c;Ti;T;:tm;;0;;;[;{;IC;"/A container class for timezone conversion. ;T;[;[;I"1 A container class for timezone conversion. ;T;0; @CP;@F;Ao;B;CT;Di;Ei;!o;2 ;30;40;50;;2;!@;7@O;F0;I" Time::tm;T;1o;2 ;30;40;50;;6;!@;7@<;F0o; ; F; ;;;;I" Time.now;F;[;[[@NPiW ;T;:now;0;[;{;IC;"Creates a new Time object for the current time. This is same as Time.new without arguments. Time.now #=> 2009-06-24 12:39:54 +0900 ;T;[o;H ;II" overload;F;J0;;7;K0;#I"now;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @YP;[;I"@return [Time];T;0; @YP;@F;Mi;N0;[; @YP;[;I"Creates a new Time object for the current time. This is same as Time.new without arguments. Time.now #=> 2009-06-24 12:39:54 +0900 @overload now @return [Time];T;0; @YP;@F;Ao;B;CT;DiM ;EiT ;!@O;"I"_static VALUE time_s_now(VALUE klass) { return rb_class_new_instance(0, NULL, klass); };T;#I"static VALUE;T;$To; ; F; ;;;;I" Time.at;F;[[@0;[[@NPi ;T;:at;0;[;{;IC;"Creates a new Time object with the value given by +time+, the given number of +seconds_with_frac+, or +seconds+ and +microseconds_with_frac+ since the Epoch. +seconds_with_frac+ and +microseconds_with_frac+ can be an Integer, Float, Rational, or other Numeric. non-portable feature allows the offset to be negative on some systems. If +in+ argument is given, the result is in that timezone or UTC offset, or if a numeric argument is given, the result is in local time. Time.at(0) #=> 1969-12-31 18:00:00 -0600 Time.at(Time.at(0)) #=> 1969-12-31 18:00:00 -0600 Time.at(946702800) #=> 1999-12-31 23:00:00 -0600 Time.at(-284061600) #=> 1960-12-31 00:00:00 -0600 Time.at(946684800.2).usec #=> 200000 Time.at(946684800, 123456.789).nsec #=> 123456789 Time.at(946684800, 123456789, :nsec).nsec #=> 123456789 ;T;[o;H ;II" overload;F;J0;;8;K0;#I" at(time);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" time;T0; @tPo;H ;II" overload;F;J0;;8;K0;#I"at(seconds_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I"seconds_with_frac;T0; @tPo;H ;II" overload;F;J0;;8;K0;#I"(at(seconds, microseconds_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"microseconds_with_frac;T0; @tPo;H ;II" overload;F;J0;;8;K0;#I",at(seconds, milliseconds, :millisecond);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"milliseconds;T0[I":;TI"millisecond;T; @tPo;H ;II" overload;F;J0;;8;K0;#I"%at(seconds, microseconds, :usec);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"microseconds;T0[I":;TI" usec;T; @tPo;H ;II" overload;F;J0;;8;K0;#I",at(seconds, microseconds, :microsecond);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"microseconds;T0[I":;TI"microsecond;T; @tPo;H ;II" overload;F;J0;;8;K0;#I"$at(seconds, nanoseconds, :nsec);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"nanoseconds;T0[I":;TI" nsec;T; @tPo;H ;II" overload;F;J0;;8;K0;#I"*at(seconds, nanoseconds, :nanosecond);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"nanoseconds;T0[I":;TI"nanosecond;T; @tPo;H ;II" overload;F;J0;;8;K0;#I"at(time, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" time;T0; @tPo;H ;II" overload;F;J0;;8;K0;#I""at(seconds_with_frac, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I"seconds_with_frac;T0; @tPo;H ;II" overload;F;J0;;8;K0;#I"0at(seconds, microseconds_with_frac, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"microseconds_with_frac;T0; @tPo;H ;II" overload;F;J0;;8;K0;#I"4at(seconds, milliseconds, :millisecond, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"milliseconds;T0[I":;TI"millisecond;T; @tPo;H ;II" overload;F;J0;;8;K0;#I"-at(seconds, microseconds, :usec, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"microseconds;T0[I":;TI" usec;T; @tPo;H ;II" overload;F;J0;;8;K0;#I"4at(seconds, microseconds, :microsecond, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"microseconds;T0[I":;TI"microsecond;T; @tPo;H ;II" overload;F;J0;;8;K0;#I",at(seconds, nanoseconds, :nsec, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"nanoseconds;T0[I":;TI" nsec;T; @tPo;H ;II" overload;F;J0;;8;K0;#I"2at(seconds, nanoseconds, :nanosecond, in: tz);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tP;[;I"@return [Time];T;0; @tP;@F;Mi;N0;[[I" seconds;T0[I"nanoseconds;T0[I":;TI"nanosecond;T; @tP;[;I"Creates a new Time object with the value given by +time+, the given number of +seconds_with_frac+, or +seconds+ and +microseconds_with_frac+ since the Epoch. +seconds_with_frac+ and +microseconds_with_frac+ can be an Integer, Float, Rational, or other Numeric. non-portable feature allows the offset to be negative on some systems. If +in+ argument is given, the result is in that timezone or UTC offset, or if a numeric argument is given, the result is in local time. Time.at(0) #=> 1969-12-31 18:00:00 -0600 Time.at(Time.at(0)) #=> 1969-12-31 18:00:00 -0600 Time.at(946702800) #=> 1999-12-31 23:00:00 -0600 Time.at(-284061600) #=> 1960-12-31 00:00:00 -0600 Time.at(946684800.2).usec #=> 200000 Time.at(946684800, 123456.789).nsec #=> 123456789 Time.at(946684800, 123456789, :nsec).nsec #=> 123456789 @overload at(time) @return [Time] @overload at(seconds_with_frac) @return [Time] @overload at(seconds, microseconds_with_frac) @return [Time] @overload at(seconds, milliseconds, :millisecond) @return [Time] @overload at(seconds, microseconds, :usec) @return [Time] @overload at(seconds, microseconds, :microsecond) @return [Time] @overload at(seconds, nanoseconds, :nsec) @return [Time] @overload at(seconds, nanoseconds, :nanosecond) @return [Time] @overload at(time, in: tz) @return [Time] @overload at(seconds_with_frac, in: tz) @return [Time] @overload at(seconds, microseconds_with_frac, in: tz) @return [Time] @overload at(seconds, milliseconds, :millisecond, in: tz) @return [Time] @overload at(seconds, microseconds, :usec, in: tz) @return [Time] @overload at(seconds, microseconds, :microsecond, in: tz) @return [Time] @overload at(seconds, nanoseconds, :nsec, in: tz) @return [Time] @overload at(seconds, nanoseconds, :nanosecond, in: tz) @return [Time];T;0; @tP;@F;Ao;B;CT;Din ;Ei ;!@O;"I"1static VALUE time_s_at(int argc, VALUE *argv, VALUE klass) { VALUE time, t, unit = Qundef, zone = Qundef, opts; wideval_t timew; argc = rb_scan_args(argc, argv, "12:", &time, &t, &unit, &opts); if (!NIL_P(opts)) { ID ids[1]; VALUE vals[numberof(ids)]; CONST_ID(ids[0], "in"); rb_get_kwargs(opts, ids, 0, 1, vals); zone = vals[0]; } if (argc >= 2) { int scale = argc == 3 ? get_scale(unit) : 1000000; time = num_exact(time); t = num_exact(t); timew = wadd(rb_time_magnify(v2w(time)), wmulquoll(v2w(t), TIME_SCALE, scale)); t = time_new_timew(klass, timew); } else if (IsTimeval(time)) { struct time_object *tobj, *tobj2; GetTimeval(time, tobj); t = time_new_timew(klass, tobj->timew); GetTimeval(t, tobj2); TZMODE_COPY(tobj2, tobj); } else { timew = rb_time_magnify(v2w(num_exact(time))); t = time_new_timew(klass, timew); } if (zone != Qundef) { time_zonelocal(t, zone); } return t; };T;#I"static VALUE;T;$To; ; F; ;;;;I" Time.utc;F;[[@0;[[@NPi) ;T;:utc;0;[;{;IC;"Creates a Time object based on given values, interpreted as UTC (GMT). The year must be specified. Other values default to the minimum value for that field (and may be +nil+ or omitted). Months may be specified by numbers from 1 to 12, or by the three-letter English month names. Hours are specified on a 24-hour clock (0..23). Raises an ArgumentError if any values are out of range. Will also accept ten arguments in the order output by Time#to_a. +sec_with_frac+ and +usec_with_frac+ can have a fractional part. Time.utc(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC ;T;[o;H ;II" overload;F;J0;;9;K0;#I"utc(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[I" year;T0; @Qo;H ;II" overload;F;J0;;9;K0;#I"utc(year, month);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[I" year;T0[I" month;T0; @Qo;H ;II" overload;F;J0;;9;K0;#I"utc(year, month, day);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[I" year;T0[I" month;T0[I"day;T0; @Qo;H ;II" overload;F;J0;;9;K0;#I" utc(year, month, day, hour);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0; @Qo;H ;II" overload;F;J0;;9;K0;#I"%utc(year, month, day, hour, min);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0; @Qo;H ;II" overload;F;J0;;9;K0;#I"4utc(year, month, day, hour, min, sec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec_with_frac;T0; @Qo;H ;II" overload;F;J0;;9;K0;#I":utc(year, month, day, hour, min, sec, usec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec;T0[I"usec_with_frac;T0; @Qo;H ;II" overload;F;J0;;9;K0;#I"Futc(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[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; @Qo;H ;II" overload;F;J0;:gm;K0;#I" gm(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[I" year;T0; @Qo;H ;II" overload;F;J0;;:;K0;#I"gm(year, month);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[I" year;T0[I" month;T0; @Qo;H ;II" overload;F;J0;;:;K0;#I"gm(year, month, day);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[I" year;T0[I" month;T0[I"day;T0; @Qo;H ;II" overload;F;J0;;:;K0;#I"gm(year, month, day, hour);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0; @Qo;H ;II" overload;F;J0;;:;K0;#I"$gm(year, month, day, hour, min);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0; @Qo;H ;II" overload;F;J0;;:;K0;#I"3gm(year, month, day, hour, min, sec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec_with_frac;T0; @Qo;H ;II" overload;F;J0;;:;K0;#I"9gm(year, month, day, hour, min, sec, usec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec;T0[I"usec_with_frac;T0; @Qo;H ;II" overload;F;J0;;:;K0;#I"Egm(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Q;[;I"@return [Time];T;0; @Q;@F;Mi;N0;[[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; @Q;[;I"WCreates a Time object based on given values, interpreted as UTC (GMT). The year must be specified. Other values default to the minimum value for that field (and may be +nil+ or omitted). Months may be specified by numbers from 1 to 12, or by the three-letter English month names. Hours are specified on a 24-hour clock (0..23). Raises an ArgumentError if any values are out of range. Will also accept ten arguments in the order output by Time#to_a. +sec_with_frac+ and +usec_with_frac+ can have a fractional part. Time.utc(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC @overload utc(year) @return [Time] @overload utc(year, month) @return [Time] @overload utc(year, month, day) @return [Time] @overload utc(year, month, day, hour) @return [Time] @overload utc(year, month, day, hour, min) @return [Time] @overload utc(year, month, day, hour, min, sec_with_frac) @return [Time] @overload utc(year, month, day, hour, min, sec, usec_with_frac) @return [Time] @overload utc(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy) @return [Time] @overload gm(year) @return [Time] @overload gm(year, month) @return [Time] @overload gm(year, month, day) @return [Time] @overload gm(year, month, day, hour) @return [Time] @overload gm(year, month, day, hour, min) @return [Time] @overload gm(year, month, day, hour, min, sec_with_frac) @return [Time] @overload gm(year, month, day, hour, min, sec, usec_with_frac) @return [Time] @overload gm(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy) @return [Time];T;0; @Q;@F;Ao;B;CT;Di ;Ei6 ;!@O;"I"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; ; F; ;;;;I" Time.gm;F;[[@0;[[@NPi) ;T;;:;0;[;{;IC;"Creates a Time object based on given values, interpreted as UTC (GMT). The year must be specified. Other values default to the minimum value for that field (and may be +nil+ or omitted). Months may be specified by numbers from 1 to 12, or by the three-letter English month names. Hours are specified on a 24-hour clock (0..23). Raises an ArgumentError if any values are out of range. Will also accept ten arguments in the order output by Time#to_a. +sec_with_frac+ and +usec_with_frac+ can have a fractional part. Time.utc(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC ;T;[o;H ;II" overload;F;J0;;9;K0;#I"utc(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[I" year;T0; @ So;H ;II" overload;F;J0;;9;K0;#I"utc(year, month);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[I" year;T0[I" month;T0; @ So;H ;II" overload;F;J0;;9;K0;#I"utc(year, month, day);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[I" year;T0[I" month;T0[I"day;T0; @ So;H ;II" overload;F;J0;;9;K0;#I" utc(year, month, day, hour);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0; @ So;H ;II" overload;F;J0;;9;K0;#I"%utc(year, month, day, hour, min);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0; @ So;H ;II" overload;F;J0;;9;K0;#I"4utc(year, month, day, hour, min, sec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec_with_frac;T0; @ So;H ;II" overload;F;J0;;9;K0;#I":utc(year, month, day, hour, min, sec, usec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec;T0[I"usec_with_frac;T0; @ So;H ;II" overload;F;J0;;9;K0;#I"Futc(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[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; @ So;H ;II" overload;F;J0;;:;K0;#I" gm(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[I" year;T0; @ So;H ;II" overload;F;J0;;:;K0;#I"gm(year, month);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[I" year;T0[I" month;T0; @ So;H ;II" overload;F;J0;;:;K0;#I"gm(year, month, day);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[I" year;T0[I" month;T0[I"day;T0; @ So;H ;II" overload;F;J0;;:;K0;#I"gm(year, month, day, hour);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0; @ So;H ;II" overload;F;J0;;:;K0;#I"$gm(year, month, day, hour, min);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0; @ So;H ;II" overload;F;J0;;:;K0;#I"3gm(year, month, day, hour, min, sec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec_with_frac;T0; @ So;H ;II" overload;F;J0;;:;K0;#I"9gm(year, month, day, hour, min, sec, usec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec;T0[I"usec_with_frac;T0; @ So;H ;II" overload;F;J0;;:;K0;#I"Egm(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ S;[;I"@return [Time];T;0; @ S;@F;Mi;N0;[[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; @ S;[;@S;0; @ S;@F;Ao;B;CT;Di ;Ei6 ;!@O;"I"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; ; F; ;;;;I"Time.local;F;[[@0;[[@NPiK ;T;: local;0;[;{;IC;"Same as Time::gm, but interprets the values in the local time zone. Time.local(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 -0600 ;T;[o;H ;II" overload;F;J0;;;;K0;#I"local(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @T;[;I"@return [Time];T;0; @T;@F;Mi;N0;[[I" year;T0; @To;H ;II" overload;F;J0;;;;K0;#I"local(year, month);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @T;[;I"@return [Time];T;0; @T;@F;Mi;N0;[[I" year;T0[I" month;T0; @To;H ;II" overload;F;J0;;;;K0;#I"local(year, month, day);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @T;[;I"@return [Time];T;0; @T;@F;Mi;N0;[[I" year;T0[I" month;T0[I"day;T0; @To;H ;II" overload;F;J0;;;;K0;#I""local(year, month, day, hour);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @T;[;I"@return [Time];T;0; @T;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0; @To;H ;II" overload;F;J0;;;;K0;#I"'local(year, month, day, hour, min);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @T;[;I"@return [Time];T;0; @T;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0; @To;H ;II" overload;F;J0;;;;K0;#I"6local(year, month, day, hour, min, sec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @T;[;I"@return [Time];T;0; @T;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec_with_frac;T0; @To;H ;II" overload;F;J0;;;;K0;#I" 2000-01-01 20:15:01 -0600 @overload local(year) @return [Time] @overload local(year, month) @return [Time] @overload local(year, month, day) @return [Time] @overload local(year, month, day, hour) @return [Time] @overload local(year, month, day, hour, min) @return [Time] @overload local(year, month, day, hour, min, sec_with_frac) @return [Time] @overload local(year, month, day, hour, min, sec, usec_with_frac) @return [Time] @overload local(sec, min, hour, day, month, year, dummy, dummy, isdst, dummy) @return [Time] @overload mktime(year) @return [Time] @overload mktime(year, month) @return [Time] @overload mktime(year, month, day) @return [Time] @overload mktime(year, month, day, hour) @return [Time] @overload mktime(year, month, day, hour, min) @return [Time] @overload mktime(year, month, day, hour, min, sec_with_frac) @return [Time] @overload mktime(year, month, day, hour, min, sec, usec_with_frac) @return [Time] @overload mktime(sec, min, hour, day, month, year, dummy, dummy, isdst, dummy) @return [Time];T;0; @T;@F;Ao;B;CT;Di2 ;EiW ;!@O;"I"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; ; F; ;;;;I"Time.mktime;F;[[@0;[[@NPiK ;T;;<;0;[;{;IC;"Same as Time::gm, but interprets the values in the local time zone. Time.local(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 -0600 ;T;[o;H ;II" overload;F;J0;;;;K0;#I"local(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ V;[;I"@return [Time];T;0; @ V;@F;Mi;N0;[[I" year;T0; @ Vo;H ;II" overload;F;J0;;;;K0;#I"local(year, month);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ V;[;I"@return [Time];T;0; @ V;@F;Mi;N0;[[I" year;T0[I" month;T0; @ Vo;H ;II" overload;F;J0;;;;K0;#I"local(year, month, day);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ V;[;I"@return [Time];T;0; @ V;@F;Mi;N0;[[I" year;T0[I" month;T0[I"day;T0; @ Vo;H ;II" overload;F;J0;;;;K0;#I""local(year, month, day, hour);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ V;[;I"@return [Time];T;0; @ V;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0; @ Vo;H ;II" overload;F;J0;;;;K0;#I"'local(year, month, day, hour, min);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ V;[;I"@return [Time];T;0; @ V;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0; @ Vo;H ;II" overload;F;J0;;;;K0;#I"6local(year, month, day, hour, min, sec_with_frac);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @ V;[;I"@return [Time];T;0; @ V;@F;Mi;N0;[ [I" year;T0[I" month;T0[I"day;T0[I" hour;T0[I"min;T0[I"sec_with_frac;T0; @ Vo;H ;II" overload;F;J0;;;;K0;#I" "1270968656.89607" t.to_i #=> 1270968656 ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @W;[;I"@return [Integer];T;0; @W;@F;Mi;N0;[; @Wo;H ;II" overload;F;J0;: tv_sec;K0;#I" tv_sec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @W;[;I"@return [Integer];T;0; @W;@F;Mi;N0;[; @W;[;I"Returns the value of _time_ as an integer number of seconds since the Epoch. t = Time.now "%10.5f" % t.to_f #=> "1270968656.89607" t.to_i #=> 1270968656 @overload to_i @return [Integer] @overload tv_sec @return [Integer];T;0; @W;@F;Ao;B;CT;DiT ;Ei_ ;!@O;"I"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; ; F; ;,;;;I"Time#to_f;F;[;[[@NPiy ;T;;>;0;[;{;IC;"'Returns the value of _time_ as a floating point number of seconds since the Epoch. t = Time.now "%10.5f" % t.to_f #=> "1270968744.77658" t.to_i #=> 1270968744 Note that IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" to_f;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @W;[;I"@return [Float];T;0; @W;@F;Mi;N0;[; @W;[;I"JReturns the value of _time_ as a floating point number of seconds since the Epoch. t = Time.now "%10.5f" % t.to_f #=> "1270968744.77658" t.to_i #=> 1270968744 Note that IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch. @overload to_f @return [Float];T;0; @W;@F;Ao;B;CT;Dij ;Eiv ;!@O;"I"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; ; F; ;,;;;I"Time#to_r;F;[;[[@NPi ;T;;;0;[;{;IC;"?Returns the value of _time_ as a rational number of seconds since the Epoch. t = Time.now t.to_r #=> (1270968792716287611/1000000000) This methods is intended to be used to get an accurate value representing the nanoseconds since the Epoch. You can use this method to convert _time_ to another Epoch. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_r;T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[; @W;[;I"PReturns the value of _time_ as a rational number of seconds since the Epoch. t = Time.now t.to_r #=> (1270968792716287611/1000000000) This methods is intended to be used to get an accurate value representing the nanoseconds since the Epoch. You can use this method to convert _time_ to another Epoch. @overload to_r;T;0; @W;@F;Ao;B;CT;Di ;Ei ;!@O;"I"static VALUE time_to_r(VALUE time) { struct time_object *tobj; VALUE v; GetTimeval(time, tobj); v = w2v(rb_time_unmagnify(tobj->timew)); if (!RB_TYPE_P(v, T_RATIONAL)) { v = rb_Rational1(v); } return v; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Time#<=>;F;[[I" time2;T0;[[@NPi;T;;V;0;[;{;IC;"rComparison---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 ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(other_time);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @W;[;I"@return [-1, 0, +1, nil];T;0; @W;@F;Mi;N0;[[I"other_time;T0; @W;[;I"Comparison---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; @W;@F;Ao;B;CT;Di ;Ei;!@O;"I"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; ; F; ;,;;;I"Time#eql?;F;[[I" time2;T0;[[@NPi#;T;;R;0;[;{;IC;"rReturns +true+ if _time_ and +other_time+ are both Time objects with the same seconds and fractional seconds.;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other_time);T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[[I"other_time;T0; @Wo;L ;II" return;F;J@;0;K[@; @W;[;I"Returns +true+ if _time_ and +other_time+ are both Time objects with the same seconds and fractional seconds. @overload eql?(other_time);T;0; @W;@F;Ao;B;CT;Di;Ei;Mi;!@O;"I"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; ; F; ;,;;;I"Time#hash;F;[;[[@NPiU;T;;U;0;[;{;IC;"EReturns a hash code for this Time object. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @X;[;I"@return [Integer];T;0; @X;@F;Mi;N0;[; @X;[;I"jReturns a hash code for this Time object. See also Object#hash. @overload hash @return [Integer];T;0; @X;@F;Ao;B;CT;DiL;EiR;!@O;"I"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; ; F; ;,;;;I"Time#initialize;F;[[@0;[[@NPi< ;T;;;0;[;{;IC;"Returns a Time object. It is initialized to the current system time if no argument is given. *Note:* The new object will use the resolution available on your system clock, and may include fractional seconds. If one or more arguments are specified, the time is initialized to the specified time. +sec+ may have fraction if it is a rational. +tz+ specifies the timezone. It can be an offset from UTC, given either as a string such as "+09:00" or as a number of seconds such as 32400. Or it can be a timezone object, see {Timezone argument}[#class-Time-label-Timezone+argument] for details. a = Time.new #=> 2007-11-19 07:50:02 -0600 b = Time.new #=> 2007-11-19 07:50:02 -0600 a == b #=> false "%.6f" % a.to_f #=> "1195480202.282373" "%.6f" % b.to_f #=> "1195480202.283415" Time.new(2008,6,21, 13,30,0, "+09:00") #=> 2008-06-21 13:30:00 +0900 # A trip for RubyConf 2007 t1 = Time.new(2007,11,1,15,25,0, "+09:00") # JST (Narita) t2 = Time.new(2007,11,1,12, 5,0, "-05:00") # CDT (Minneapolis) t3 = Time.new(2007,11,1,13,25,0, "-05:00") # CDT (Minneapolis) t4 = Time.new(2007,11,1,16,53,0, "-04:00") # EDT (Charlotte) t5 = Time.new(2007,11,5, 9,24,0, "-05:00") # EST (Charlotte) t6 = Time.new(2007,11,5,11,21,0, "-05:00") # EST (Detroit) t7 = Time.new(2007,11,5,13,45,0, "-05:00") # EST (Detroit) t8 = Time.new(2007,11,6,17,10,0, "+09:00") # JST (Narita) (t2-t1)/3600.0 #=> 10.666666666666666 (t4-t3)/3600.0 #=> 2.466666666666667 (t6-t5)/3600.0 #=> 1.95 (t8-t7)/3600.0 #=> 13.416666666666666 ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @6X;[;I"@return [Time];T;0; @6X;@F;Mi;N0;[; @6Xo;H ;II" overload;F;J0;; ;K0;#I"Fnew(year, month=nil, day=nil, hour=nil, min=nil, sec=nil, tz=nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @6X;[;I"@return [Time];T;0; @6X;@F;Mi;N0;[ [I" year;T0[I" month;TI"nil;T[I"day;TI"nil;T[I" hour;TI"nil;T[I"min;TI"nil;T[I"sec;TI"nil;T[I"tz;TI"nil;T; @6X;[;I"Returns a Time object. It is initialized to the current system time if no argument is given. *Note:* The new object will use the resolution available on your system clock, and may include fractional seconds. If one or more arguments are specified, the time is initialized to the specified time. +sec+ may have fraction if it is a rational. +tz+ specifies the timezone. It can be an offset from UTC, given either as a string such as "+09:00" or as a number of seconds such as 32400. Or it can be a timezone object, see {Timezone argument}[#class-Time-label-Timezone+argument] for details. a = Time.new #=> 2007-11-19 07:50:02 -0600 b = Time.new #=> 2007-11-19 07:50:02 -0600 a == b #=> false "%.6f" % a.to_f #=> "1195480202.282373" "%.6f" % b.to_f #=> "1195480202.283415" Time.new(2008,6,21, 13,30,0, "+09:00") #=> 2008-06-21 13:30:00 +0900 # A trip for RubyConf 2007 t1 = Time.new(2007,11,1,15,25,0, "+09:00") # JST (Narita) t2 = Time.new(2007,11,1,12, 5,0, "-05:00") # CDT (Minneapolis) t3 = Time.new(2007,11,1,13,25,0, "-05:00") # CDT (Minneapolis) t4 = Time.new(2007,11,1,16,53,0, "-04:00") # EDT (Charlotte) t5 = Time.new(2007,11,5, 9,24,0, "-05:00") # EST (Charlotte) t6 = Time.new(2007,11,5,11,21,0, "-05:00") # EST (Detroit) t7 = Time.new(2007,11,5,13,45,0, "-05:00") # EST (Detroit) t8 = Time.new(2007,11,6,17,10,0, "+09:00") # JST (Narita) (t2-t1)/3600.0 #=> 10.666666666666666 (t4-t3)/3600.0 #=> 2.466666666666667 (t6-t5)/3600.0 #=> 1.95 (t8-t7)/3600.0 #=> 13.416666666666666 @overload new @return [Time] @overload new(year, month=nil, day=nil, hour=nil, min=nil, sec=nil, tz=nil) @return [Time];T;0; @6X;@F;Ao;B;CT;Di ;Ei: ;!@O;"I"static VALUE time_init(int argc, VALUE *argv, VALUE time) { if (argc == 0) return time_init_0(time); else return time_init_1(argc, argv, time); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#initialize_copy;F;[[I" time;T0;[[@NPi_;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @sX;@F;Ao;B;CT;Di^;Ei^;!@O;"I" 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; ; F; ;,;;;I"Time#localtime;F;[[@0;[[@NPi;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;H ;II" overload;F;J0;;>;K0;#I"localtime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;>;K0;#I"localtime(utc_offset);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[[I"utc_offset;T0; @X;[;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; @X;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#gmtime;F;[;[[@NPi;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;H ;II" overload;F;J0;;?;K0;#I" gmtime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;9;K0;#I"utc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[; @X;[;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; @X;@F;Ao;B;CT;Di;Ei;!@O;"I"static 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 = rb_fstring_lit("UTC"); GMTIMEW(tobj->timew, &vtm); tobj->vtm = vtm; tobj->tm_got = 1; TZMODE_SET_UTC(tobj); return time; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Time#utc;F;[;[[@NPi;T;;9;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;H ;II" overload;F;J0;;?;K0;#I" gmtime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;9;K0;#I"utc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[; @X;[;@X;0; @X;@F;Ao;B;CT;Di;Ei;!@O;"I"static 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 = rb_fstring_lit("UTC"); GMTIMEW(tobj->timew, &vtm); tobj->vtm = vtm; tobj->tm_got = 1; TZMODE_SET_UTC(tobj); return time; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#getlocal;F;[[@0;[[@NPi.;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;H ;II" overload;F;J0;;@;K0;#I" getlocal;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;@;K0;#I"getlocal(utc_offset);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[[I"utc_offset;T0; @Xo;H ;II" overload;F;J0;;@;K0;#I"getlocal(timezone);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @X;[;I"@return [Time];T;0; @X;@F;Mi;N0;[[I" timezone;T0; @X;[;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; @X;@F;Ao;B;CT;Di;Ei-;!@O;"I"static 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))) { if (NIL_P(zone = find_timezone(time, zone))) invalid_utc_offset(); time = time_dup(time); if (!zone_localtime(zone, time)) invalid_utc_offset(); return 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; ; F; ;,;;;I"Time#getgm;F;[;[[@NPiX;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;H ;II" overload;F;J0;;A;K0;#I" getgm;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @7Y;[;I"@return [Time];T;0; @7Y;@F;Mi;N0;[; @7Yo;H ;II" overload;F;J0;: getutc;K0;#I" getutc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @7Y;[;I"@return [Time];T;0; @7Y;@F;Mi;N0;[; @7Y;[;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; @7Y;@F;Ao;B;CT;DiJ;EiV;!@O;"I"Xstatic VALUE time_getgmtime(VALUE time) { return time_gmtime(time_dup(time)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#getutc;F;[;[[@NPiX;T;;B;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;H ;II" overload;F;J0;;A;K0;#I" getgm;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @_Y;[;I"@return [Time];T;0; @_Y;@F;Mi;N0;[; @_Yo;H ;II" overload;F;J0;;B;K0;#I" getutc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @_Y;[;I"@return [Time];T;0; @_Y;@F;Mi;N0;[; @_Y;[;@[Y;0; @_Y;@F;Ao;B;CT;DiJ;EiV;!@O;"I"Xstatic VALUE time_getgmtime(VALUE time) { return time_gmtime(time_dup(time)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#ctime;F;[;[[@NPit;T;: ctime;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;H ;II" overload;F;J0;: asctime;K0;#I" asctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Yo;H ;II" overload;F;J0;;C;K0;#I" ctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Y;[;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; @Y;@F;Ao;B;CT;Dii;Eir;!@O;"I"sstatic VALUE time_asctime(VALUE time) { return strftimev("%a %b %e %T %Y", time, rb_usascii_encoding()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#asctime;F;[;[[@NPit;T;;D;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;H ;II" overload;F;J0;;D;K0;#I" asctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Yo;H ;II" overload;F;J0;;C;K0;#I" ctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Y;[;@Y;0; @Y;@F;Ao;B;CT;Dii;Eir;!@O;"I"sstatic VALUE time_asctime(VALUE time) { return strftimev("%a %b %e %T %Y", time, rb_usascii_encoding()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#to_s;F;[;[[@NPi;T;;h;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Yo;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Y;[;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 inspect @return [String] @overload to_s @return [String];T;0; @Y;@F;Ao;B;CT;Diz;Ei;!@O;"I"%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; ; F; ;,;;;I"Time#inspect;F;[;[[@NPi;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Yo;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[; @Y;[;@Y;0; @Y;@F;Ao;B;CT;Diz;Ei;!@O;"I"%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; ; F; ;,;;;I"Time#to_a;F;[;[[@NPi;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;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @$Z;[;I"@return [Array];T;0; @$Z;@F;Mi;N0;[; @$Z;[;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; @$Z;@F;Ao;B;CT;Di;Ei;!@O;"I"static VALUE time_to_a(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); 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), tobj->vtm.isdst?Qtrue:Qfalse, time_zone(time)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Time#+;F;[[I" time2;T0;[[@NPi;T;;(;0;[;{;IC;"Addition --- Adds some number of seconds (possibly fractional) to _time_ and returns that value as a new Time object. t = Time.now #=> 2007-11-19 08:22:21 -0600 t + (60 * 60 * 24) #=> 2007-11-20 08:22:21 -0600 ;T;[o;H ;II" overload;F;J0;;(;K0;#I"+(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @?Z;[;I"@return [Time];T;0; @?Z;@F;Mi;N0;[[I" numeric;T0; @?Z;[;I" Addition --- Adds some number of seconds (possibly fractional) to _time_ and returns that value as a new Time object. t = Time.now #=> 2007-11-19 08:22:21 -0600 t + (60 * 60 * 24) #=> 2007-11-20 08:22:21 -0600 @overload +(numeric) @return [Time];T;0; @?Z;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I" Time#-;F;[[I" time2;T0;[[@NPi;T;;<;0;[;{;IC;"^Difference --- 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 #=> 2007-11-19 08:23:10 -0600 t2 = t + 2592000 #=> 2007-12-19 08:23:10 -0600 t2 - t #=> 2592000.0 t2 - 2592000 #=> 2007-11-19 08:23:10 -0600 ;T;[o;H ;II" overload;F;J0;;<;K0;#I"-(other_time);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @^Z;[;I"@return [Float];T;0; @^Z;@F;Mi;N0;[[I"other_time;T0; @^Zo;H ;II" overload;F;J0;;<;K0;#I"-(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @^Z;[;I"@return [Time];T;0; @^Z;@F;Mi;N0;[[I" numeric;T0; @^Z;[;I"Difference --- 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 #=> 2007-11-19 08:23:10 -0600 t2 = t + 2592000 #=> 2007-12-19 08:23:10 -0600 t2 - t #=> 2592000.0 t2 - 2592000 #=> 2007-11-19 08:23:10 -0600 @overload -(other_time) @return [Float] @overload -(numeric) @return [Time];T;0; @^Z;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#succ;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @Z;!@O;$To; ; F; ;,;;;I"Time#round;F;[[@0;[[@NPi);T;: round;0;[;{;IC;"fRounds sub seconds 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. require 'time' t = Time.utc(2010,3,30, 5,43,"25.123456789".to_r) t.iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z" t.round.iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z" t.round(0).iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z" t.round(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z" t.round(2).iso8601(10) #=> "2010-03-30T05:43:25.1200000000Z" t.round(3).iso8601(10) #=> "2010-03-30T05:43:25.1230000000Z" t.round(4).iso8601(10) #=> "2010-03-30T05:43:25.1235000000Z" t.round(5).iso8601(10) #=> "2010-03-30T05:43:25.1234600000Z" t.round(6).iso8601(10) #=> "2010-03-30T05:43:25.1234570000Z" t.round(7).iso8601(10) #=> "2010-03-30T05:43:25.1234568000Z" t.round(8).iso8601(10) #=> "2010-03-30T05:43:25.1234567900Z" t.round(9).iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z" t.round(10).iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z" t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).round.iso8601(3) #=> "1999-12-31T23:59:59.000Z" (t + 0.49).round.iso8601(3) #=> "1999-12-31T23:59:59.000Z" (t + 0.5).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z" (t + 1.4).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z" (t + 1.49).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z" (t + 1.5).round.iso8601(3) #=> "2000-01-01T00:00:01.000Z" t = Time.utc(1999,12,31, 23,59,59) (t + 0.123456789).round(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z" ;T;[o;H ;II" overload;F;J0;;E;K0;#I"round([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Z;[;I"@return [Time];T;0; @Z;@F;Mi;N0;[[I"[ndigits];T0; @Z;[;I"Rounds sub seconds 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. require 'time' t = Time.utc(2010,3,30, 5,43,"25.123456789".to_r) t.iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z" t.round.iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z" t.round(0).iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z" t.round(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z" t.round(2).iso8601(10) #=> "2010-03-30T05:43:25.1200000000Z" t.round(3).iso8601(10) #=> "2010-03-30T05:43:25.1230000000Z" t.round(4).iso8601(10) #=> "2010-03-30T05:43:25.1235000000Z" t.round(5).iso8601(10) #=> "2010-03-30T05:43:25.1234600000Z" t.round(6).iso8601(10) #=> "2010-03-30T05:43:25.1234570000Z" t.round(7).iso8601(10) #=> "2010-03-30T05:43:25.1234568000Z" t.round(8).iso8601(10) #=> "2010-03-30T05:43:25.1234567900Z" t.round(9).iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z" t.round(10).iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z" t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).round.iso8601(3) #=> "1999-12-31T23:59:59.000Z" (t + 0.49).round.iso8601(3) #=> "1999-12-31T23:59:59.000Z" (t + 0.5).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z" (t + 1.4).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z" (t + 1.49).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z" (t + 1.5).round.iso8601(3) #=> "2000-01-01T00:00:01.000Z" t = Time.utc(1999,12,31, 23,59,59) (t + 0.123456789).round(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z" @overload round([ndigits]) @return [Time];T;0; @Z;@F;Ao;B;CT;Di;Ei&;!@O;"I",static VALUE time_round(int argc, VALUE *argv, VALUE time) { VALUE ndigits, v, a, b, den; long nd; struct time_object *tobj; if (!rb_check_arity(argc, 0, 1) || NIL_P(ndigits = argv[0])) ndigits = INT2FIX(0); else ndigits = rb_to_int(ndigits); nd = NUM2LONG(ndigits); if (nd < 0) rb_raise(rb_eArgError, "negative ndigits given"); GetTimeval(time, tobj); v = w2v(rb_time_unmagnify(tobj->timew)); a = INT2FIX(1); b = INT2FIX(10); while (0 < nd) { if (nd & 1) a = mulv(a, b); b = mulv(b, b); nd = nd >> 1; } den = quov(INT2FIX(1), a); 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; ; F; ;,;;;I" Time#sec;F;[;[[@NPiZ;T;:sec;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 http://en.wikipedia.org/wiki/Leap_second for further details. t = Time.now #=> 2007-11-19 08:25:02 -0600 t.sec #=> 2 ;T;[o;H ;II" overload;F;J0;;F;K0;#I"sec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Z;[;I"@return [Integer];T;0; @Z;@F;Mi;N0;[; @Z;[;I"6Returns 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 http://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; @Z;@F;Ao;B;CT;DiL;EiW;!@O;"I"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; ; F; ;,;;;I" Time#min;F;[;[[@NPin;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;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Z;[;I"@return [Integer];T;0; @Z;@F;Mi;N0;[; @Z;[;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; @Z;@F;Ao;B;CT;Did;Eik;!@O;"I"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; ; F; ;,;;;I"Time#hour;F;[;[[@NPi;T;: hour;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;H ;II" overload;F;J0;;G;K0;#I" hour;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Z;[;I"@return [Integer];T;0; @Z;@F;Mi;N0;[; @Z;[;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; @Z;@F;Ao;B;CT;Dix;Ei;!@O;"I"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; ; F; ;,;;;I"Time#mday;F;[;[[@NPi;T;: mday;0;[;{;IC;"Returns the day of the month (1..n) for _time_. t = Time.now #=> 2007-11-19 08:27:03 -0600 t.day #=> 19 t.mday #=> 19 ;T;[o;H ;II" overload;F;J0;:day;K0;#I"day;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @[;[;I"@return [Integer];T;0; @[;@F;Mi;N0;[; @[o;H ;II" overload;F;J0;;H;K0;#I" mday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @[;[;I"@return [Integer];T;0; @[;@F;Mi;N0;[; @[;[;I"Returns the day of the month (1..n) 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;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I" Time#day;F;[;[[@NPi;T;;I;0;[;{;IC;"Returns the day of the month (1..n) for _time_. t = Time.now #=> 2007-11-19 08:27:03 -0600 t.day #=> 19 t.mday #=> 19 ;T;[o;H ;II" overload;F;J0;;I;K0;#I"day;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @,[;[;I"@return [Integer];T;0; @,[;@F;Mi;N0;[; @,[o;H ;II" overload;F;J0;;H;K0;#I" mday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @,[;[;I"@return [Integer];T;0; @,[;@F;Mi;N0;[; @,[;[;@([;0; @,[;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I" Time#mon;F;[;[[@NPi;T;:mon;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;H ;II" overload;F;J0;;J;K0;#I"mon;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @S[;[;I"@return [Integer];T;0; @S[;@F;Mi;N0;[; @S[o;H ;II" overload;F;J0;: month;K0;#I" month;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @S[;[;I"@return [Integer];T;0; @S[;@F;Mi;N0;[; @S[;[;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; @S[;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#month;F;[;[[@NPi;T;;K;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;H ;II" overload;F;J0;;J;K0;#I"mon;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @{[;[;I"@return [Integer];T;0; @{[;@F;Mi;N0;[; @{[o;H ;II" overload;F;J0;;K;K0;#I" month;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @{[;[;I"@return [Integer];T;0; @{[;@F;Mi;N0;[; @{[;[;@w[;0; @{[;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#year;F;[;[[@NPi;T;: year;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;H ;II" overload;F;J0;;L;K0;#I" year;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @[;[;I"@return [Integer];T;0; @[;@F;Mi;N0;[; @[;[;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; @[;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#wday;F;[;[[@NPi;T;: wday;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;H ;II" overload;F;J0;;M;K0;#I" wday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @[;[;I"@return [Integer];T;0; @[;@F;Mi;N0;[; @[;[;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; @[;@F;Ao;B;CT;Di;Ei;!@O;"I"static VALUE time_wday(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX((int)tobj->vtm.wday); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#yday;F;[;[[@NPii;T;: yday;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;H ;II" overload;F;J0;;N;K0;#I" yday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @[;[;I"@return [Integer];T;0; @[;@F;Mi;N0;[; @[;[;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;Ao;B;CT;Di_;Eif;!@O;"I"static VALUE time_yday(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.yday); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#isdst;F;[;[[@NPi;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;H ;II" overload;F;J0;;O;K0;#I" isdst;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @[;[;I"@return [Boolean];T;0; @[;@F;Mi;N0;[; @[o;H ;II" overload;F;J0;: dst?;K0;#I" dst?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @[;[;I"@return [Boolean];T;0; @[;@F;Mi;N0;[; @[;[;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;Ao;B;CT;Dis;Ei;!@O;"I"static VALUE time_isdst(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return tobj->vtm.isdst ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#dst?;F;[;[[@NPi;T;;P;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;H ;II" overload;F;J0;;O;K0;#I" isdst;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @\;[;I"@return [Boolean];T;0; @\;@F;Mi;N0;[; @\o;H ;II" overload;F;J0;;P;K0;#I" dst?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @\;[;I"@return [Boolean];T;0; @\;@F;Mi;N0;[; @\;[;@\;0; @\;@F;Ao;B;CT;Dis;Ei;Mi;!@O;"I"static VALUE time_isdst(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return tobj->vtm.isdst ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#zone;F;[;[[@NPi;T;: zone;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;H ;II" overload;F;J0;;Q;K0;#I" zone;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @B\;[;I"@return [String];T;0; @B\;@F;Mi;N0;[; @B\;[;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; @B\;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#gmtoff;F;[;[[@NPi;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;H ;II" overload;F;J0;:gmt_offset;K0;#I"gmt_offset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @]\;[;I"@return [Integer];T;0; @]\;@F;Mi;N0;[; @]\o;H ;II" overload;F;J0;;R;K0;#I" gmtoff;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @]\;[;I"@return [Integer];T;0; @]\;@F;Mi;N0;[; @]\o;H ;II" overload;F;J0;:utc_offset;K0;#I"utc_offset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @]\;[;I"@return [Integer];T;0; @]\;@F;Mi;N0;[; @]\;[;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;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#gmt_offset;F;[;[[@NPi;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"gmt_offset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\;[;I"@return [Integer];T;0; @\;@F;Mi;N0;[; @\o;H ;II" overload;F;J0;;R;K0;#I" gmtoff;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\;[;I"@return [Integer];T;0; @\;@F;Mi;N0;[; @\o;H ;II" overload;F;J0;;T;K0;#I"utc_offset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\;[;I"@return [Integer];T;0; @\;@F;Mi;N0;[; @\;[;@\;0; @\;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#utc_offset;F;[;[[@NPi;T;;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;H ;II" overload;F;J0;;S;K0;#I"gmt_offset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\;[;I"@return [Integer];T;0; @\;@F;Mi;N0;[; @\o;H ;II" overload;F;J0;;R;K0;#I" gmtoff;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\;[;I"@return [Integer];T;0; @\;@F;Mi;N0;[; @\o;H ;II" overload;F;J0;;T;K0;#I"utc_offset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\;[;I"@return [Integer];T;0; @\;@F;Mi;N0;[; @\;[;@\;0; @\;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"Time#utc?;F;[;[[@NPiB;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;H ;II" overload;F;J0;;U;K0;#I" utc?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @\;[;I"@return [Boolean];T;0; @\;@F;Mi;N0;[; @\o;H ;II" overload;F;J0;: gmt?;K0;#I" gmt?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @\;[;I"@return [Boolean];T;0; @\;@F;Mi;N0;[; @\;[;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;Ao;B;CT;Di0;Ei@;Mi;!@O;"I"static VALUE time_utc_p(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#gmt?;F;[;[[@NPiB;T;;V;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;H ;II" overload;F;J0;;U;K0;#I" utc?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @"];[;I"@return [Boolean];T;0; @"];@F;Mi;N0;[; @"]o;H ;II" overload;F;J0;;V;K0;#I" gmt?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @"];[;I"@return [Boolean];T;0; @"];@F;Mi;N0;[; @"];[;@];0; @"];@F;Ao;B;CT;Di0;Ei@;Mi;!@O;"I"static VALUE time_utc_p(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#sunday?;F;[;[[@NPi;T;: sunday?;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;H ;II" overload;F;J0;;W;K0;#I" sunday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @I];[;I"@return [Boolean];T;0; @I];@F;Mi;N0;[; @I];[;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; @I];@F;Ao;B;CT;Di;Ei;Mi;!@O;"I" 2003-08-04 00:00:00 -0500 t.monday? #=> true;T;[o;H ;II" overload;F;J0;;X;K0;#I" monday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @d];[;I"@return [Boolean];T;0; @d];@F;Mi;N0;[; @d];[;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; @d];@F;Ao;B;CT;Di;Ei;Mi;!@O;"I" 1991-02-19 00:00:00 -0600 t.tuesday? #=> true;T;[o;H ;II" overload;F;J0;;Y;K0;#I" tuesday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @];[;I"@return [Boolean];T;0; @];@F;Mi;N0;[; @];[;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;Ao;B;CT;Di;Ei;Mi;!@O;"I"=static VALUE time_tuesday(VALUE time) { wday_p(2); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#wednesday?;F;[;[[@NPi);T;:wednesday?;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;H ;II" overload;F;J0;;Z;K0;#I"wednesday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @];[;I"@return [Boolean];T;0; @];@F;Mi;N0;[; @];[;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;Ao;B;CT;Di;Ei&;Mi;!@O;"I"?static VALUE time_wednesday(VALUE time) { wday_p(3); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#thursday?;F;[;[[@NPi9;T;:thursday?;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;H ;II" overload;F;J0;;[;K0;#I"thursday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @];[;I"@return [Boolean];T;0; @];@F;Mi;N0;[; @];[;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; @];@F;Ao;B;CT;Di/;Ei6;Mi;!@O;"I">static VALUE time_thursday(VALUE time) { wday_p(4); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#friday?;F;[;[[@NPiI;T;: friday?;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;H ;II" overload;F;J0;;\;K0;#I" friday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @];[;I"@return [Boolean];T;0; @];@F;Mi;N0;[; @];[;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;Ao;B;CT;Di?;EiF;Mi;!@O;"I" 2006-06-10 00:00:00 -0500 t.saturday? #=> true;T;[o;H ;II" overload;F;J0;;];K0;#I"saturday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @];[;I"@return [Boolean];T;0; @];@F;Mi;N0;[; @];[;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; @];@F;Ao;B;CT;DiO;EiV;Mi;!@O;"I">static VALUE time_saturday(VALUE time) { wday_p(6); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Time#tv_sec;F;[;[[@NPia ;T;;=;0;[;{;IC;"Returns the value of _time_ as an integer number of seconds since the Epoch. t = Time.now "%10.5f" % t.to_f #=> "1270968656.89607" t.to_i #=> 1270968656 ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @^;[;I"@return [Integer];T;0; @^;@F;Mi;N0;[; @^o;H ;II" overload;F;J0;;=;K0;#I" tv_sec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @^;[;I"@return [Integer];T;0; @^;@F;Mi;N0;[; @^;[;@W;0; @^;@F;Ao;B;CT;DiT ;Ei_ ;!@O;"I"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; ; F; ;,;;;I"Time#tv_usec;F;[;[[@NPi ;T;: tv_usec;0;[;{;IC;"Returns the number of microseconds for _time_. t = Time.now #=> 2007-11-19 08:03:26 -0600 "%10.6f" % t.to_f #=> "1195481006.775195" t.usec #=> 775195 ;T;[o;H ;II" overload;F;J0;: usec;K0;#I" usec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-^;[;I"@return [Integer];T;0; @-^;@F;Mi;N0;[; @-^o;H ;II" overload;F;J0;;^;K0;#I" tv_usec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-^;[;I"@return [Integer];T;0; @-^;@F;Mi;N0;[; @-^;[;I"Returns the number of microseconds for _time_. t = Time.now #=> 2007-11-19 08:03:26 -0600 "%10.6f" % t.to_f #=> "1195481006.775195" t.usec #=> 775195 @overload usec @return [Integer] @overload tv_usec @return [Integer];T;0; @-^;@F;Ao;B;CT;Di ;Ei ;!@O;"I"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; ; F; ;,;;;I"Time#usec;F;[;[[@NPi ;T;;_;0;[;{;IC;"Returns the number of microseconds for _time_. t = Time.now #=> 2007-11-19 08:03:26 -0600 "%10.6f" % t.to_f #=> "1195481006.775195" t.usec #=> 775195 ;T;[o;H ;II" overload;F;J0;;_;K0;#I" usec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U^;[;I"@return [Integer];T;0; @U^;@F;Mi;N0;[; @U^o;H ;II" overload;F;J0;;^;K0;#I" tv_usec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U^;[;I"@return [Integer];T;0; @U^;@F;Mi;N0;[; @U^;[;@Q^;0; @U^;@F;Ao;B;CT;Di ;Ei ;!@O;"I"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; ; F; ;,;;;I"Time#tv_nsec;F;[;[[@NPi ;T;: tv_nsec;0;[;{;IC;"Returns the number of nanoseconds for _time_. t = Time.now #=> 2007-11-17 15:18:03 +0900 "%10.9f" % t.to_f #=> "1195280283.536151409" t.nsec #=> 536151406 The lowest digits of #to_f and #nsec are different because IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch. The more accurate value is returned by #nsec. ;T;[o;H ;II" overload;F;J0;: nsec;K0;#I" nsec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|^;[;I"@return [Integer];T;0; @|^;@F;Mi;N0;[; @|^o;H ;II" overload;F;J0;;`;K0;#I" tv_nsec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|^;[;I"@return [Integer];T;0; @|^;@F;Mi;N0;[; @|^;[;I"Returns the number of nanoseconds for _time_. t = Time.now #=> 2007-11-17 15:18:03 +0900 "%10.9f" % t.to_f #=> "1195280283.536151409" t.nsec #=> 536151406 The lowest digits of #to_f and #nsec are different because IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch. The more accurate value is returned by #nsec. @overload nsec @return [Integer] @overload tv_nsec @return [Integer];T;0; @|^;@F;Ao;B;CT;Di ;Ei ;!@O;"I"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; ; F; ;,;;;I"Time#nsec;F;[;[[@NPi ;T;;a;0;[;{;IC;"Returns the number of nanoseconds for _time_. t = Time.now #=> 2007-11-17 15:18:03 +0900 "%10.9f" % t.to_f #=> "1195280283.536151409" t.nsec #=> 536151406 The lowest digits of #to_f and #nsec are different because IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch. The more accurate value is returned by #nsec. ;T;[o;H ;II" overload;F;J0;;a;K0;#I" nsec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @^;[;I"@return [Integer];T;0; @^;@F;Mi;N0;[; @^o;H ;II" overload;F;J0;;`;K0;#I" tv_nsec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @^;[;I"@return [Integer];T;0; @^;@F;Mi;N0;[; @^;[;@^;0; @^;@F;Ao;B;CT;Di ;Ei ;!@O;"I"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; ; F; ;,;;;I"Time#subsec;F;[;[[@NPi ;T;: subsec;0;[;{;IC;"Returns the fraction for _time_. The return value can be a rational number. t = Time.now #=> 2009-03-26 22:33:12 +0900 "%10.9f" % t.to_f #=> "1238074392.940563917" t.subsec #=> (94056401/100000000) The lowest digits of #to_f and #subsec are different because IEEE 754 double is not accurate enough to represent the rational number. The more accurate value is returned by #subsec. ;T;[o;H ;II" overload;F;J0;;b;K0;#I" subsec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @^;[;I"@return [Numeric];T;0; @^;@F;Mi;N0;[; @^;[;I"Returns the fraction for _time_. The return value can be a rational number. t = Time.now #=> 2009-03-26 22:33:12 +0900 "%10.9f" % t.to_f #=> "1238074392.940563917" t.subsec #=> (94056401/100000000) The lowest digits of #to_f and #subsec are different because IEEE 754 double is not accurate enough to represent the rational number. The more accurate value is returned by #subsec. @overload subsec @return [Numeric];T;0; @^;@F;Ao;B;CT;Di ;Ei ;!@O;"I"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; ; F; ;,;;;I"Time#strftime;F;[[I" format;T0;[[@NPi;T;: strftime;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;H ;II" overload;F;J0;;c;K0;#I"strftime( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @^;[;I"@return [String];T;0; @^;@F;Mi;N0;[[I" string;T0; @^;[;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; @^;@F;Ao;B;CT;Di;Ei;!@O;"I"estatic 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(time, tobj); 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; ; F; ;,;;;I"Time#_dump;F;[[@0;[[@NPi`;T;: _dump;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @_;@F;Ao;B;CT;Di_;Ei_;!@O;"I"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; ; F; ;,;;;I"Time#marshal_dump;F;[;[[@NPi;T;:marshal_dump;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @_;@F;Ao;B;CT;Di;Ei;!@O;"I" static VALUE time_mdump(VALUE time) { struct time_object *tobj; unsigned long p, s; char buf[8]; int i; VALUE str; struct vtm vtm; long year; long usec, nsec; VALUE subsecx, nano, subnano, v, zone; GetTimeval(time, tobj); gmtimew(tobj->timew, &vtm); if (FIXNUM_P(vtm.year)) { year = FIX2LONG(vtm.year); if (year < 1900 || 1900+0xffff < year) rb_raise(rb_eArgError, "year too %s to marshal: %ld UTC", (year < 1900 ? "small" : "big"), year); } else { rb_raise(rb_eArgError, "year too %s to marshal: %"PRIsVALUE" UTC", (le(vtm.year, INT2FIX(1900)) ? "small" : "big"), vtm.year); } 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); } str = rb_str_new(buf, 8); 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; ; F; ;,;;;I"Time#marshal_load;F;[[I"str;T0;[[@NPi;T;:marshal_load;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @"_;@F;Ao;B;CT;Di;Ei;!@O;"I" 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; 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, NULL, Qnil))); get_attr(zone, (zone = rb_rescue(validate_zone_name, zone, NULL, Qnil))); #undef get_attr rb_copy_generic_ivar(time, str); StringValue(str); buf = (unsigned char *)RSTRING_PTR(str); if (RSTRING_LEN(str) != 8) { rb_raise(rb_eTypeError, "marshaled time format differ"); } 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); vtm.year = INT2FIX(((int)(p >> 14) & 0xffff) + 1900); vtm.mon = ((int)(p >> 10) & 0xf) + 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 = rb_fstring_lit(""); 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; } return time; };T;#I"static VALUE;T;$T;&@O;'IC;[;&@O;(IC;[@;&@O;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@NPi;F;;2;;0;;;[;{;IC;"Time is an abstraction of dates and times. Time is stored internally as the number of seconds with fraction since the _Epoch_, January 1, 1970 00:00 UTC. Also see the library module Date. The Time class treats GMT (Greenwich Mean Time) and UTC (Coordinated Universal Time) as equivalent. GMT is the older way of referring to these baseline times but persists in the names of calls on POSIX systems. All times may have fraction. Be aware of this fact when comparing times with each other -- times that are apparently equal when displayed may be different when compared. Since Ruby 1.9.2, Time implementation uses a signed 63 bit integer, Bignum or Rational. The integer is a number of nanoseconds since the _Epoch_ which can represent 1823-11-12 to 2116-02-20. When Bignum or Rational is used (before 1823, after 2116, under nanosecond), Time works slower as when integer is used. = Examples All of these examples were done using the EST timezone which is GMT-5. == Creating a new Time instance You can create a new instance of Time with Time::new. This will use the current system time. Time::now is an alias for this. You can also pass parts of the time to Time::new such as year, month, minute, etc. When you want to construct a time this way you must pass at least a year. If you pass the year with nothing else time will default to January 1 of that year at 00:00:00 with the current system timezone. Here are some examples: Time.new(2002) #=> 2002-01-01 00:00:00 -0500 Time.new(2002, 10) #=> 2002-10-01 00:00:00 -0500 Time.new(2002, 10, 31) #=> 2002-10-31 00:00:00 -0500 You can pass a UTC offset: Time.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 +0200 Or a timezone object: tz = timezone("Europe/Athens") # Eastern European Time, UTC+2 Time.new(2002, 10, 31, 2, 2, 2, tz) #=> 2002-10-31 02:02:02 +0200 You can also use Time::gm, Time::local and Time::utc to infer GMT, local and UTC timezones instead of using the current system setting. You can also create a new time using Time::at which takes the number of seconds (or fraction of seconds) since the {Unix Epoch}[http://en.wikipedia.org/wiki/Unix_time]. Time.at(628232400) #=> 1989-11-28 00:00:00 -0500 == Working with an instance of Time Once you have an instance of Time there is a multitude of things you can do with it. Below are some examples. For all of the following examples, we will work on the assumption that you have done the following: t = Time.new(1993, 02, 24, 12, 0, 0, "+09:00") Was that a monday? t.monday? #=> false What year was that again? t.year #=> 1993 Was it daylight savings at the time? t.dst? #=> false What's the day a year later? t + (60*60*24*365) #=> 1994-02-24 12:00:00 +0900 How many seconds was that since the Unix Epoch? t.to_i #=> 730522800 You can also do standard functions like compare two times. t1 = Time.new(2010) t2 = Time.new(2011) t1 == t2 #=> false t1 == t1 #=> true t1 < t2 #=> true t1 > t2 #=> false Time.new(2010,10,31).between?(t1, t2) #=> true == Timezone argument A timezone argument must have +local_to_utc+ and +utc_to_local+ methods, and may have +name+ and +abbr+ methods. The +local_to_utc+ method should convert a Time-like object from the timezone to UTC, and +utc_to_local+ is the opposite. The result also should be a Time or Time-like object (not necessary to be the same class). The #zone of the result is just ignored. Time-like argument to these methods is similar to a Time object in UTC without sub-second; it has attribute readers for the parts, e.g. #year, #month, and so on, and epoch time readers, #to_i. The sub-second attributes are fixed as 0, and #utc_offset, #zone, #isdst, and their aliases are same as a Time object in UTC. Also #to_time, #+, and #- methods are defined. The +name+ method is used for marshaling. If this method is not defined on a timezone object, Time objects using that timezone object can not be dumped by Marshal. The +abbr+ method is used by '%Z' in #strftime. === Auto conversion to Timezone At loading marshaled data, a timezone name will be converted to a timezone object by +find_timezone+ class method, if the method is defined. Similary, that class method will be called when a timezone argument does not have the necessary methods mentioned above. ;T;[;[;I"Time is an abstraction of dates and times. Time is stored internally as the number of seconds with fraction since the _Epoch_, January 1, 1970 00:00 UTC. Also see the library module Date. The Time class treats GMT (Greenwich Mean Time) and UTC (Coordinated Universal Time) as equivalent. GMT is the older way of referring to these baseline times but persists in the names of calls on POSIX systems. All times may have fraction. Be aware of this fact when comparing times with each other -- times that are apparently equal when displayed may be different when compared. Since Ruby 1.9.2, Time implementation uses a signed 63 bit integer, Bignum or Rational. The integer is a number of nanoseconds since the _Epoch_ which can represent 1823-11-12 to 2116-02-20. When Bignum or Rational is used (before 1823, after 2116, under nanosecond), Time works slower as when integer is used. = Examples All of these examples were done using the EST timezone which is GMT-5. == Creating a new Time instance You can create a new instance of Time with Time::new. This will use the current system time. Time::now is an alias for this. You can also pass parts of the time to Time::new such as year, month, minute, etc. When you want to construct a time this way you must pass at least a year. If you pass the year with nothing else time will default to January 1 of that year at 00:00:00 with the current system timezone. Here are some examples: Time.new(2002) #=> 2002-01-01 00:00:00 -0500 Time.new(2002, 10) #=> 2002-10-01 00:00:00 -0500 Time.new(2002, 10, 31) #=> 2002-10-31 00:00:00 -0500 You can pass a UTC offset: Time.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 +0200 Or a timezone object: tz = timezone("Europe/Athens") # Eastern European Time, UTC+2 Time.new(2002, 10, 31, 2, 2, 2, tz) #=> 2002-10-31 02:02:02 +0200 You can also use Time::gm, Time::local and Time::utc to infer GMT, local and UTC timezones instead of using the current system setting. You can also create a new time using Time::at which takes the number of seconds (or fraction of seconds) since the {Unix Epoch}[http://en.wikipedia.org/wiki/Unix_time]. Time.at(628232400) #=> 1989-11-28 00:00:00 -0500 == Working with an instance of Time Once you have an instance of Time there is a multitude of things you can do with it. Below are some examples. For all of the following examples, we will work on the assumption that you have done the following: t = Time.new(1993, 02, 24, 12, 0, 0, "+09:00") Was that a monday? t.monday? #=> false What year was that again? t.year #=> 1993 Was it daylight savings at the time? t.dst? #=> false What's the day a year later? t + (60*60*24*365) #=> 1994-02-24 12:00:00 +0900 How many seconds was that since the Unix Epoch? t.to_i #=> 730522800 You can also do standard functions like compare two times. t1 = Time.new(2010) t2 = Time.new(2011) t1 == t2 #=> false t1 == t1 #=> true t1 < t2 #=> true t1 > t2 #=> false Time.new(2010,10,31).between?(t1, t2) #=> true == Timezone argument A timezone argument must have +local_to_utc+ and +utc_to_local+ methods, and may have +name+ and +abbr+ methods. The +local_to_utc+ method should convert a Time-like object from the timezone to UTC, and +utc_to_local+ is the opposite. The result also should be a Time or Time-like object (not necessary to be the same class). The #zone of the result is just ignored. Time-like argument to these methods is similar to a Time object in UTC without sub-second; it has attribute readers for the parts, e.g. #year, #month, and so on, and epoch time readers, #to_i. The sub-second attributes are fixed as 0, and #utc_offset, #zone, #isdst, and their aliases are same as a Time object in UTC. Also #to_time, #+, and #- methods are defined. The +name+ method is used for marshaling. If this method is not defined on a timezone object, Time objects using that timezone object can not be dumped by Marshal. The +abbr+ method is used by '%Z' in #strftime. === Auto conversion to Timezone At loading marshaled data, a timezone name will be converted to a timezone object by +find_timezone+ class method, if the method is defined. Similary, that class method will be called when a timezone argument does not have the necessary methods mentioned above. ;T;0; @O;@F;Ao;B;CT;Di;Ei{;!@;I" Time;F;1@<;F;o; ;IC;[o; ; F; ;,;;;I"Bug::Method#rstruct_len;F;[;[[I"ext/-test-/struct/len.c;Ti;T;:rstruct_len;0;[;{;IC;" ;T;[;[;@;0; @E_;!@C_;"I"Vstatic VALUE bug_struct_len(VALUE obj) { return LONG2NUM(RSTRUCT_LEN(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Bug::Method#get;F;[[I" name;T0;[[I"ext/-test-/struct/member.c;Ti;T;:get;0;[;{;IC;" ;T;[;[;@;0; @R_;!@C_;"I"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;&@C_;'IC;[;&@C_;(IC;[;&@C_;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/method/init.c;Ti;F;: Method;;0;;;[;{;IC;" ;T;[;[;@;0; @C_;!@;I"Bug::Method;Fo; ;IC;[o; ;IC;[ o; ; F; ;,;;;I"Bug::File::Fs#fsname;F;[[I"str;T0;[[I"ext/-test-/file/fs.c;Ti4;T;: fsname;0;[;{;IC;" ;T;[;[;I";F;0; @u_;@F;N0;!@s_;"I";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; ; T; ;;;;I"Bug::File::Fs.fsname;F;@w_;@z_;T;;j;0;@}_;{;IC;" ;T;[;[;@;0; @_;Mi;!@s_;"@_;#@_;$To; ; F; ;,;;;I"Bug::File::Fs#noatime?;F;[[I"str;T0;[[@|_iV;T;: noatime?;0;[;{;IC;" ;T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @_;[;I"@return [Boolean] ;T;0; @_;@F;N0;!@s_;"I"!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; ; T; ;;;;I"Bug::File::Fs.noatime?;F;@_;@_;T;;k;0;@_;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @_;[;@;0; @_;Mi;!@s_;"@_;#@_;$T;&@s_;'IC;[;&@s_;(IC;[;&@s_;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@|_iq;F;:Fs;;0;;;[;{;IC;" ;T;[;[;@;0; @s_;Mi;!@q_;I"Bug::File::Fs;F;&@q_;'IC;[;&@q_;(IC;[;&@q_;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/file/init.c;Ti;F;: File;;0;;;[;{;IC;" ;T;[;[;@;0; @q_;!@;I"Bug::File;Fo; ;IC;[o; ; F; ;;;;I"Bug::Struct.new_duplicate;F;[[I" name;T0[I"mem;T0;[[I""ext/-test-/struct/duplicate.c;Ti;T;:new_duplicate;0;[;{;IC;" ;T;[;[;@;0; @_;!@_;"I"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; ; F; ;;;;I"$Bug::Struct.new_duplicate_under;F;[[I" name;T0[I"mem;T0;[[@_i;T;:new_duplicate_under;0;[;{;IC;" ;T;[;[;@;0; @_;!@_;"I"static VALUE bug_struct_new_duplicate_under(VALUE obj, VALUE name, VALUE mem) { const char *n = StringValueCStr(name); const char *m = StringValueCStr(mem); return rb_struct_define_under(obj, n, m, m, NULL); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Bug::Struct.class2name;F;[[I" klass;T0;[[I""ext/-test-/class/class2name.c;Ti;T;:class2name;0;[;{;IC;" ;T;[;[;@;0; @_;!@_;"I"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;&@_;'IC;[;&@_;(IC;[;&@_;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/struct/init.c;Ti;F;: Struct;;0;;;[;{;IC;" ;T;[;[;@;0; @_;!@;I"Bug::Struct;F;1o; ;IC;[o; ; F; ;;;;I"Struct.new;F;[[@0;[[I" struct.c;Ti;T;; ;0;[;{;IC;"The first two forms are used to create a new Struct subclass +class_name+ that can contain a value for each +member_name+. This subclass can be used to create instances of the structure like any other Class. If the +class_name+ is omitted an anonymous structure class will be created. Otherwise, the name of this struct will appear as a constant in class Struct, so it must be unique for all Structs in the system and must start with a capital letter. Assigning a structure class to a constant also gives the class the name of the constant. # Create a structure with a name under Struct Struct.new("Customer", :name, :address) #=> Struct::Customer Struct::Customer.new("Dave", "123 Main") #=> # # Create a structure named by its constant Customer = Struct.new(:name, :address) #=> Customer Customer.new("Dave", "123 Main") #=> # If the optional +keyword_init+ keyword argument is set to +true+, .new takes keyword arguments instead of normal arguments. Customer = Struct.new(:name, :address, keyword_init: true) Customer.new(name: "Dave", address: "123 Main") #=> # If a block is given it will be evaluated in the context of +StructClass+, passing the created class as a parameter: Customer = Struct.new(:name, :address) do def greeting "Hello #{name}!" end end Customer.new("Dave", "123 Main").greeting #=> "Hello Dave!" This is the recommended way to customize a struct. Subclassing an anonymous struct creates an extra anonymous class that will never be used. The last two forms create a new instance of a struct subclass. The number of +value+ parameters must be less than or equal to the number of attributes defined for the structure. Unset parameters default to +nil+. Passing more parameters than number of attributes will raise an ArgumentError. Customer = Struct.new(:name, :address) Customer.new("Dave", "123 Main") #=> # Customer["Dave"] #=> # ;T;[ o;H ;II" overload;F;J0;; ;K0;#I"'new([class_name] [, member_name]+);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"StructClass;T; @ `;[;I"@return [StructClass];T;0; @ `;@F;Mi;N0;[[I" [class_name][, member_name];T0; @ `o;H ;II" overload;F;J0;; ;K0;#I";new([class_name] [, member_name]+, keyword_init: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"StructClass;T; @ `;[;I"@return [StructClass];T;0; @ `;@F;Mi;N0;[[I" [class_name][, member_name];T0[I"keyword_init:;TI" true;T; @ `o;H ;II" overload;F;J0;; ;K0;#I"'new([class_name] [, member_name]+);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"StructClass;T; @ `o;L ;II" return;F;JI";T;0;K[I"StructClass;T; @ `;[;I"/@yield [StructClass] @return [StructClass];T;0; @ `;@F;Mi;N0;[[I" [class_name][, member_name];T0; @ `o;H ;II" overload;F;J0;; ;K0;#I"new(value, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ `;[;I"@return [Object];T;0; @ `;@F;Mi;N0;[[I" value;T0[I"...;T0; @ `o;H ;II" overload;F;J0;;;K0;#I"[](value, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ `;[;I"@return [Object];T;0; @ `;@F;Mi;N0;[[I" value;T0[I"...;T0; @ `;[;I" The first two forms are used to create a new Struct subclass +class_name+ that can contain a value for each +member_name+. This subclass can be used to create instances of the structure like any other Class. If the +class_name+ is omitted an anonymous structure class will be created. Otherwise, the name of this struct will appear as a constant in class Struct, so it must be unique for all Structs in the system and must start with a capital letter. Assigning a structure class to a constant also gives the class the name of the constant. # Create a structure with a name under Struct Struct.new("Customer", :name, :address) #=> Struct::Customer Struct::Customer.new("Dave", "123 Main") #=> # # Create a structure named by its constant Customer = Struct.new(:name, :address) #=> Customer Customer.new("Dave", "123 Main") #=> # If the optional +keyword_init+ keyword argument is set to +true+, .new takes keyword arguments instead of normal arguments. Customer = Struct.new(:name, :address, keyword_init: true) Customer.new(name: "Dave", address: "123 Main") #=> # If a block is given it will be evaluated in the context of +StructClass+, passing the created class as a parameter: Customer = Struct.new(:name, :address) do def greeting "Hello #{name}!" end end Customer.new("Dave", "123 Main").greeting #=> "Hello Dave!" This is the recommended way to customize a struct. Subclassing an anonymous struct creates an extra anonymous class that will never be used. The last two forms create a new instance of a struct subclass. The number of +value+ parameters must be less than or equal to the number of attributes defined for the structure. Unset parameters default to +nil+. Passing more parameters than number of attributes will raise an ArgumentError. Customer = Struct.new(:name, :address) Customer.new("Dave", "123 Main") #=> # Customer["Dave"] #=> # @overload new([class_name] [, member_name]+) @return [StructClass] @overload new([class_name] [, member_name]+, keyword_init: true) @return [StructClass] @overload new([class_name] [, member_name]+) @yield [StructClass] @return [StructClass] @overload new(value, ...) @return [Object] @overload [](value, ...) @return [Object];T;0; @ `;@F;Ao;B;CT;Di;Ei;!@ `;"I"static VALUE rb_struct_s_def(int argc, VALUE *argv, VALUE klass) { VALUE name, rest, keyword_init = Qfalse; 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 = Qfalse; } --argc; } rest = rb_ident_hash_new(); RBASIC_CLEAR_CLASS(rest); tbl = RHASH_TBL(rest); for (i=0; i 0 && RTEST(rb_struct_s_keyword_init(klass))) { struct struct_hash_set_arg arg; if (argc > 2 || !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"); } for (i=0; i argc) { rb_mem_clear((VALUE *)RSTRUCT_CONST_PTR(self)+argc, n-argc); } } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Struct#initialize_copy;F;[[I"s;T0;[[@`i;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @`;@F;Ao;B;CT;Di;Ei;!@ `;"I"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); i true joe == jane #=> false ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`;[;I"@return [Boolean];T;0; @`;@F;Mi;N0;[[I" other;T0; @`;[;I"Equality---Returns +true+ if +other+ has the same struct subclass and has equal member values (according to Object#==). Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joejr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) jane = Customer.new("Jane Doe", "456 Elm, Anytown NC", 12345) joe == joejr #=> true joe == jane #=> false @overload ==(other) @return [Boolean];T;0; @`;@F;Ao;B;CT;Di;Ei;!@ `;"I"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; ; F; ;,;;;I"Struct#eql?;F;[[I"s2;T0;[[@`i;T;;R;0;[;{;IC;"Hash equality---+other+ and +struct+ refer to the same hash key if they have the same struct subclass and have equal member values (according to Object#eql?).;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`;[;I"@return [Boolean];T;0; @`;@F;Mi;N0;[[I" other;T0; @`;[;I"Hash equality---+other+ and +struct+ refer to the same hash key if they have the same struct subclass and have equal member values (according to Object#eql?). @overload eql?(other) @return [Boolean];T;0; @`;@F;Ao;B;CT;Di;Ei;Mi;!@ `;"I"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; ; F; ;,;;;I"Struct#hash;F;[;[[@`i;T;;U;0;[;{;IC;"QReturns a hash value based on this struct's contents. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @`;[;I"@return [Integer];T;0; @`;@F;Mi;N0;[; @`;[;I"vReturns a hash value based on this struct's contents. See also Object#hash. @overload hash @return [Integer];T;0; @`;@F;Ao;B;CT;Di;Ei;!@ `;"I"Dstatic 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 INT2FIX(h); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Struct#inspect;F;[;[[@`il;T;;i;0;[;{;IC;"6Returns a description of this struct as a string. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @`;[;I"@return [String];T;0; @`;@F;Mi;N0;[; @`o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @`;[;I"@return [String];T;0; @`;@F;Mi;N0;[; @`;[;I"Returns a description of this struct as a string. @overload to_s @return [String] @overload inspect @return [String];T;0; o; ; F; ;,;;;I"Struct#to_s;F;[;[[@`i1;F;;h;;0;[;{;@`;!@ `;"I"dstatic VALUE rb_struct_inspect(VALUE s) { return rb_exec_recursive(inspect_struct, s, 0); };T;#I"static VALUE;T;@F;Ao;B;CT;Did;Eij;!@ `;"I"dstatic VALUE rb_struct_inspect(VALUE s) { return rb_exec_recursive(inspect_struct, s, 0); };T;#@a;$T@ ao; ; F; ;,;;;I"Struct#to_a;F;[;[[@`i~;T;;;0;[;{;IC;"Returns the values for this struct as an Array. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_a[1] #=> "123 Maple, Anytown NC" ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @a;[;I"@return [Array];T;0; @a;@F;Mi;N0;[; @ao;H ;II" overload;F;J0;;;K0;#I" values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @a;[;I"@return [Array];T;0; @a;@F;Mi;N0;[; @a;[;I"Returns the values for this struct as an Array. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_a[1] #=> "123 Maple, Anytown NC" @overload to_a @return [Array] @overload values @return [Array];T;0; @a;@F;Ao;B;CT;Dir;Ei|;!@ `;"I"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; ; F; ;,;;;I"Struct#to_h;F;[;[[@`i;T;;;0;[;{;IC;"Returns a Hash containing the names and values for the struct's members. If a block is given, the results of the block on each pair of the receiver will be used as pairs. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_h[:address] #=> "123 Maple, Anytown NC" joe.to_h{|name, value| [name.upcase, value.to_s.upcase]}[:ADDRESS] #=> "123 MAPLE, ANYTOWN NC" ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_h;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @@a;[;I"@return [Hash];T;0; @@a;@F;Mi;N0;[; @@ao;H ;II" overload;F;J0;;;K0;#I" to_h;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" name;TI" value;T; @@ao;L ;II" return;F;JI";T;0;K[I" Hash;T; @@a;[;I"(@yield [name, value] @return [Hash];T;0; @@a;@F;Mi;N0;[; @@a;[;I"&Returns a Hash containing the names and values for the struct's members. If a block is given, the results of the block on each pair of the receiver will be used as pairs. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_h[:address] #=> "123 Maple, Anytown NC" joe.to_h{|name, value| [name.upcase, value.to_s.upcase]}[:ADDRESS] #=> "123 MAPLE, ANYTOWN NC" @overload to_h @return [Hash] @overload to_h @yield [name, value] @return [Hash];T;0; @@a;@F;Ao;B;CT;Di;Ei;!@ `;"I"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 "123 Maple, Anytown NC" ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @na;[;I"@return [Array];T;0; @na;@F;Mi;N0;[; @nao;H ;II" overload;F;J0;;;K0;#I" values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @na;[;I"@return [Array];T;0; @na;@F;Mi;N0;[; @na;[;@ 3 ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @a;[;I"@return [Integer];T;0; @a;@F;Mi;N0;[; @ao;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @a;[;I"@return [Integer];T;0; @a;@F;Mi;N0;[; @a;[;I"Returns the number of struct members. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.length #=> 3 @overload length @return [Integer] @overload size @return [Integer];T;0; @a;@F;Ao;B;CT;Di;Ei;!@ `;"I"KVALUE rb_struct_size(VALUE s) { return LONG2FIX(RSTRUCT_LEN(s)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Struct#length;F;[;[[@`i;T;;;0;[;{;IC;"Returns the number of struct members. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.length #=> 3 ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @a;[;I"@return [Integer];T;0; @a;@F;Mi;N0;[; @ao;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @a;[;I"@return [Integer];T;0; @a;@F;Mi;N0;[; @a;[;@a;0; @a;@F;Ao;B;CT;Di;Ei;!@ `;"I"KVALUE rb_struct_size(VALUE s) { return LONG2FIX(RSTRUCT_LEN(s)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Struct#each;F;[;[[@`i;T;;;0;[;{;IC;"+Yields the value of each struct member in order. If no block is given an enumerator is returned. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each {|x| puts(x) } Produces: Joe Smith 123 Maple, Anytown NC 12345 ;T;[o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @a;[;I"@yield [obj];T;0; @a;@F;Mi;N0;[; @ao;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @a;@F;Mi;N0;[; @a;[;I"ZYields the value of each struct member in order. If no block is given an enumerator is returned. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each {|x| puts(x) } Produces: Joe Smith 123 Maple, Anytown NC 12345 @overload each @yield [obj] @overload each;T;0; @a;@F;Ao;B;CT;Di;Ei;!@ `;"I"static VALUE rb_struct_each(VALUE s) { long i; RETURN_SIZED_ENUMERATOR(s, 0, 0, struct_enum_size); for (i=0; i #{value}") } Produces: name => Joe Smith address => 123 Maple, Anytown NC zip => 12345 ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"sym;TI"obj;T; @b;[;I"@yield [sym, obj];T;0; @b;@F;Mi;N0;[; @bo;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[; @b;[;I"Yields the name and value of each struct member in order. If no block is given an enumerator is returned. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each_pair {|name, value| puts("#{name} => #{value}") } Produces: name => Joe Smith address => 123 Maple, Anytown NC zip => 12345 @overload each_pair @yield [sym, obj] @overload each_pair;T;0; @b;@F;Ao;B;CT;Di ;Ei;!@ `;"I",static 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_arity() > 1) { for (i=0; i "Joe Smith" joe[:name] #=> "Joe Smith" joe[0] #=> "Joe Smith" ;T;[o;H ;II" overload;F;J0;;;K0;#I"[](member);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @+b;[;I"@return [Object];T;0; @+b;@F;Mi;N0;[[I" member;T0; @+bo;H ;II" overload;F;J0;;;K0;#I"[](index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @+b;[;I"@return [Object];T;0; @+b;@F;Mi;N0;[[I" index;T0; @+b;[;I"Attribute Reference---Returns the value of the given struct +member+ or the member at the given +index+. Raises NameError if the +member+ does not exist and IndexError if the +index+ is out of range. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe["name"] #=> "Joe Smith" joe[:name] #=> "Joe Smith" joe[0] #=> "Joe Smith" @overload [](member) @return [Object] @overload [](index) @return [Object];T;0; @+b;@F;Ao;B;CT;Di;Ei;!@ `;"I"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; ; F; ;,;;;I"Struct#[]=;F;[[I"idx;T0[I"val;T0;[[@`i;T;;+;0;[;{;IC;"Attribute Assignment---Sets the value of the given struct +member+ or the member at the given +index+. Raises NameError if the +member+ does not exist and IndexError if the +index+ is out of range. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe["name"] = "Luke" joe[:zip] = "90210" joe.name #=> "Luke" joe.zip #=> "90210" ;T;[o;H ;II" overload;F;J0;;+;K0;#I"[]=(member);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @Yb;[;I"@return [Object];T;0; @Yb;@F;Mi;N0;[[I" member;T0; @Ybo;H ;II" overload;F;J0;;+;K0;#I"[]=(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @Yb;[;I"@return [Object];T;0; @Yb;@F;Mi;N0;[[I" index;T0; @Yb;[;I"Attribute Assignment---Sets the value of the given struct +member+ or the member at the given +index+. Raises NameError if the +member+ does not exist and IndexError if the +index+ is out of range. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe["name"] = "Luke" joe[:zip] = "90210" joe.name #=> "Luke" joe.zip #=> "90210" @overload []=(member) @return [Object] @overload []=(index) @return [Object];T;0; @Yb;@F;Ao;B;CT;Di;Ei;!@ `;"I"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; ; F; ;,;;;I"Struct#select;F;[[@0;[[@`ia;T;;;0;[;{;IC;"}Yields each member value from the struct to the block and returns an Array containing the member values from the +struct+ for which the given block returns a true value (equivalent to Enumerable#select). Lots = Struct.new(:a, :b, :c, :d, :e, :f) l = Lots.new(11, 22, 33, 44, 55, 66) l.select {|v| v.even? } #=> [22, 44, 66] Struct#filter is an alias for Struct#select. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @bo;L ;II" return;F;JI";T;0;K[I" Array;T; @b;[;I"!@yield [obj] @return [Array];T;0; @b;@F;Mi;N0;[; @bo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[; @bo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @bo;L ;II" return;F;JI";T;0;K[I" Array;T; @b;[;I"!@yield [obj] @return [Array];T;0; @b;@F;Mi;N0;[; @bo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[; @b;[;I"Yields each member value from the struct to the block and returns an Array containing the member values from the +struct+ for which the given block returns a true value (equivalent to Enumerable#select). Lots = Struct.new(:a, :b, :c, :d, :e, :f) l = Lots.new(11, 22, 33, 44, 55, 66) l.select {|v| v.even? } #=> [22, 44, 66] Struct#filter is an alias for Struct#select. @overload select @yield [obj] @return [Array] @overload select @overload filter @yield [obj] @return [Array] @overload filter;T;0; @b;@F;Ao;B;CT;DiO;Eia;!@ `;"I"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; ; F; ;,;;;I"Struct#filter;F;[[@0;[[@`ia;T;;;0;[;{;IC;"}Yields each member value from the struct to the block and returns an Array containing the member values from the +struct+ for which the given block returns a true value (equivalent to Enumerable#select). Lots = Struct.new(:a, :b, :c, :d, :e, :f) l = Lots.new(11, 22, 33, 44, 55, 66) l.select {|v| v.even? } #=> [22, 44, 66] Struct#filter is an alias for Struct#select. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @bo;L ;II" return;F;JI";T;0;K[I" Array;T; @b;[;I"!@yield [obj] @return [Array];T;0; @b;@F;Mi;N0;[; @bo;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[; @bo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @bo;L ;II" return;F;JI";T;0;K[I" Array;T; @b;[;I"!@yield [obj] @return [Array];T;0; @b;@F;Mi;N0;[; @bo;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[; @b;[;@b;0; @b;@F;Ao;B;CT;DiO;Eia;!@ `;"I"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; ; F; ;,;;;I"Struct#values_at;F;[[@0;[[@`iI;T;;;0;[;{;IC;"DReturns the struct member values for each +selector+ as an Array. A +selector+ may be either an Integer offset or a Range of offsets (as in Array#values_at). Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.values_at(0, 2) #=> ["Joe Smith", 12345] ;T;[o;H ;II" overload;F;J0;;;K0;#I"values_at(selector, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @c;[;I"@return [Array];T;0; @c;@F;Mi;N0;[[I" selector;T0[I"...;T0; @c;[;I"|Returns the struct member values for each +selector+ as an Array. A +selector+ may be either an Integer offset or a Range of offsets (as in Array#values_at). Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.values_at(0, 2) #=> ["Joe Smith", 12345] @overload values_at(selector, ...) @return [Array];T;0; @c;@F;Ao;B;CT;Di;;EiF;!@ `;"I"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; ; F; ;,;;;I"Struct#members;F;[;[[@`i;T;: members;0;[;{;IC;"Returns the struct members as an array of symbols: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.members #=> [:name, :address, :zip] ;T;[o;H ;II" overload;F;J0;;r;K0;#I" members;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @.c;[;I"@return [Array];T;0; @.c;@F;Mi;N0;[; @.c;[;I"Returns the struct members as an array of symbols: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.members #=> [:name, :address, :zip] @overload members @return [Array];T;0; @.c;@F;Ao;B;CT;Di;Ei;!@ `;"I"istatic VALUE rb_struct_members_m(VALUE obj) { return rb_struct_s_members_m(rb_obj_class(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Struct#dig;F;[[@0;[[@`i;T;;;0;[;{;IC;"oExtracts the nested value specified by the sequence of +key+ objects by calling +dig+ at each step, returning +nil+ if any intermediate step is +nil+. Foo = Struct.new(:a) f = Foo.new(Foo.new({b: [1, 2, 3]})) f.dig(:a, :a, :b, 0) # => 1 f.dig(:b, 0) # => nil f.dig(:a, :a, :b, :c) # TypeError: no implicit conversion of Symbol into Integer ;T;[o;H ;II" overload;F;J0;;;K0;#I"dig(key, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @Ic;[;I"@return [Object];T;0; @Ic;@F;Mi;N0;[[I"key;T0[I"...;T0; @Ic;[;I"Extracts the nested value specified by the sequence of +key+ objects by calling +dig+ at each step, returning +nil+ if any intermediate step is +nil+. Foo = Struct.new(:a) f = Foo.new(Foo.new({b: [1, 2, 3]})) f.dig(:a, :a, :b, 0) # => 1 f.dig(:b, 0) # => nil f.dig(:a, :a, :b, :c) # TypeError: no implicit conversion of Symbol into Integer @overload dig(key, ...) @return [Object];T;0; @Ic;@F;Ao;B;CT;Di;Ei;!@ `;"I"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;9;[[@i ;F;:Tms;;;;;;[;{;IC;"$:Tms for backward compatibility ;T;[;[;I"$:Tms for backward compatibility;T;0; @ic;@F;Ao;B;CT;Di ;Ei ;!@ `;I"Struct::Tms;F; "Dave" dave.greeting #=> "Hello Dave!" See Struct::new for further examples of creating struct subclasses and instances. In the method descriptions that follow, a "member" parameter refers to a struct member which is either a quoted string ("name") or a Symbol (:name).;T;[;[;I" A Struct is a convenient way to bundle a number of attributes together, using accessor methods, without having to write an explicit class. The Struct class generates new subclasses that hold a set of members and their values. For each member a reader and writer method is created similar to Module#attr_accessor. Customer = Struct.new(:name, :address) do def greeting "Hello #{name}!" end end dave = Customer.new("Dave", "123 Main") dave.name #=> "Dave" dave.greeting #=> "Hello Dave!" See Struct::new for further examples of creating struct subclasses and instances. In the method descriptions that follow, a "member" parameter refers to a struct member which is either a quoted string ("name") or a Symbol (:name). ;T;0; @ `;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Struct;F;1@ 0 Integer.sqrt(1) #=> 1 Integer.sqrt(24) #=> 4 Integer.sqrt(25) #=> 5 Integer.sqrt(10**400) #=> 10**200 Equivalent to Math.sqrt(n).floor, except that the result of the latter code may differ from the true value due to the limited precision of floating point arithmetic. Integer.sqrt(10**46) #=> 100000000000000000000000 Math.sqrt(10**46).floor #=> 99999999999999991611392 (!) If +n+ is not an Integer, it is converted to an Integer first. If +n+ is negative, a Math::DomainError is raised. ;T;[o;H ;II" overload;F;J0;;~;K0;#I" sqrt(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Gd;[;I"@return [Integer];T;0; @Gd;@F;Mi;N0;[[I"n;T0; @Gd;[;I"Returns the integer square root of the non-negative integer +n+, i.e. the largest non-negative integer less than or equal to the square root of +n+. Integer.sqrt(0) #=> 0 Integer.sqrt(1) #=> 1 Integer.sqrt(24) #=> 4 Integer.sqrt(25) #=> 5 Integer.sqrt(10**400) #=> 10**200 Equivalent to Math.sqrt(n).floor, except that the result of the latter code may differ from the true value due to the limited precision of floating point arithmetic. Integer.sqrt(10**46) #=> 100000000000000000000000 Math.sqrt(10**46).floor #=> 99999999999999991611392 (!) If +n+ is not an Integer, it is converted to an Integer first. If +n+ is negative, a Math::DomainError is raised. @overload sqrt(n) @return [Integer];T;0; @Gd;@F;Ao;B;CT;Di;Ei;!@Ed;"I"qstatic VALUE rb_int_s_isqrt(VALUE self, VALUE num) { unsigned long n, sq; num = rb_to_int(num); if (FIXNUM_P(num)) { if (FIXNUM_NEGATIVE_P(num)) { domain_error("isqrt"); } n = FIX2ULONG(num); sq = rb_ulong_isqrt(n); return LONG2FIX(sq); } else { size_t biglen; if (RBIGNUM_NEGATIVE_P(num)) { domain_error("isqrt"); } biglen = BIGNUM_LEN(num); if (biglen == 0) return INT2FIX(0); #if SIZEOF_BDIGIT <= SIZEOF_LONG /* short-circuit */ if (biglen == 1) { n = BIGNUM_DIGITS(num)[0]; sq = rb_ulong_isqrt(n); return ULONG2NUM(sq); } #endif return rb_big_isqrt(num); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#to_s;F;[[@0;[[@)i ;T;;h;0;[;{;IC;"\Returns a string containing the place-value representation of +int+ with radix +base+ (between 2 and 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" ;T;[o;H ;II" overload;F;J0;;h;K0;#I"to_s(base=10);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @fd;[;I"@return [String];T;0; @fd;@F;Mi;N0;[[I" base;TI"10;T; @fd;[;I"Returns a string containing the place-value representation of +int+ with radix +base+ (between 2 and 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" @overload to_s(base=10) @return [String];T;0; o; ; F; ;,;;;I"Integer#inspect;F;[;[[@)i;F;;i;;0;[;{;@nd;!@Ed;"I"static VALUE 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"static VALUE;T;@F;Ao;B;CT;Di ;Ei ;!@Ed;"I"static VALUE 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;#@d;$T@do; ; F; ;,;;;I"Integer#integer?;F;[;[[@)i~ ;T;: integer?;0;[;{;IC;"CSince +int+ is already an Integer, this always returns +true+.;T;[o;H ;II" overload;F;J0;;;K0;#I" integer?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @d;[;I"@return [true];T;0; @d;@F;Mi;N0;[; @d;[;I"iSince +int+ is already an Integer, this always returns +true+. @overload integer? @return [true];T;0; @d;@F;Ao;B;CT;Diw ;Ei{ ;Mi;!@Ed;"I"+int+ & +mask+ are 1.;T;[o;H ;II" overload;F;J0;;;K0;#I"allbits?(mask);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @d;[;I"@return [Boolean];T;0; @d;@F;Mi;N0;[[I" mask;T0; @d;[;I"tReturns +true+ if all bits of +int+ & +mask+ are 1. @overload allbits?(mask) @return [Boolean];T;0; @d;@F;Ao;B;CT;Di ;Ei ;Mi;!@Ed;"I"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; ; F; ;,;;;I"Integer#anybits?;F;[[I" mask;T0;[[@)i ;T;: anybits?;0;[;{;IC;"EReturns +true+ if any bits of +int+ & +mask+ are 1.;T;[o;H ;II" overload;F;J0;;;K0;#I"anybits?(mask);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @d;[;I"@return [Boolean];T;0; @d;@F;Mi;N0;[[I" mask;T0; @d;[;I"tReturns +true+ if any bits of +int+ & +mask+ are 1. @overload anybits?(mask) @return [Boolean];T;0; @d;@F;Ao;B;CT;Di ;Ei ;Mi;!@Ed;"I"static VALUE int_anybits_p(VALUE num, VALUE mask) { mask = rb_to_int(mask); return num_zero_p(rb_int_and(num, mask)) ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#nobits?;F;[[I" mask;T0;[[@)i ;T;: nobits?;0;[;{;IC;"DReturns +true+ if no bits of +int+ & +mask+ are 1.;T;[o;H ;II" overload;F;J0;;;K0;#I"nobits?(mask);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @e;[;I"@return [Boolean];T;0; @e;@F;Mi;N0;[[I" mask;T0; @e;[;I"rReturns +true+ if no bits of +int+ & +mask+ are 1. @overload nobits?(mask) @return [Boolean];T;0; @e;@F;Ao;B;CT;Di ;Ei ;Mi;!@Ed;"I"~static VALUE int_nobits_p(VALUE num, VALUE mask) { mask = rb_to_int(mask); return num_zero_p(rb_int_and(num, mask)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#upto;F;[[I"to;T0;[[@)ix;T;;0;0;[;{;IC;"Iterates the given block, passing in integer values from +int+ up to and including +limit+. If no block is given, an Enumerator is returned instead. 5.upto(10) {|i| print i, " " } #=> 5 6 7 8 9 10 ;T;[o;H ;II" overload;F;J0;;0;K0;#I"upto(limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @;eo;L ;II" return;F;JI";T;0;K[I" self;T; @;e;[;I"@yield [i] @return [self];T;0; @;e;@F;Mi;N0;[[I" limit;T0; @;eo;H ;II" overload;F;J0;;0;K0;#I"upto(limit);T;IC;";T;[;[;I";T;0; @;e;@F;Mi;N0;[[I" limit;T0; @;e;[;I"Iterates the given block, passing in integer values from +int+ up to and including +limit+. If no block is given, an Enumerator is returned instead. 5.upto(10) {|i| print i, " " } #=> 5 6 7 8 9 10 @overload upto(limit) @yield [i] @return [self] @overload upto(limit);T;0; @;e;@F;Ao;B;CT;Did;Eio;!@Ed;"I"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)); } if (NIL_P(c)) rb_cmperr(i, to); } return from; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#downto;F;[[I"to;T0;[[@)i;T;: downto;0;[;{;IC;"Iterates the given block, passing in decreasing values from +int+ down to and including +limit+. If no block is given, an Enumerator is returned instead. 5.downto(1) { |n| print n, ".. " } puts "Liftoff!" #=> "5.. 4.. 3.. 2.. 1.. Liftoff!" ;T;[o;H ;II" overload;F;J0;;;K0;#I"downto(limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @ieo;L ;II" return;F;JI";T;0;K[I" self;T; @ie;[;I"@yield [i] @return [self];T;0; @ie;@F;Mi;N0;[[I" limit;T0; @ieo;H ;II" overload;F;J0;;;K0;#I"downto(limit);T;IC;";T;[;[;I";T;0; @ie;@F;Mi;N0;[[I" limit;T0; @ie;[;I"JIterates the given block, passing in decreasing values from +int+ down to and including +limit+. If no block is given, an Enumerator is returned instead. 5.downto(1) { |n| print n, ".. " } puts "Liftoff!" #=> "5.. 4.. 3.. 2.. 1.. Liftoff!" @overload downto(limit) @yield [i] @return [self] @overload downto(limit);T;0; @ie;@F;Ao;B;CT;Di;Ei;!@Ed;"I"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; ; F; ;,;;;I"Integer#times;F;[;[[@)i;T;: times;0;[;{;IC;"Iterates the given block +int+ times, passing in values from zero to int - 1. If no block is given, an Enumerator is returned instead. 5.times {|i| print i, " " } #=> 0 1 2 3 4 ;T;[o;H ;II" overload;F;J0;;;K0;#I" times;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @eo;L ;II" return;F;JI";T;0;K[I" self;T; @e;[;I"@yield [i] @return [self];T;0; @e;@F;Mi;N0;[; @eo;H ;II" overload;F;J0;;;K0;#I" times;T;IC;";T;[;[;I";T;0; @e;@F;Mi;N0;[; @e;[;I"Iterates the given block +int+ times, passing in values from zero to int - 1. If no block is given, an Enumerator is returned instead. 5.times {|i| print i, " " } #=> 0 1 2 3 4 @overload times @yield [i] @return [self] @overload times;T;0; @e;@F;Ao;B;CT;Di;Ei;!@Ed;"I"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; iint+1. 1.next #=> 2 (-1).next #=> 0 1.succ #=> 2 (-1).succ #=> 0 ;T;[o;H ;II" overload;F;J0;;;K0;#I" next;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @e;[;I"@return [Integer];T;0; @e;@F;Mi;N0;[; @eo;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @e;[;I"@return [Integer];T;0; @e;@F;Mi;N0;[; @e;[;I"Returns the successor of +int+, i.e. the Integer equal to int+1. 1.next #=> 2 (-1).next #=> 0 1.succ #=> 2 (-1).succ #=> 0 @overload next @return [Integer] @overload succ @return [Integer];T;0; @e;@F;Ao;B;CT;Di ;Ei ;!@Ed;$To; ; F; ;,;;;I"Integer#next;F;[;[;F;;;;0;[;{;IC;"Returns the successor of +int+, i.e. the Integer equal to int+1. 1.next #=> 2 (-1).next #=> 0 1.succ #=> 2 (-1).succ #=> 0 ;T;[o;H ;II" overload;F;J0;;;K0;#I" next;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @e;[;I"@return [Integer];T;0; @e;@F;Mi;N0;[; @eo;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @e;[;I"@return [Integer];T;0; @e;@F;Mi;N0;[; @e;[;@e;0; @e;@F;Ao;B;CT;Di ;Ei ;!@Ed;$To; ; F; ;,;;;I"Integer#pred;F;[;[;F;: pred;;0;[;{;IC;" ;T;[;[;@;0; @f;!@Ed;$To; ; F; ;,;;;I"Integer#chr;F;[[@0;[[@)i: ;T;;4;0;[;{;IC;"Returns a string containing the character represented by the +int+'s value according to +encoding+. 65.chr #=> "A" 230.chr #=> "\xE6" 255.chr(Encoding::UTF_8) #=> "\u00FF" ;T;[o;H ;II" overload;F;J0;;4;K0;#I"chr([encoding]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @f;[;I"@return [String];T;0; @f;@F;Mi;N0;[[I"[encoding];T0; @f;[;I"Returns a string containing the character represented by the +int+'s value according to +encoding+. 65.chr #=> "A" 230.chr #=> "\xE6" 255.chr(Encoding::UTF_8) #=> "\u00FF" @overload chr([encoding]) @return [String];T;0; @f;@F;Ao;B;CT;Di ;Ei ;!@Ed;"I"Rstatic 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, "%d 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_check_arity(argc, 0, 1); break; } 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; ; F; ;,;;;I"Integer#ord;F;[;[[@)it ;T;;T;0;[;{;IC;"Returns the +int+ itself. 97.ord #=> 97 This method is intended for compatibility to character literals in Ruby 1.9. For example, ?a.ord returns 97 both in 1.8 and 1.9. ;T;[o;H ;II" overload;F;J0;;T;K0;#I"ord;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @/f;[;I"@return [self];T;0; @/f;@F;Mi;N0;[; @/f;[;I"Returns the +int+ itself. 97.ord #=> 97 This method is intended for compatibility to character literals in Ruby 1.9. For example, ?a.ord returns 97 both in 1.8 and 1.9. @overload ord @return [self];T;0; @/f;@F;Ao;B;CT;Dif ;Eiq ;!@Ed;"I"8static VALUE int_ord(VALUE num) { return num; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#to_i;F;[;[[@)iq ;T;;=;0;[;{;IC;"WSince +int+ is already an Integer, returns +self+. #to_int is an alias for #to_i. ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Jf;[;I"@return [Integer];T;0; @Jf;@F;Mi;N0;[; @Jfo;H ;II" overload;F;J0;: to_int;K0;#I" to_int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Jf;[;I"@return [Integer];T;0; @Jf;@F;Mi;N0;[; @Jf;[;I"Since +int+ is already an Integer, returns +self+. #to_int is an alias for #to_i. @overload to_i @return [Integer] @overload to_int @return [Integer];T;0; @Jf;@F;Ao;B;CT;Dig ;Eio ;!@Ed;"I"9static VALUE int_to_i(VALUE num) { return num; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#to_int;F;[;[[@)iq ;T;;;0;[;{;IC;"WSince +int+ is already an Integer, returns +self+. #to_int is an alias for #to_i. ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @rf;[;I"@return [Integer];T;0; @rf;@F;Mi;N0;[; @rfo;H ;II" overload;F;J0;;;K0;#I" to_int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @rf;[;I"@return [Integer];T;0; @rf;@F;Mi;N0;[; @rf;[;@nf;0; @rf;@F;Ao;B;CT;Dig ;Eio ;!@Ed;"I"9static VALUE int_to_i(VALUE num) { return num; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#to_f;F;[;[[@)i[;T;;>;0;[;{;IC;"YConverts +int+ to a Float. If +int+ doesn't fit in a Float, the result is infinity. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" to_f;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @f;[;I"@return [Float];T;0; @f;@F;Mi;N0;[; @f;[;I"|Converts +int+ to a Float. If +int+ doesn't fit in a Float, the result is infinity. @overload to_f @return [Float];T;0; @f;@F;Ao;B;CT;DiR;EiW;!@Ed;"I"8static VALUE int_to_f(VALUE num) { double val; if (FIXNUM_P(num)) { val = (double)FIX2LONG(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { 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; ; F; ;,;;;I"Integer#floor;F;[[@0;[[@)i4;T;: floor;0;[;{;IC;"Returns the largest number less than or equal to +int+ 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 +self+ when +ndigits+ is zero or positive. 1.floor #=> 1 1.floor(2) #=> 1 18.floor(-1) #=> 10 (-18).floor(-1) #=> -20 ;T;[o;H ;II" overload;F;J0;;;K0;#I"floor([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @f;[;I"@return [Integer, Float];T;0; @f;@F;Mi;N0;[[I"[ndigits];T0; @f;[;I"Returns the largest number less than or equal to +int+ 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 +self+ when +ndigits+ is zero or positive. 1.floor #=> 1 1.floor(2) #=> 1 18.floor(-1) #=> 10 (-18).floor(-1) #=> -20 @overload floor([ndigits]) @return [Integer, Float];T;0; @f;@F;Ao;B;CT;Di!;Ei0;!@Ed;"I"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; ; F; ;,;;;I"Integer#ceil;F;[[@0;[[@)iT;T;: ceil;0;[;{;IC;"Returns the smallest number greater than or equal to +int+ 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 +self+ when +ndigits+ is zero or positive. 1.ceil #=> 1 1.ceil(2) #=> 1 18.ceil(-1) #=> 20 (-18).ceil(-1) #=> -10 ;T;[o;H ;II" overload;F;J0;;;K0;#I"ceil([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @f;[;I"@return [Integer, Float];T;0; @f;@F;Mi;N0;[[I"[ndigits];T0; @f;[;I"Returns the smallest number greater than or equal to +int+ 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 +self+ when +ndigits+ is zero or positive. 1.ceil #=> 1 1.ceil(2) #=> 1 18.ceil(-1) #=> 20 (-18).ceil(-1) #=> -10 @overload ceil([ndigits]) @return [Integer, Float];T;0; @f;@F;Ao;B;CT;DiA;EiP;!@Ed;"I"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; ; F; ;,;;;I"Integer#truncate;F;[[@0;[[@)it;T;: truncate;0;[;{;IC;"Returns +int+ 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 +self+ when +ndigits+ is zero or positive. 1.truncate #=> 1 1.truncate(2) #=> 1 18.truncate(-1) #=> 10 (-18).truncate(-1) #=> -10 ;T;[o;H ;II" overload;F;J0;;;K0;#I"truncate([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @f;[;I"@return [Integer, Float];T;0; @f;@F;Mi;N0;[[I"[ndigits];T0; @f;[;I"Returns +int+ 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 +self+ when +ndigits+ is zero or positive. 1.truncate #=> 1 1.truncate(2) #=> 1 18.truncate(-1) #=> 10 (-18).truncate(-1) #=> -10 @overload truncate([ndigits]) @return [Integer, Float];T;0; @f;@F;Ao;B;CT;Dia;Eip;!@Ed;"I"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; ; F; ;,;;;I"Integer#round;F;[[@0;[[@)i;T;;E;0;[;{;IC;"0Returns +int+ 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 +self+ when +ndigits+ is zero or positive. 1.round #=> 1 1.round(2) #=> 1 15.round(-1) #=> 20 (-15).round(-1) #=> -20 The optional +half+ keyword argument is available similar to Float#round. 25.round(-1, half: :up) #=> 30 25.round(-1, half: :down) #=> 20 25.round(-1, half: :even) #=> 20 35.round(-1, half: :up) #=> 40 35.round(-1, half: :down) #=> 30 35.round(-1, half: :even) #=> 40 (-25).round(-1, half: :up) #=> -30 (-25).round(-1, half: :down) #=> -20 (-25).round(-1, half: :even) #=> -20 ;T;[o;H ;II" overload;F;J0;;E;K0;#I"$round([ndigits] [, half: mode]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @g;[;I"@return [Integer, Float];T;0; @g;@F;Mi;N0;[[I"[ndigits][, half:;TI" mode];T; @g;[;I"wReturns +int+ 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 +self+ when +ndigits+ is zero or positive. 1.round #=> 1 1.round(2) #=> 1 15.round(-1) #=> 20 (-15).round(-1) #=> -20 The optional +half+ keyword argument is available similar to Float#round. 25.round(-1, half: :up) #=> 30 25.round(-1, half: :down) #=> 20 25.round(-1, half: :even) #=> 20 35.round(-1, half: :up) #=> 40 35.round(-1, half: :down) #=> 30 35.round(-1, half: :even) #=> 40 (-25).round(-1, half: :up) #=> -30 (-25).round(-1, half: :down) #=> -20 (-25).round(-1, half: :even) #=> -20 @overload round([ndigits] [, half: mode]) @return [Integer, Float];T;0; @g;@F;Ao;B;CT;Di;Ei ;!@Ed;"I"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; ; F; ;,;;;I"Integer#<=>;F;[[I"y;T0;[[@)ik;T;;V;0;[;{;IC;"Comparison---Returns -1, 0, or +1 depending on whether +int+ is less than, equal to, or greater than +numeric+. This is the basis for the tests in the Comparable module. +nil+ is returned if the two values are incomparable. ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @1g;[;I" @return [ -1, 0, +1, nil];T;0; @1g;@F;Mi;N0;[[I" numeric;T0; @1g;[;I"Comparison---Returns -1, 0, or +1 depending on whether +int+ is less than, equal to, or greater than +numeric+. This is the basis for the tests in the Comparable module. +nil+ is returned if the two values are incomparable. @overload <=>(numeric) @return [ -1, 0, +1, nil];T;0; @1g;@F;Ao;B;CT;DiE;EiN;!@Ed;"I"VALUE rb_int_cmp(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_cmp(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { 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; ; F; ;,;;;I"Integer#-@;F;[;[[@)i ;T;;;;0;[;{;IC;"Returns +int+, negated. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" -int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Sg;[;I"@return [Integer];T;0; @Sg;@F;Mi;N0;[; @Sg;[;I"AReturns +int+, negated. @overload -int @return [Integer];T;0; @Sg;@F;Ao;B;CT;Di ;Ei ;!@Ed;"I"VALUE rb_int_uminus(VALUE num) { if (FIXNUM_P(num)) { return fix_uminus(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { return rb_big_uminus(num); } return num_funcall0(num, idUMinus); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#+;F;[[I"y;T0;[[@)i;T;;(;0;[;{;IC;"\Performs addition: the class of the resulting object depends on the class of +numeric+. ;T;[o;H ;II" overload;F;J0;;(;K0;#I"+(numeric);T;IC;";T;[;[;I";T;0; @ng;@F;Mi;N0;[[I" numeric;T0; @ng;[;I"sPerforms addition: the class of the resulting object depends on the class of +numeric+. @overload +(numeric);T;0; @ng;@F;Ao;B;CT;Di ;Ei ;!@Ed;"I"VALUE rb_int_plus(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_plus(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_plus(x, y); } return rb_num_coerce_bin(x, y, '+'); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#-;F;[[I"y;T0;[[@)i7;T;;<;0;[;{;IC;"_Performs subtraction: the class of the resulting object depends on the class of +numeric+. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"-(numeric);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I" numeric;T0; @g;[;I"vPerforms subtraction: the class of the resulting object depends on the class of +numeric+. @overload -(numeric);T;0; @g;@F;Ao;B;CT;Di;Ei ;!@Ed;"I"VALUE rb_int_minus(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_minus(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_minus(x, y); } return rb_num_coerce_bin(x, y, '-'); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#*;F;[[I"y;T0;[[@)ii;T;;);0;[;{;IC;"bPerforms multiplication: the class of the resulting object depends on the class of +numeric+. ;T;[o;H ;II" overload;F;J0;;);K0;#I"*(numeric);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I" numeric;T0; @g;[;I"yPerforms multiplication: the class of the resulting object depends on the class of +numeric+. @overload *(numeric);T;0; @g;@F;Ao;B;CT;DiH;EiL;!@Ed;"I"VALUE rb_int_mul(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_mul(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_mul(x, y); } return rb_num_coerce_bin(x, y, '*'); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#/;F;[[I"y;T0;[[@)i;T;:/;0;[;{;IC;"\Performs division: the class of the resulting object depends on the class of +numeric+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"/(numeric);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I" numeric;T0; @g;[;I"sPerforms division: the class of the resulting object depends on the class of +numeric+. @overload /(numeric);T;0; @g;@F;Ao;B;CT;Di;Ei;!@Ed;"I"VALUE rb_int_div(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_div(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_div(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#div;F;[[I"y;T0;[[@)i;T;:div;0;[;{;IC;"ZPerforms integer division: returns the integer result of dividing +int+ by +numeric+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"div(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @g;[;I"@return [Integer];T;0; @g;@F;Mi;N0;[[I" numeric;T0; @g;[;I"Performs integer division: returns the integer result of dividing +int+ by +numeric+. @overload div(numeric) @return [Integer];T;0; @g;@F;Ao;B;CT;Di;Ei;!@Ed;"I"VALUE rb_int_idiv(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_idiv(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_idiv(x, y); } return num_div(x, y); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#%;F;[[I"y;T0;[[@)i$;T;;*;0;[;{;IC;"LReturns +int+ modulo +other+. See Numeric#divmod for more information. ;T;[o;H ;II" overload;F;J0;;*;K0;#I" %(other);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I" other;T0; @go;H ;II" overload;F;J0;: modulo;K0;#I"modulo(other);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I" other;T0; @g;[;I"yReturns +int+ modulo +other+. See Numeric#divmod for more information. @overload %(other) @overload modulo(other);T;0; @g;@F;Ao;B;CT;Di;Ei ;!@Ed;"I"VALUE rb_int_modulo(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_mod(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_modulo(x, y); } return num_modulo(x, y); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#modulo;F;[[I"y;T0;[[@)i$;T;;;0;[;{;IC;"LReturns +int+ modulo +other+. See Numeric#divmod for more information. ;T;[o;H ;II" overload;F;J0;;*;K0;#I" %(other);T;IC;";T;[;[;I";T;0; @h;@F;Mi;N0;[[I" other;T0; @ho;H ;II" overload;F;J0;;;K0;#I"modulo(other);T;IC;";T;[;[;I";T;0; @h;@F;Mi;N0;[[I" other;T0; @h;[;@h;0; @h;@F;Ao;B;CT;Di;Ei ;!@Ed;"I"VALUE rb_int_modulo(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_mod(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_modulo(x, y); } return num_modulo(x, y); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#remainder;F;[[I"y;T0;[[@)iA;T;:remainder;0;[;{;IC;""Returns the remainder after dividing +int+ by +numeric+. x.remainder(y) means x-y*(x/y).truncate. 5.remainder(3) #=> 2 -5.remainder(3) #=> -2 5.remainder(-3) #=> 2 -5.remainder(-3) #=> -2 5.remainder(1.5) #=> 0.5 See Numeric#divmod. ;T;[o;H ;II" overload;F;J0;;;K0;#I"remainder(numeric);T;IC;";T;[;[;I";T;0; @x.remainder(y) means x-y*(x/y).truncate. 5.remainder(3) #=> 2 -5.remainder(3) #=> -2 5.remainder(-3) #=> 2 -5.remainder(-3) #=> -2 5.remainder(1.5) #=> 0.5 See Numeric#divmod. @overload remainder(numeric);T;0; @ 47.652829364212366 654321.fdiv(13731.24) #=> 47.65199646936475 -654321.fdiv(13731) #=> -47.652829364212366 ;T;[o;H ;II" overload;F;J0;;;K0;#I"fdiv(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @uh;[;I"@return [Float];T;0; @uh;@F;Mi;N0;[[I" numeric;T0; @uh;[;I"Returns the floating point result of dividing +int+ by +numeric+. 654321.fdiv(13731) #=> 47.652829364212366 654321.fdiv(13731.24) #=> 47.65199646936475 -654321.fdiv(13731) #=> -47.652829364212366 @overload fdiv(numeric) @return [Float];T;0; @uh;@F;Ao;B;CT;Di;Ei;!@Ed;"I"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; ; F; ;,;;;I"Integer#**;F;[[I"y;T0;[[@)i;T;:**;0;[;{;IC;"Raises +int+ to the power of +numeric+, which may be negative or fractional. The result may be an Integer, a Float, a Rational, or a complex number. 2 ** 3 #=> 8 2 ** -1 #=> (1/2) 2 ** 0.5 #=> 1.4142135623730951 (-1) ** 0.5 #=> (0.0+1.0i) 123456789 ** 2 #=> 15241578750190521 123456789 ** 1.2 #=> 5126464716.0993185 123456789 ** -2 #=> (1/15241578750190521) ;T;[o;H ;II" overload;F;J0;;;K0;#I"**(numeric);T;IC;";T;[;[;I";T;0; @h;@F;Mi;N0;[[I" numeric;T0; @h;[;I"Raises +int+ to the power of +numeric+, which may be negative or fractional. The result may be an Integer, a Float, a Rational, or a complex number. 2 ** 3 #=> 8 2 ** -1 #=> (1/2) 2 ** 0.5 #=> 1.4142135623730951 (-1) ** 0.5 #=> (0.0+1.0i) 123456789 ** 2 #=> 15241578750190521 123456789 ** 1.2 #=> 5126464716.0993185 123456789 ** -2 #=> (1/15241578750190521) @overload **(numeric);T;0; @h;@F;Ao;B;CT;Di};Ei;!@Ed;"I"VALUE rb_int_pow(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_pow(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_pow(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#pow;F;[[I"*;T0[I" const;T0;[[@oi;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;H ;II" overload;F;J0;;;K0;#I"pow(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @h;[;I"@return [Numeric];T;0; @h;@F;Mi;N0;[[I" numeric;T0; @ho;H ;II" overload;F;J0;;;K0;#I"pow(integer, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @h;[;I"@return [Integer];T;0; @h;@F;Mi;N0;[[I" integer;T0[I" integer;T0; @h;[;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; @h;@F;Ao;B;CT;Di;Ei;!@Ed;"I"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 <= 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(); return int_pow_tmp3(rb_int_modulo(a, m), b, m, nega_flg); } } UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To;9;[[I"ext/-test-/bignum/mul.c;Ti>;F;:SIZEOF_BDIGIT;;;;;;[;{;IC;" ;T;[;[;@;0; @h;!@Ed;I"Integer::SIZEOF_BDIGIT;F; [42, 4611686018427387904] ;T;[o;H ;II" overload;F;J0;;;K0;#I"coerce(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @Vj;[;I"@return [Array];T;0; @Vj;@F;Mi;N0;[[I" numeric;T0; @Vj;[;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; @Vj;@F;Ao;B;CT;Di?;EiJ;!@Ed;"I"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;9;[[@oi;F;:GMP_VERSION;;;;;;[;{;IC;"The version of loaded GMP. ;T;[;[;I"The version of loaded GMP.;T;0; @uj;@F;Ao;B;CT;Di;Ei;!@Ed;I"Integer::GMP_VERSION;F; 12 2.gcd(2) #=> 2 3.gcd(-7) #=> 1 ((1<<31)-1).gcd((1<<61)-1) #=> 1 ;T;[o;H ;II" overload;F;J0;;;K0;#I"gcd(other_int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @j;[;I"@return [Integer];T;0; @j;@F;Mi;N0;[[I"other_int;T0; @j;[;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; @j;@F;Ao;B;CT;DiO;EiY;!@Ed;"I"qVALUE rb_gcd(VALUE self, VALUE other) { other = nurat_int_value(other); return f_gcd(self, other); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#lcm;F;[[I" other;T0;[[@ in;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;H ;II" overload;F;J0;;;K0;#I"lcm(other_int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @j;[;I"@return [Integer];T;0; @j;@F;Mi;N0;[[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;Ao;B;CT;Dib;Eil;!@Ed;"I"qVALUE rb_lcm(VALUE self, VALUE other) { other = nurat_int_value(other); return f_lcm(self, other); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#gcdlcm;F;[[I" other;T0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"gcdlcm(other_int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @j;[;I"@return [Array];T;0; @j;@F;Mi;N0;[[I"other_int;T0; @j;[;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; @j;@F;Ao;B;CT;Diu;Ei;!@Ed;"I"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; ; F; ;,;;;I"Integer#numerator;F;[;[[@ i;T;:numerator;0;[;{;IC;"Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I"numerator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @j;[;I"@return [self];T;0; @j;@F;Mi;N0;[; @j;[;I"9Returns self. @overload numerator @return [self];T;0; @j;@F;Ao;B;CT;Di;Ei;!@Ed;"I"Dstatic VALUE integer_numerator(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#denominator;F;[;[[@ i;T;:denominator;0;[;{;IC;"Returns 1. ;T;[o;H ;II" overload;F;J0;;;K0;#I"denominator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"1;T; @j;[;I"@return [ 1];T;0; @j;@F;Mi;N0;[; @j;[;I"6Returns 1. @overload denominator @return [ 1];T;0; @j;@F;Ao;B;CT;Di;Ei;!@Ed;"I"Lstatic VALUE integer_denominator(VALUE self) { return INT2FIX(1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#to_r;F;[;[[@ iZ;T;;;0;[;{;IC;"oReturns the value as a rational. 1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1) ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_r;T;IC;";T;[;[;I";T;0; @k;@F;Mi;N0;[; @k;[;I"{Returns the value as a rational. 1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1) @overload to_r;T;0; @k;@F;Ao;B;CT;DiQ;EiW;!@Ed;"I"Qstatic VALUE integer_to_r(VALUE self) { return rb_rational_new1(self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#rationalize;F;[[@0;[[@ ig;T;:rationalize;0;[;{;IC;"UReturns the value as a rational. The optional argument +eps+ is always ignored. ;T;[o;H ;II" overload;F;J0;;;K0;#I"rationalize([eps]);T;IC;";T;[;[;I";T;0; @*k;@F;Mi;N0;[[I" [eps];T0; @*k;[;I"tReturns the value as a rational. The optional argument +eps+ is always ignored. @overload rationalize([eps]);T;0; @*k;@F;Ao;B;CT;Di`;Eid;!@Ed;"I"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;$To; ; F; ;,;;;I"Integer#gcd_normal;F;[[I"y;T0;[[I"ext/-test-/rational/rat.c;Ti;T;:gcd_normal;0;[;{;IC;" ;T;[;[;@;0; @Ck;!@Ed;"I"ustatic VALUE gcd_normal(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; ; F; ;,;;;I"Integer#gcd_gmp;F;[[I"y;T0;[[@Jki;T;: gcd_gmp;0;[;{;IC;" ;T;[;[;@;0; @Rk;!@Ed;"I"cstatic VALUE gcd_gmp(VALUE x, VALUE y) { return rb_big_norm(rb_gcd_gmp(big(x), big(y))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#bignum?;F;[;[[I""ext/-test-/integer/core_ext.c;Ti;T;: bignum?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @`k;[;@;0; @`k;Mi;!@Ed;"I"estatic VALUE int_bignum_p(VALUE self) { return RB_TYPE_P(self, T_BIGNUM) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#fixnum?;F;[;[[@eki;T;: fixnum?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @pk;[;@;0; @pk;Mi;!@Ed;"I"Zstatic VALUE int_fixnum_p(VALUE self) { return FIXNUM_P(self) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#to_bignum;F;[;[[@eki;T;:to_bignum;0;[;{;IC;" ;T;[;[;@;0; @k;!@Ed;"I"wstatic VALUE rb_int_to_bignum(VALUE x) { if (FIXNUM_P(x)) x = rb_int2big(FIX2LONG(x)); return x; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#positive_pow;F;[[I"y;T0;[[@eki;T;:positive_pow;0;[;{;IC;" ;T;[;[;@;0; @k;!@Ed;"I"ostatic VALUE positive_pow(VALUE x, VALUE y) { return rb_int_positive_pow(NUM2LONG(x), NUM2ULONG(y)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#abs;F;[;[[@)i;T;:abs;0;[;{;IC;" ;T;[;[;@;0; @k;!@Ed;"I"VALUE rb_int_abs(VALUE num) { if (FIXNUM_P(num)) { return fix_abs(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { return rb_big_abs(num); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#magnitude;F;[;[[@)i;T;:magnitude;0;[;{;IC;"Returns the absolute value of +int+. (-12345).abs #=> 12345 -12345.abs #=> 12345 12345.abs #=> 12345 Integer#magnitude is an alias for Integer#abs. ;T;[o;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @k;[;I"@return [Integer];T;0; @k;@F;Mi;N0;[; @ko;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @k;[;I"@return [Integer];T;0; @k;@F;Mi;N0;[; @k;[;I"Returns the absolute value of +int+. (-12345).abs #=> 12345 -12345.abs #=> 12345 12345.abs #=> 12345 Integer#magnitude is an alias for Integer#abs. @overload abs @return [Integer] @overload magnitude @return [Integer];T;0; @k;@F;Ao;B;CT;Dim;Eiy;!@Ed;"I"VALUE rb_int_abs(VALUE num) { if (FIXNUM_P(num)) { return fix_abs(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { return rb_big_abs(num); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#===;F;[[I"y;T0;[[@)i9;T;;O;0;[;{;IC;"Returns +true+ if +int+ equals +other+ numerically. Contrast this with Integer#eql?, which requires +other+ to be an Integer. 1 == 2 #=> false 1 == 1.0 #=> true ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @k;[;I"@return [Boolean];T;0; @k;@F;Mi;N0;[[I" other;T0; @k;[;I"Returns +true+ if +int+ equals +other+ numerically. Contrast this with Integer#eql?, which requires +other+ to be an Integer. 1 == 2 #=> false 1 == 1.0 #=> true @overload ==(other) @return [Boolean];T;0; @k;@F;Ao;B;CT;Di;Ei$;!@Ed;"I"VALUE rb_int_equal(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_equal(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_eq(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#==;F;[[I"y;T0;[[@)i9;T;;S;0;[;{;IC;"Returns +true+ if +int+ equals +other+ numerically. Contrast this with Integer#eql?, which requires +other+ to be an Integer. 1 == 2 #=> false 1 == 1.0 #=> true ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @k;[;I"@return [Boolean];T;0; @k;@F;Mi;N0;[[I" other;T0; @k;[;@k;0; @k;@F;Ao;B;CT;Di;Ei$;!@Ed;"I"VALUE rb_int_equal(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_equal(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_eq(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#>;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"IReturns +true+ if the value of +int+ is greater than that of +real+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" >(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ l;[;I"@return [Boolean];T;0; @ l;@F;Mi;N0;[[I" real;T0; @ l;[;I"qReturns +true+ if the value of +int+ is greater than that of +real+. @overload >(real) @return [Boolean];T;0; @ l;@F;Ao;B;CT;Diy;Ei};!@Ed;"I"VALUE rb_int_gt(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_gt(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_gt(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#>=;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"UReturns +true+ if the value of +int+ is greater than or equal to that of +real+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" >=(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @)l;[;I"@return [Boolean];T;0; @)l;@F;Mi;N0;[[I" real;T0; @)l;[;I"~Returns +true+ if the value of +int+ is greater than or equal to that of +real+. @overload >=(real) @return [Boolean];T;0; @)l;@F;Ao;B;CT;Di;Ei;!@Ed;"I"VALUE rb_int_ge(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_ge(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_ge(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#<;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"FReturns +true+ if the value of +int+ is less than that of +real+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" <(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Hl;[;I"@return [Boolean];T;0; @Hl;@F;Mi;N0;[[I" real;T0; @Hl;[;I"nReturns +true+ if the value of +int+ is less than that of +real+. @overload <(real) @return [Boolean];T;0; @Hl;@F;Ao;B;CT;Di;Ei;!@Ed;"I"static VALUE int_lt(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_lt(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_lt(x, y); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#<=;F;[[I"y;T0;[[@)i ;T;;;0;[;{;IC;"RReturns +true+ if the value of +int+ is less than or equal to that of +real+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" <=(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @gl;[;I"@return [Boolean];T;0; @gl;@F;Mi;N0;[[I" real;T0; @gl;[;I"{Returns +true+ if the value of +int+ is less than or equal to that of +real+. @overload <=(real) @return [Boolean];T;0; @gl;@F;Ao;B;CT;Di;Ei;!@Ed;"I"static VALUE int_le(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_le(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_le(x, y); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#~;F;[;[[@)i*;T;; ;0;[;{;IC;"cOne's complement: returns a number where each bit is flipped. Inverts the bits in an Integer. As integers are conceptually of infinite length, the result acts as if it had an infinite number of one bits to the left. In hex representations, this is displayed as two periods to the left of the digits. sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA" ;T;[o;H ;II" overload;F;J0;; ;K0;#I" ~int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @l;[;I"@return [Integer];T;0; @l;@F;Mi;N0;[; @l;[;I"One's complement: returns a number where each bit is flipped. Inverts the bits in an Integer. As integers are conceptually of infinite length, the result acts as if it had an infinite number of one bits to the left. In hex representations, this is displayed as two periods to the left of the digits. sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA" @overload ~int @return [Integer];T;0; @l;@F;Ao;B;CT;Di;Ei ;!@Ed;"I"static VALUE int_comp(VALUE num) { if (FIXNUM_P(num)) { return fix_comp(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { return rb_big_comp(num); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#&;F;[[I"y;T0;[[@)ij;T;:&;0;[;{;IC;"Bitwise AND. ;T;[o;H ;II" overload;F;J0;;;K0;#I"&(other_int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @l;[;I"@return [Integer];T;0; @l;@F;Mi;N0;[[I"other_int;T0; @l;[;I">Bitwise AND. @overload &(other_int) @return [Integer];T;0; @l;@F;Ao;B;CT;DiS;EiW;!@Ed;"I"VALUE rb_int_and(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_and(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_and(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#|;F;[[I"y;T0;[[@)i;T;:|;0;[;{;IC;"Bitwise OR. ;T;[o;H ;II" overload;F;J0;;;K0;#I"|(other_int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @l;[;I"@return [Integer];T;0; @l;@F;Mi;N0;[[I"other_int;T0; @l;[;I"=Bitwise OR. @overload |(other_int) @return [Integer];T;0; @l;@F;Ao;B;CT;Div;Eiz;!@Ed;"I"static VALUE int_or(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_or(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_or(x, y); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#^;F;[[I"y;T0;[[@)i;T;:^;0;[;{;IC;"Bitwise EXCLUSIVE OR. ;T;[o;H ;II" overload;F;J0;;;K0;#I"^(other_int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @l;[;I"@return [Integer];T;0; @l;@F;Mi;N0;[[I"other_int;T0; @l;[;I"GBitwise EXCLUSIVE OR. @overload ^(other_int) @return [Integer];T;0; @l;@F;Ao;B;CT;Di;Ei;!@Ed;"I"static VALUE int_xor(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_xor(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_xor(x, y); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#[];F;[[I"idx;T0;[[@)iF;T;;;0;[;{;IC;"\Bit Reference---Returns the nth bit in the binary representation of +int+, where int[0] is the least significant bit. a = 0b11001100101010 30.downto(0) {|n| print a[n] } #=> 0000000000000000011001100101010 a = 9**15 50.downto(0) {|n| print a[n] } #=> 000101110110100000111000011110010100111100010111001 ;T;[o;H ;II" overload;F;J0;;;K0;#I" [](n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI"1;T; @l;[;I"@return [ 0, 1];T;0; @l;@F;Mi;N0;[[I"n;T0; @l;[;I"Bit Reference---Returns the nth bit in the binary representation of +int+, where int[0] is the least significant bit. a = 0b11001100101010 30.downto(0) {|n| print a[n] } #=> 0000000000000000011001100101010 a = 9**15 50.downto(0) {|n| print a[n] } #=> 000101110110100000111000011110010100111100010111001 @overload [](n) @return [ 0, 1];T;0; @l;@F;Ao;B;CT;Di;Ei';!@Ed;"I"static VALUE int_aref(VALUE num, VALUE idx) { if (FIXNUM_P(num)) { return fix_aref(num, idx); } else if (RB_TYPE_P(num, T_BIGNUM)) { return rb_big_aref(num, idx); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#<<;F;[[I"y;T0;[[@)i;T;;Q;0;[;{;IC;"SReturns +int+ shifted left +count+ positions, or right if +count+ is negative. ;T;[o;H ;II" overload;F;J0;;Q;K0;#I"<<(count);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @m;[;I"@return [Integer];T;0; @m;@F;Mi;N0;[[I" count;T0; @m;[;I"}Returns +int+ shifted left +count+ positions, or right if +count+ is negative. @overload <<(count) @return [Integer];T;0; @m;@F;Ao;B;CT;Di;Ei;!@Ed;"I"VALUE rb_int_lshift(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return rb_fix_lshift(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_lshift(x, y); } return Qnil; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Integer#>>;F;[[I"y;T0;[[@)i ;T;:>>;0;[;{;IC;"SReturns +int+ shifted right +count+ positions, or left if +count+ is negative. ;T;[o;H ;II" overload;F;J0;;;K0;#I">>(count);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @=m;[;I"@return [Integer];T;0; @=m;@F;Mi;N0;[[I" count;T0; @=m;[;I"}Returns +int+ shifted right +count+ positions, or left if +count+ is negative. @overload >>(count) @return [Integer];T;0; @=m;@F;Ao;B;CT;Di;Ei;!@Ed;"I"static VALUE rb_int_rshift(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return rb_fix_rshift(x, y); } else if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_rshift(x, y); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#size;F;[;[[@)i;T;;;0;[;{;IC;"Returns the number of bytes in the machine representation of +int+ (machine dependent). 1.size #=> 8 -1.size #=> 8 2147483647.size #=> 8 (256**10 - 1).size #=> 10 (256**20 - 1).size #=> 20 (256**40 - 1).size #=> 40 ;T;[o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\m;[;I"@return [Integer];T;0; @\m;@F;Mi;N0;[; @\m;[;I"4Returns the number of bytes in the machine representation of +int+ (machine dependent). 1.size #=> 8 -1.size #=> 8 2147483647.size #=> 8 (256**10 - 1).size #=> 10 (256**20 - 1).size #=> 20 (256**40 - 1).size #=> 40 @overload size @return [Integer];T;0; @\m;@F;Ao;B;CT;Di;Ei;!@Ed;"I"static VALUE int_size(VALUE num) { if (FIXNUM_P(num)) { return fix_size(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { return rb_big_size_m(num); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#bit_length;F;[;[[@)i;T;:bit_length;0;[;{;IC;"Returns the number of bits of the value of +int+. "Number of bits" means the bit position of the highest bit which is different from the sign bit (where the least significant bit has bit position 1). If there is no such bit (zero or minus one), zero is returned. I.e. this method returns ceil(log2(int < 0 ? -int : int+1)). (-2**1000-1).bit_length #=> 1001 (-2**1000).bit_length #=> 1000 (-2**1000+1).bit_length #=> 1000 (-2**12-1).bit_length #=> 13 (-2**12).bit_length #=> 12 (-2**12+1).bit_length #=> 12 -0x101.bit_length #=> 9 -0x100.bit_length #=> 8 -0xff.bit_length #=> 8 -2.bit_length #=> 1 -1.bit_length #=> 0 0.bit_length #=> 0 1.bit_length #=> 1 0xff.bit_length #=> 8 0x100.bit_length #=> 9 (2**12-1).bit_length #=> 12 (2**12).bit_length #=> 13 (2**12+1).bit_length #=> 13 (2**1000-1).bit_length #=> 1000 (2**1000).bit_length #=> 1001 (2**1000+1).bit_length #=> 1001 This method can be used to detect overflow in Array#pack as follows: if n.bit_length < 32 [n].pack("l") # no overflow else raise "overflow" end ;T;[o;H ;II" overload;F;J0;;;K0;#I"bit_length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @wm;[;I"@return [Integer];T;0; @wm;@F;Mi;N0;[; @wm;[;I"Returns the number of bits of the value of +int+. "Number of bits" means the bit position of the highest bit which is different from the sign bit (where the least significant bit has bit position 1). If there is no such bit (zero or minus one), zero is returned. I.e. this method returns ceil(log2(int < 0 ? -int : int+1)). (-2**1000-1).bit_length #=> 1001 (-2**1000).bit_length #=> 1000 (-2**1000+1).bit_length #=> 1000 (-2**12-1).bit_length #=> 13 (-2**12).bit_length #=> 12 (-2**12+1).bit_length #=> 12 -0x101.bit_length #=> 9 -0x100.bit_length #=> 8 -0xff.bit_length #=> 8 -2.bit_length #=> 1 -1.bit_length #=> 0 0.bit_length #=> 0 1.bit_length #=> 1 0xff.bit_length #=> 8 0x100.bit_length #=> 9 (2**12-1).bit_length #=> 12 (2**12).bit_length #=> 13 (2**12+1).bit_length #=> 13 (2**1000-1).bit_length #=> 1000 (2**1000).bit_length #=> 1001 (2**1000+1).bit_length #=> 1001 This method can be used to detect overflow in Array#pack as follows: if n.bit_length < 32 [n].pack("l") # no overflow else raise "overflow" end @overload bit_length @return [Integer];T;0; @wm;@F;Ao;B;CT;Di;Ei;!@Ed;"I"static VALUE rb_int_bit_length(VALUE num) { if (FIXNUM_P(num)) { return rb_fix_bit_length(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { return rb_big_bit_length(num); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Integer#digits;F;[[@0;[[@)iB;T;: digits;0;[;{;IC;"Returns the digits of +int+'s place-value representation with radix +base+ (default: 10). The digits are returned as an array with the least significant digit as the first array element. +base+ must be greater than or equal to 2. 12345.digits #=> [5, 4, 3, 2, 1] 12345.digits(7) #=> [4, 6, 6, 0, 5] 12345.digits(100) #=> [45, 23, 1] -12345.digits(7) #=> Math::DomainError ;T;[o;H ;II" overload;F;J0;;;K0;#I" digits;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @m;[;I"@return [Array];T;0; @m;@F;Mi;N0;[; @mo;H ;II" overload;F;J0;;;K0;#I"digits(base);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @m;[;I"@return [Array];T;0; @m;@F;Mi;N0;[[I" base;T0; @m;[;I"Returns the digits of +int+'s place-value representation with radix +base+ (default: 10). The digits are returned as an array with the least significant digit as the first array element. +base+ must be greater than or equal to 2. 12345.digits #=> [5, 4, 3, 2, 1] 12345.digits(7) #=> [4, 6, 6, 0, 5] 12345.digits(100) #=> [45, 23, 1] -12345.digits(7) #=> Math::DomainError @overload digits @return [Array] @overload digits(base) @return [Array];T;0; @m;@F;Ao;B;CT;Di;Ei;!@Ed;"I"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_TYPE_P(base_value, T_BIGNUM)) 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_TYPE_P(num, T_BIGNUM)) return rb_int_digits_bigbase(num, LONG2FIX(base)); return Qnil; };T;#I"static VALUE;T;$T;&@Ed;'IC;[;&@Ed;(IC;[;&@Ed;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@d;h;.[;[[@)i^ [@)i{;T;;;;0;;;[;{;IC;"****************************************************************** Holds Integer values. You cannot add a singleton method to an Integer object, any attempt to do so will raise a TypeError.;T;[;[;I"****************************************************************** Holds Integer values. You cannot add a singleton method to an Integer object, any attempt to do so will raise a TypeError. ;T;0; @Ed;@F;Ao;B;CT;Di^ ;Eid ;Mi;!@;I" Integer;F;1o; ;IC;[4o; ; F; ;,;;;I"#Numeric#singleton_method_added;F;[[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; @m;@F;Ao;B;CT;Di;Ei;!@m;"I"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; ; F; ;,;;;I"Numeric#coerce;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"If +numeric+ is the same type as +num+, returns an array [numeric, num]. Otherwise, returns an array with both +numeric+ and +num+ represented as Float objects. This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator. 1.coerce(2.5) #=> [2.5, 1.0] 1.2.coerce(3) #=> [3.0, 1.2] 1.coerce(2) #=> [2, 1] ;T;[o;H ;II" overload;F;J0;;;K0;#I"coerce(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @m;[;I"@return [Array];T;0; @m;@F;Mi;N0;[[I" numeric;T0; @m;[;I"If +numeric+ is the same type as +num+, returns an array [numeric, num]. Otherwise, returns an array with both +numeric+ and +num+ represented as Float objects. This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator. 1.coerce(2.5) #=> [2.5, 1.0] 1.2.coerce(3) #=> [3.0, 1.2] 1.coerce(2) #=> [2, 1] @overload coerce(numeric) @return [Array];T;0; @m;@F;Ao;B;CT;Di|;Ei;!@m;"I"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; ; F; ;,;;;I"Numeric#clone;F;[[@0;[[@)i;T;;X;0;[;{;IC;"7Returns the receiver. +freeze+ cannot be +false+. ;T;[o;H ;II" overload;F;J0;;X;K0;#I"clone(freeze: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @n;[;I"@return [Numeric];T;0; @n;@F;Mi;N0;[[I" freeze:;TI" true;T; @n;[;I"kReturns the receiver. +freeze+ cannot be +false+. @overload clone(freeze: true) @return [Numeric];T;0; @n;@F;Ao;B;CT;Di;Ei;!@m;"I"qstatic VALUE num_clone(int argc, VALUE *argv, VALUE x) { return rb_immutable_obj_clone(argc, argv, x); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#dup;F;[;[[@)i;T;;Y;0;[;{;IC;"Returns the receiver. ;T;[o;H ;II" overload;F;J0;;Y;K0;#I"dup;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @n;[;I"@return [Numeric];T;0; @n;@F;Mi;N0;[; @n;[;I">Returns the receiver. @overload dup @return [Numeric];T;0; @n;@F;Ao;B;CT;Di;Ei;!@m;"I"4static VALUE num_dup(VALUE x) { return x; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#i;F;[;[[@)i%;T;:i;0;[;{;IC;"|Returns the corresponding imaginary number. Not available for complex numbers. -42.i #=> (0-42i) 2.0.i #=> (0+2.0i) ;T;[o;H ;II" overload;F;J0;;;K0;#I"i;T;IC;";T;[o;L ;II" return;F;JI"Complex(0];T;0;K[I"Complex(0];T; @:n;[;I"@return [ Complex(0];T;0; @:n;@F;Mi;N0;[; @:n;[;I"Returns the corresponding imaginary number. Not available for complex numbers. -42.i #=> (0-42i) 2.0.i #=> (0+2.0i) @overload i @return [ Complex(0];T;0; @:n;@F;Ao;B;CT;Di;Ei";!@m;"I"Zstatic VALUE num_imaginary(VALUE num) { return rb_complex_new(INT2FIX(0), num); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#+@;F;[;[[@)i;T;;:;0;[;{;IC;"'Unary Plus---Returns the receiver. ;T;[o;H ;II" overload;F;J0;;(;K0;#I" +num;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @Un;[;I"@return [Numeric];T;0; @Un;@F;Mi;N0;[; @Un;[;I"LUnary Plus---Returns the receiver. @overload +num @return [Numeric];T;0; @Un;@F;Ao;B;CT;Di ;Ei;!@m;"I":static VALUE num_uplus(VALUE num) { return num; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#-@;F;[;[[@)i2;T;;;;0;[;{;IC;"1Unary Minus---Returns the receiver, negated. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" -num;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @pn;[;I"@return [Numeric];T;0; @pn;@F;Mi;N0;[; @pn;[;I"VUnary Minus---Returns the receiver, negated. @overload -num @return [Numeric];T;0; @pn;@F;Ao;B;CT;Di+;Ei/;!@m;"I"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; ; F; ;,;;;I"Numeric#<=>;F;[[I"y;T0;[[@)iF;T;;V;0;[;{;IC;"FReturns zero if +number+ equals +other+, otherwise returns +nil+. ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI"nil;T; @n;[;I"@return [ 0, nil];T;0; @n;@F;Mi;N0;[[I" other;T0; @n;[;I"qReturns zero if +number+ equals +other+, otherwise returns +nil+. @overload <=>(other) @return [ 0, nil];T;0; @n;@F;Ao;B;CT;Di?;EiC;!@m;"I"cstatic VALUE num_cmp(VALUE x, VALUE y) { if (x == y) return INT2FIX(0); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#eql?;F;[[I"y;T0;[[@)i3;T;;R;0;[;{;IC;"Returns +true+ if +num+ and +numeric+ are the same type and have equal values. Contrast this with Numeric#==, which performs type conversions. 1 == 1.0 #=> true 1.eql?(1.0) #=> false 1.0.eql?(1.0) #=> true;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n;[;I"@return [Boolean];T;0; @n;@F;Mi;N0;[[I" numeric;T0; @n;[;I"Returns +true+ if +num+ and +numeric+ are the same type and have equal values. Contrast this with Numeric#==, which performs type conversions. 1 == 1.0 #=> true 1.eql?(1.0) #=> false 1.0.eql?(1.0) #=> true @overload eql?(numeric) @return [Boolean];T;0; @n;@F;Ao;B;CT;Di';Ei0;Mi;!@m;"I"static VALUE num_eql(VALUE x, VALUE y) { if (TYPE(x) != TYPE(y)) return Qfalse; if (RB_TYPE_P(x, T_BIGNUM)) { return rb_big_eql(x, y); } return rb_equal(x, y); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#fdiv;F;[[I"y;T0;[[@)iD;T;;;0;[;{;IC;"Returns float division. ;T;[o;H ;II" overload;F;J0;;;K0;#I"fdiv(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @n;[;I"@return [Float];T;0; @n;@F;Mi;N0;[[I" numeric;T0; @n;[;I"HReturns float division. @overload fdiv(numeric) @return [Float];T;0; @n;@F;Ao;B;CT;Di=;EiA;!@m;"I"_static VALUE num_fdiv(VALUE x, VALUE y) { return rb_funcall(rb_Float(x), '/', 1, y); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#div;F;[[I"y;T0;[[@)iV;T;;;0;[;{;IC;"Uses +/+ to perform division, then converts the result to an integer. Numeric does not define the +/+ operator; this is left to subclasses. Equivalent to num.divmod(numeric)[0]. See Numeric#divmod. ;T;[o;H ;II" overload;F;J0;;;K0;#I"div(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @n;[;I"@return [Integer];T;0; @n;@F;Mi;N0;[[I" numeric;T0; @n;[;I"Uses +/+ to perform division, then converts the result to an integer. Numeric does not define the +/+ operator; this is left to subclasses. Equivalent to num.divmod(numeric)[0]. See Numeric#divmod. @overload div(numeric) @return [Integer];T;0; @n;@F;Ao;B;CT;DiJ;EiS;!@m;"I"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; ; F; ;,;;;I"Numeric#divmod;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"6Returns an array containing the quotient and modulus obtained by dividing +num+ by +numeric+. If q, r = x.divmod(y), then q = floor(x/y) x = q*y + r The quotient is rounded toward negative infinity, as shown in the following table: a | b | a.divmod(b) | a/b | a.modulo(b) | a.remainder(b) ------+-----+---------------+---------+-------------+--------------- 13 | 4 | 3, 1 | 3 | 1 | 1 ------+-----+---------------+---------+-------------+--------------- 13 | -4 | -4, -3 | -4 | -3 | 1 ------+-----+---------------+---------+-------------+--------------- -13 | 4 | -4, 3 | -4 | 3 | -1 ------+-----+---------------+---------+-------------+--------------- -13 | -4 | 3, -1 | 3 | -1 | -1 ------+-----+---------------+---------+-------------+--------------- 11.5 | 4 | 2, 3.5 | 2.875 | 3.5 | 3.5 ------+-----+---------------+---------+-------------+--------------- 11.5 | -4 | -3, -0.5 | -2.875 | -0.5 | 3.5 ------+-----+---------------+---------+-------------+--------------- -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5 ------+-----+---------------+---------+-------------+--------------- -11.5 | -4 | 2, -3.5 | 2.875 | -3.5 | -3.5 Examples 11.divmod(3) #=> [3, 2] 11.divmod(-3) #=> [-4, -1] 11.divmod(3.5) #=> [3, 0.5] (-11).divmod(3.5) #=> [-4, 3.0] 11.5.divmod(3.5) #=> [3, 1.0] ;T;[o;H ;II" overload;F;J0;;;K0;#I"divmod(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @o;[;I"@return [Array];T;0; @o;@F;Mi;N0;[[I" numeric;T0; @o;[;I"dReturns an array containing the quotient and modulus obtained by dividing +num+ by +numeric+. If q, r = x.divmod(y), then q = floor(x/y) x = q*y + r The quotient is rounded toward negative infinity, as shown in the following table: a | b | a.divmod(b) | a/b | a.modulo(b) | a.remainder(b) ------+-----+---------------+---------+-------------+--------------- 13 | 4 | 3, 1 | 3 | 1 | 1 ------+-----+---------------+---------+-------------+--------------- 13 | -4 | -4, -3 | -4 | -3 | 1 ------+-----+---------------+---------+-------------+--------------- -13 | 4 | -4, 3 | -4 | 3 | -1 ------+-----+---------------+---------+-------------+--------------- -13 | -4 | 3, -1 | 3 | -1 | -1 ------+-----+---------------+---------+-------------+--------------- 11.5 | 4 | 2, 3.5 | 2.875 | 3.5 | 3.5 ------+-----+---------------+---------+-------------+--------------- 11.5 | -4 | -3, -0.5 | -2.875 | -0.5 | 3.5 ------+-----+---------------+---------+-------------+--------------- -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5 ------+-----+---------------+---------+-------------+--------------- -11.5 | -4 | 2, -3.5 | 2.875 | -3.5 | -3.5 Examples 11.divmod(3) #=> [3, 2] 11.divmod(-3) #=> [-4, -1] 11.divmod(3.5) #=> [3, 0.5] (-11).divmod(3.5) #=> [-4, 3.0] 11.5.divmod(3.5) #=> [3, 1.0] @overload divmod(numeric) @return [Array];T;0; @o;@F;Ao;B;CT;Di;Ei;!@m;"I"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; ; F; ;,;;;I"Numeric#%;F;[[I"y;T0;[[@)ih;T;;*;0;[;{;IC;"x.modulo(y) means x-y*(x/y).floor. Equivalent to num.divmod(numeric)[1]. See Numeric#divmod. ;T;[o;H ;II" overload;F;J0;;;K0;#I"modulo(numeric);T;IC;";T;[;[;I";T;0; @'o;@F;Mi;N0;[[I" numeric;T0; @'o;[;I"x.modulo(y) means x-y*(x/y).floor. Equivalent to num.divmod(numeric)[1]. See Numeric#divmod. @overload modulo(numeric);T;0; @'o;@F;Ao;B;CT;Di];Eid;!@m;"I"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; ; F; ;,;;;I"Numeric#modulo;F;[[I"y;T0;[[@)ih;T;;;0;[;{;IC;"x.modulo(y) means x-y*(x/y).floor. Equivalent to num.divmod(numeric)[1]. See Numeric#divmod. ;T;[o;H ;II" overload;F;J0;;;K0;#I"modulo(numeric);T;IC;";T;[;[;I";T;0; @Ao;@F;Mi;N0;[[I" numeric;T0; @Ao;[;@=o;0; @Ao;@F;Ao;B;CT;Di];Eid;!@m;"I"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; ; F; ;,;;;I"Numeric#remainder;F;[[I"y;T0;[[@)iy;T;;;0;[;{;IC;"\x.remainder(y) means x-y*(x/y).truncate. See Numeric#divmod. ;T;[o;H ;II" overload;F;J0;;;K0;#I"remainder(numeric);T;IC;";T;[;[;I";T;0; @Zo;@F;Mi;N0;[[I" numeric;T0; @Zo;[;I"{x.remainder(y) means x-y*(x/y).truncate. See Numeric#divmod. @overload remainder(numeric);T;0; @Zo;@F;Ao;B;CT;Dip;Eiu;!@m;"I"3static 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)))) { return rb_funcall(z, '-', 1, y); } return z; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#abs;F;[;[[@)i;T;;;0;[;{;IC;"Returns the absolute value of +num+. 12.abs #=> 12 (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 Numeric#magnitude is an alias for Numeric#abs. ;T;[o;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @to;[;I"@return [Numeric];T;0; @to;@F;Mi;N0;[; @too;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @to;[;I"@return [Numeric];T;0; @to;@F;Mi;N0;[; @to;[;I"Returns the absolute value of +num+. 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] @overload magnitude @return [Numeric];T;0; @to;@F;Ao;B;CT;Di;Ei;!@m;"I"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; ; F; ;,;;;I"Numeric#magnitude;F;[;[[@)i;T;;;0;[;{;IC;"Returns the absolute value of +num+. 12.abs #=> 12 (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 Numeric#magnitude is an alias for Numeric#abs. ;T;[o;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @o;[;I"@return [Numeric];T;0; @o;@F;Mi;N0;[; @oo;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @o;[;I"@return [Numeric];T;0; @o;@F;Mi;N0;[; @o;[;@o;0; @o;@F;Ao;B;CT;Di;Ei;!@m;"I"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; ; F; ;,;;;I"Numeric#to_int;F;[;[[@)iB;T;;;0;[;{;IC;"Invokes the child class's +to_i+ method to convert +num+ to an integer. 1.0.class #=> Float 1.0.to_int.class #=> Integer 1.0.to_i.class #=> Integer ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @o;[;I"@return [Integer];T;0; @o;@F;Mi;N0;[; @o;[;I"Invokes the child class's +to_i+ method to convert +num+ to an integer. 1.0.class #=> Float 1.0.to_int.class #=> Integer 1.0.to_i.class #=> Integer @overload to_int @return [Integer];T;0; @o;@F;Ao;B;CT;Di7;Ei?;!@m;"I"Rstatic VALUE num_to_int(VALUE num) { return num_funcall0(num, id_to_i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#real?;F;[;[[@)i;T;: real?;0;[;{;IC;"AReturns +true+ if +num+ is a real number (i.e. not Complex).;T;[o;H ;II" overload;F;J0;;;K0;#I" real?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @o;[;I"@return [Boolean];T;0; @o;@F;Mi;N0;[; @o;[;I"gReturns +true+ if +num+ is a real number (i.e. not Complex). @overload real? @return [Boolean];T;0; @o;@F;Ao;B;CT;Di;Ei;Mi;!@m;"I"=static VALUE num_real_p(VALUE num) { return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#integer?;F;[;[[@)i;T;;;0;[;{;IC;"eReturns +true+ if +num+ is an Integer. 1.0.integer? #=> false 1.integer? #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I" integer?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @o;[;I"@return [Boolean];T;0; @o;@F;Mi;N0;[; @o;[;I"Returns +true+ if +num+ is an Integer. 1.0.integer? #=> false 1.integer? #=> true @overload integer? @return [Boolean];T;0; @o;@F;Ao;B;CT;Di;Ei;Mi;!@m;"I"=static VALUE num_int_p(VALUE num) { return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#zero?;F;[;[[@)i;T;: zero?;0;[;{;IC;".Returns +true+ if +num+ has a zero value.;T;[o;H ;II" overload;F;J0;;;K0;#I" zero?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @p;[;I"@return [Boolean];T;0; @p;@F;Mi;N0;[; @p;[;I"TReturns +true+ if +num+ has a zero value. @overload zero? @return [Boolean];T;0; @p;@F;Ao;B;CT;Di;Ei;Mi;!@m;"I"Qstatic VALUE num_zero_p(VALUE num) { if (FIXNUM_P(num)) { if (FIXNUM_ZERO_P(num)) { return Qtrue; } } else if (RB_TYPE_P(num, T_BIGNUM)) { if (rb_bigzero_p(num)) { /* this should not happen usually */ return Qtrue; } } else if (rb_equal(num, INT2FIX(0))) { return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#nonzero?;F;[;[[@)i;T;: nonzero?;0;[;{;IC;"Returns +self+ if +num+ is not zero, +nil+ otherwise. This behavior is useful when chaining comparisons: a = %w( z Bb bB bb BB a aA Aa AA A ) b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b } b #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"];T;[o;H ;II" overload;F;J0;;;K0;#I" nonzero?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;TI"nil;T; @/p;[;I"@return [self, nil];T;0; @/p;@F;Mi;N0;[; @/p;[;I"IReturns +self+ if +num+ is not zero, +nil+ otherwise. This behavior is useful when chaining comparisons: a = %w( z Bb bB bb BB a aA Aa AA A ) b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b } b #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"] @overload nonzero? @return [self, nil];T;0; @/p;@F;Ao;B;CT;Di;Ei;Mi;!@m;"I"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; ; F; ;,;;;I"Numeric#finite?;F;[;[[@)i$;T;: finite?;0;[;{;IC;"KReturns +true+ if +num+ is a finite number, otherwise returns +false+.;T;[o;H ;II" overload;F;J0;;;K0;#I" finite?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Kp;[;I"@return [Boolean];T;0; @Kp;@F;Mi;N0;[; @Kp;[;I"sReturns +true+ if +num+ is a finite number, otherwise returns +false+. @overload finite? @return [Boolean];T;0; @Kp;@F;Ao;B;CT;Di;Ei";Mi;!@m;"I"?static VALUE num_finite_p(VALUE num) { return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#infinite?;F;[;[[@)i1;T;:infinite?;0;[;{;IC;"yReturns +nil+, -1, or 1 depending on whether the value is finite, -Infinity, or +Infinity.;T;[o;H ;II" overload;F;J0;;;K0;#I"infinite?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"-1;TI"1;TI"nil;T; @fp;[;I"@return [ -1, 1, nil];T;0; @fp;@F;Mi;N0;[; @fp;[;I"Returns +nil+, -1, or 1 depending on whether the value is finite, -Infinity, or +Infinity. @overload infinite? @return [ -1, 1, nil];T;0; @fp;@F;Ao;B;CT;Di*;Ei/;Mi;!@m;"I"@static VALUE num_infinite_p(VALUE num) { return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#floor;F;[[@0;[[@)i{ ;T;;;0;[;{;IC;"Returns the largest number less than or equal to +num+ with a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#floor. ;T;[o;H ;II" overload;F;J0;;;K0;#I"floor([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @p;[;I"@return [Integer, Float];T;0; @p;@F;Mi;N0;[[I"[ndigits];T0; @p;[;I"Returns the largest number less than or equal to +num+ with a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#floor. @overload floor([ndigits]) @return [Integer, Float];T;0; @p;@F;Ao;B;CT;Dip ;Eix ;!@m;"I"rstatic VALUE num_floor(int argc, VALUE *argv, VALUE num) { return flo_floor(argc, argv, rb_Float(num)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#ceil;F;[[@0;[[@)i ;T;;;0;[;{;IC;"Returns the smallest number greater than or equal to +num+ with a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#ceil. ;T;[o;H ;II" overload;F;J0;;;K0;#I"ceil([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @p;[;I"@return [Integer, Float];T;0; @p;@F;Mi;N0;[[I"[ndigits];T0; @p;[;I"Returns the smallest number greater than or equal to +num+ with a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#ceil. @overload ceil([ndigits]) @return [Integer, Float];T;0; @p;@F;Ao;B;CT;Di ;Ei ;!@m;"I"pstatic VALUE num_ceil(int argc, VALUE *argv, VALUE num) { return flo_ceil(argc, argv, rb_Float(num)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#round;F;[[@0;[[@)i ;T;;E;0;[;{;IC;"Returns +num+ rounded to the nearest value with a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#round. ;T;[o;H ;II" overload;F;J0;;E;K0;#I"round([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @p;[;I"@return [Integer, Float];T;0; @p;@F;Mi;N0;[[I"[ndigits];T0; @p;[;I"Returns +num+ rounded to the nearest value with a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#round. @overload round([ndigits]) @return [Integer, Float];T;0; @p;@F;Ao;B;CT;Di ;Ei ;!@m;"I"rstatic VALUE num_round(int argc, VALUE* argv, VALUE num) { return flo_round(argc, argv, rb_Float(num)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#truncate;F;[[@0;[[@)i ;T;;;0;[;{;IC;"Returns +num+ truncated (toward zero) to a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#truncate. ;T;[o;H ;II" overload;F;J0;;;K0;#I"truncate([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @p;[;I"@return [Integer, Float];T;0; @p;@F;Mi;N0;[[I"[ndigits];T0; @p;[;I"Returns +num+ truncated (toward zero) to a precision of +ndigits+ decimal digits (default: 0). Numeric implements this by converting its value to a Float and invoking Float#truncate. @overload truncate([ndigits]) @return [Integer, Float];T;0; @p;@F;Ao;B;CT;Di ;Ei ;!@m;"I"xstatic VALUE num_truncate(int argc, VALUE *argv, VALUE num) { return flo_truncate(argc, argv, rb_Float(num)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#step;F;[[@0;[[@)i ;T;: step;0;[;{;IC;"4Invokes the given block with the sequence of numbers starting at +num+, incremented by +step+ (defaulted to +1+) on each call. The loop finishes when the value to be passed to the block is greater than +limit+ (if +step+ is positive) or less than +limit+ (if +step+ is negative), where +limit+ is defaulted to infinity. In the recommended keyword argument style, either or both of +step+ and +limit+ (default infinity) can be omitted. In the fixed position argument style, zero as a step (i.e. num.step(limit, 0)) is not allowed for historical compatibility reasons. 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 - num)/step. Otherwise, the loop starts at +num+, uses either the less-than (<) or greater-than (>) operator to compare the counter against +limit+, and increments itself using the + operator. If no block is given, an Enumerator is returned instead. Especially, the enumerator is an Enumerator::ArithmeticSequence if both +limit+ and +step+ are kind of Numeric or nil. For example: p 1.step.take(4) p 10.step(by: -1).take(4) 3.step(to: 5) {|i| print i, " " } 1.step(10, 2) {|i| print i, " " } Math::E.step(to: Math::PI, by: 0.2) {|f| print f, " " } Will produce: [1, 2, 3, 4] [10, 9, 8, 7] 3 4 5 1 3 5 7 9 2.718281828459045 2.9182818284590453 3.118281828459045 ;T;[ o;H ;II" overload;F;J0;;;K0;#I"step(by: step, to: limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @po;L ;II" return;F;JI";T;0;K[I" self;T; @p;[;I"@yield [i] @return [self];T;0; @p;@F;Mi;N0;[[I"by:;TI" step;T[I"to:;TI" limit;T; @po;H ;II" overload;F;J0;;;K0;#I"step(by: step, to: limit);T;IC;";T;[;[;I";T;0; @p;@F;Mi;N0;[[I"by:;TI" step;T[I"to:;TI" limit;T; @po;H ;II" overload;F;J0;;;K0;#I"step(by: step, to: limit);T;IC;";T;[;[;I";T;0; @p;@F;Mi;N0;[[I"by:;TI" step;T[I"to:;TI" limit;T; @po;H ;II" overload;F;J0;;;K0;#I"step(limit=nil, step=1);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @po;L ;II" return;F;JI";T;0;K[I" self;T; @p;[;I"@yield [i] @return [self];T;0; @p;@F;Mi;N0;[[I" limit;TI"nil;T[I" step;TI"1;T; @po;H ;II" overload;F;J0;;;K0;#I"step(limit=nil, step=1);T;IC;";T;[;[;I";T;0; @p;@F;Mi;N0;[[I" limit;TI"nil;T[I" step;TI"1;T; @po;H ;II" overload;F;J0;;;K0;#I"step(limit=nil, step=1);T;IC;";T;[;[;I";T;0; @p;@F;Mi;N0;[[I" limit;TI"nil;T[I" step;TI"1;T; @p;[;I"DInvokes the given block with the sequence of numbers starting at +num+, incremented by +step+ (defaulted to +1+) on each call. The loop finishes when the value to be passed to the block is greater than +limit+ (if +step+ is positive) or less than +limit+ (if +step+ is negative), where +limit+ is defaulted to infinity. In the recommended keyword argument style, either or both of +step+ and +limit+ (default infinity) can be omitted. In the fixed position argument style, zero as a step (i.e. num.step(limit, 0)) is not allowed for historical compatibility reasons. 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 - num)/step. Otherwise, the loop starts at +num+, uses either the less-than (<) or greater-than (>) operator to compare the counter against +limit+, and increments itself using the + operator. If no block is given, an Enumerator is returned instead. Especially, the enumerator is an Enumerator::ArithmeticSequence if both +limit+ and +step+ are kind of Numeric or nil. For example: p 1.step.take(4) p 10.step(by: -1).take(4) 3.step(to: 5) {|i| print i, " " } 1.step(10, 2) {|i| print i, " " } Math::E.step(to: Math::PI, by: 0.2) {|f| print f, " " } Will produce: [1, 2, 3, 4] [10, 9, 8, 7] 3 4 5 1 3 5 7 9 2.718281828459045 2.9182818284590453 3.118281828459045 @overload step(by: step, to: limit) @yield [i] @return [self] @overload step(by: step, to: limit) @overload step(by: step, to: limit) @overload step(limit=nil, step=1) @yield [i] @return [self] @overload step(limit=nil, step=1) @overload step(limit=nil, step=1);T;0; @p;@F;Ao;B;CT;Di| ;Ei ;!@m;"I"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); } 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, argc, argv, 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_TYPE_P(to, T_FLOAT)) { 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; ; F; ;,;;;I"Numeric#positive?;F;[;[[@)iO;T;:positive?;0;[;{;IC;"/Returns +true+ if +num+ is greater than 0.;T;[o;H ;II" overload;F;J0;;;K0;#I"positive?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @vq;[;I"@return [Boolean];T;0; @vq;@F;Mi;N0;[; @vq;[;I"YReturns +true+ if +num+ is greater than 0. @overload positive? @return [Boolean];T;0; @vq;@F;Ao;B;CT;DiH;EiL;Mi;!@m;"I"static VALUE num_positive_p(VALUE num) { const ID mid = '>'; if (FIXNUM_P(num)) { if (method_basic_p(rb_cInteger)) return (SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0) ? Qtrue : Qfalse; } else if (RB_TYPE_P(num, T_BIGNUM)) { if (method_basic_p(rb_cInteger)) return BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num) ? Qtrue : Qfalse; } return rb_num_compare_with_zero(num, mid); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#negative?;F;[;[[@)if;T;:negative?;0;[;{;IC;",Returns +true+ if +num+ is less than 0.;T;[o;H ;II" overload;F;J0;;;K0;#I"negative?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @q;[;I"@return [Boolean];T;0; @q;@F;Mi;N0;[; @q;[;I"VReturns +true+ if +num+ is less than 0. @overload negative? @return [Boolean];T;0; @q;@F;Ao;B;CT;Di_;Eic;Mi;!@m;"I"gstatic VALUE num_negative_p(VALUE num) { return rb_num_negative_int_p(num) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#to_c;F;[;[[@i-;T;;&;0;[;{;IC;"$Returns the value as a complex. ;T;[o;H ;II" overload;F;J0;;&;K0;#I" to_c;T;IC;";T;[;[;I";T;0; @q;@F;Mi;N0;[; @q;[;I"5Returns the value as a complex. @overload to_c;T;0; @q;@F;Ao;B;CT;Di';Ei*;!@m;"I"Pstatic VALUE numeric_to_c(VALUE self) { return rb_complex_new1(self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#real;F;[;[[@i;T;: real;0;[;{;IC;"Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I" real;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @q;[;I"@return [self];T;0; @q;@F;Mi;N0;[; @q;[;I"4Returns self. @overload real @return [self];T;0; @q;@F;Ao;B;CT;Di;Ei;!@m;"I"?static VALUE numeric_real(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#imaginary;F;[;[[@i;T;:imaginary;0;[;{;IC;"Returns zero. ;T;[o;H ;II" overload;F;J0;: imag;K0;#I" imag;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @q;[;I"@return [ 0];T;0; @q;@F;Mi;N0;[; @qo;H ;II" overload;F;J0;;;K0;#I"imaginary;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @q;[;I"@return [ 0];T;0; @q;@F;Mi;N0;[; @q;[;I"UReturns zero. @overload imag @return [ 0] @overload imaginary @return [ 0];T;0; @q;@F;Ao;B;CT;Di;Ei;!@m;"I"Estatic VALUE numeric_imag(VALUE self) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#imag;F;[;[[@i;T;;;0;[;{;IC;"Returns zero. ;T;[o;H ;II" overload;F;J0;;;K0;#I" imag;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @r;[;I"@return [ 0];T;0; @r;@F;Mi;N0;[; @ro;H ;II" overload;F;J0;;;K0;#I"imaginary;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @r;[;I"@return [ 0];T;0; @r;@F;Mi;N0;[; @r;[;@r;0; @r;@F;Ao;B;CT;Di;Ei;!@m;"I"Estatic VALUE numeric_imag(VALUE self) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#abs2;F;[;[[@i ;T;: abs2;0;[;{;IC;"Returns square of self. ;T;[o;H ;II" overload;F;J0;;;K0;#I" abs2;T;IC;";T;[;[;I";T;0; @,r;@F;Mi;N0;[; @,r;[;I"-Returns square of self. @overload abs2;T;0; @,r;@F;Ao;B;CT;Di;Ei ;!@m;"I"Lstatic VALUE numeric_abs2(VALUE self) { return f_mul(self, self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#arg;F;[;[[@i;T;:arg;0;[;{;IC;"6Returns 0 if the value is positive, pi otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I"arg;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @Br;[;I"@return [ 0, Float];T;0; @Br;@F;Mi;N0;[; @Bro;H ;II" overload;F;J0;: angle;K0;#I" angle;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @Br;[;I"@return [ 0, Float];T;0; @Br;@F;Mi;N0;[; @Bro;H ;II" overload;F;J0;: phase;K0;#I" phase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @Br;[;I"@return [ 0, Float];T;0; @Br;@F;Mi;N0;[; @Br;[;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; @Br;@F;Ao;B;CT;Di;Ei;!@m;"I"~static VALUE numeric_arg(VALUE self) { if (f_positive_p(self)) return INT2FIX(0); return DBL2NUM(M_PI); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#angle;F;[;[[@i;T;;;0;[;{;IC;"6Returns 0 if the value is positive, pi otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I"arg;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @zr;[;I"@return [ 0, Float];T;0; @zr;@F;Mi;N0;[; @zro;H ;II" overload;F;J0;;;K0;#I" angle;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @zr;[;I"@return [ 0, Float];T;0; @zr;@F;Mi;N0;[; @zro;H ;II" overload;F;J0;;;K0;#I" phase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @zr;[;I"@return [ 0, Float];T;0; @zr;@F;Mi;N0;[; @zr;[;@vr;0; @zr;@F;Ao;B;CT;Di;Ei;!@m;"I"~static VALUE numeric_arg(VALUE self) { if (f_positive_p(self)) return INT2FIX(0); return DBL2NUM(M_PI); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#phase;F;[;[[@i;T;;;0;[;{;IC;"6Returns 0 if the value is positive, pi otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I"arg;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @r;[;I"@return [ 0, Float];T;0; @r;@F;Mi;N0;[; @ro;H ;II" overload;F;J0;;;K0;#I" angle;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @r;[;I"@return [ 0, Float];T;0; @r;@F;Mi;N0;[; @ro;H ;II" overload;F;J0;;;K0;#I" phase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" Float;T; @r;[;I"@return [ 0, Float];T;0; @r;@F;Mi;N0;[; @r;[;@vr;0; @r;@F;Ao;B;CT;Di;Ei;!@m;"I"~static VALUE numeric_arg(VALUE self) { if (f_positive_p(self)) return INT2FIX(0); return DBL2NUM(M_PI); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#rectangular;F;[;[[@i*;T;:rectangular;0;[;{;IC;" Returns an array; [num, 0]. ;T;[o;H ;II" overload;F;J0;: rect;K0;#I" rect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @r;[;I"@return [Array];T;0; @r;@F;Mi;N0;[; @ro;H ;II" overload;F;J0;;;K0;#I"rectangular;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @r;[;I"@return [Array];T;0; @r;@F;Mi;N0;[; @r;[;I"kReturns an array; [num, 0]. @overload rect @return [Array] @overload rectangular @return [Array];T;0; @r;@F;Ao;B;CT;Di#;Ei);!@m;"I"Ystatic VALUE numeric_rect(VALUE self) { return rb_assoc_new(self, INT2FIX(0)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#rect;F;[;[[@i*;T;;;0;[;{;IC;" Returns an array; [num, 0]. ;T;[o;H ;II" overload;F;J0;;;K0;#I" rect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @s;[;I"@return [Array];T;0; @s;@F;Mi;N0;[; @so;H ;II" overload;F;J0;;;K0;#I"rectangular;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @s;[;I"@return [Array];T;0; @s;@F;Mi;N0;[; @s;[;@ s;0; @s;@F;Ao;B;CT;Di#;Ei);!@m;"I"Ystatic VALUE numeric_rect(VALUE self) { return rb_assoc_new(self, INT2FIX(0)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#polar;F;[;[[@i8;T;: polar;0;[;{;IC;"*Returns an array; [num.abs, num.arg]. ;T;[o;H ;II" overload;F;J0;;;K0;#I" polar;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @7s;[;I"@return [Array];T;0; @7s;@F;Mi;N0;[; @7s;[;I"NReturns an array; [num.abs, num.arg]. @overload polar @return [Array];T;0; @7s;@F;Ao;B;CT;Di2;Ei6;!@m;"I"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; ; F; ;,;;;I"Numeric#conjugate;F;[;[[@iW;T;:conjugate;0;[;{;IC;"Returns self. ;T;[o;H ;II" overload;F;J0;: conj;K0;#I" conj;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @Rs;[;I"@return [self];T;0; @Rs;@F;Mi;N0;[; @Rso;H ;II" overload;F;J0;;;K0;#I"conjugate;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @Rs;[;I"@return [self];T;0; @Rs;@F;Mi;N0;[; @Rs;[;I"YReturns self. @overload conj @return [self] @overload conjugate @return [self];T;0; @Rs;@F;Ao;B;CT;DiP;EiV;!@m;"I"?static VALUE numeric_conj(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#conj;F;[;[[@iW;T;;;0;[;{;IC;"Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I" conj;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @zs;[;I"@return [self];T;0; @zs;@F;Mi;N0;[; @zso;H ;II" overload;F;J0;;;K0;#I"conjugate;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @zs;[;I"@return [self];T;0; @zs;@F;Mi;N0;[; @zs;[;@vs;0; @zs;@F;Ao;B;CT;DiP;EiV;!@m;"I"?static VALUE numeric_conj(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#numerator;F;[;[[@ i;T;;;0;[;{;IC;"Returns the numerator. ;T;[o;H ;II" overload;F;J0;;;K0;#I"numerator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @s;[;I"@return [Integer];T;0; @s;@F;Mi;N0;[; @s;[;I"EReturns the numerator. @overload numerator @return [Integer];T;0; @s;@F;Ao;B;CT;Di;Ei;!@m;"I"Ystatic VALUE numeric_numerator(VALUE self) { return f_numerator(f_to_r(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#denominator;F;[;[[@ i;T;;;0;[;{;IC;"/Returns the denominator (always positive). ;T;[o;H ;II" overload;F;J0;;;K0;#I"denominator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @s;[;I"@return [Integer];T;0; @s;@F;Mi;N0;[; @s;[;I"[Returns the denominator (always positive). @overload denominator @return [Integer];T;0; @s;@F;Ao;B;CT;Di;Ei;!@m;"I"]static VALUE numeric_denominator(VALUE self) { return f_denominator(f_to_r(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Numeric#quo;F;[[I"y;T0;[[@ i;T;:quo;0;[;{;IC;"OReturns the most exact division (rational for integers, float for floats). ;T;[o;H ;II" overload;F;J0;;;K0;#I"quo(int_or_rat);T;IC;";T;[;[;I";T;0; @s;@F;Mi;N0;[[I"int_or_rat;T0; @so;H ;II" overload;F;J0;;;K0;#I" quo(flo);T;IC;";T;[;[;I";T;0; @s;@F;Mi;N0;[[I"flo;T0; @s;[;I"~Returns the most exact division (rational for integers, float for floats). @overload quo(int_or_rat) @overload quo(flo);T;0; @s;@F;Ao;B;CT;Di;Ei;!@m;"I"6VALUE rb_numeric_quo(VALUE x, VALUE y) { if (RB_FLOAT_TYPE_P(y)) { return rb_funcall(x, rb_intern("fdiv"), 1, y); } if (canonicalization) { x = rb_rational_raw1(x); } else { x = rb_convert_type(x, T_RATIONAL, "Rational", "to_r"); } return nurat_div(x, y); };T;#I" VALUE;T;$T;&@m;'IC;[;&@m;(IC;[o;2 ;30;40;50;;;!@;7@;F0;&@m;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@)i[@)iU;T;: Numeric;;0;;;[;{;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;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 ;T;0; @m;@F;Ao;B;CT;Di;EiB;Mi;!@;I" Numeric;F;1o;2 ;30;40;50;;6;!@;7@<;F;o;9;[[I"ext/win32ole/win32ole.c;Ti';F;:CONSTANTS;;;;;;[;{;IC;" ;T;[;[;@;0; @t;!@%d;I"Bug::Integer::CONSTANTS;F;basic.flags &= ~RSTRING_EMBED_LEN_MASK; RSTRING(str)->basic.flags |= len << RSTRING_EMBED_LEN_SHIFT; memmove(RSTRING(str)->as.ary, RSTRING(str)->as.ary + beg, len); } else { RSTRING(str)->as.heap.ptr += beg; RSTRING(str)->as.heap.len = len; } return str; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Bug::Integer.cstr_term;F;[[I"str;T0;[[@0tiP;T;:cstr_term;0;[;{;IC;" ;T;[;[;@;0; @Tt;!@%d;"I"}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; ; F; ;;;;I"Bug::Integer.cstr_unterm;F;[[I"str;T0[I"c;T0;[[@0tiW;T;;;0;[;{;IC;" ;T;[;[;@;0; @bt;!@%d;"I"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; ; F; ;;;;I" Bug::Integer.cstr_term_char;F;[[I"str;T0;[[@0ti^;T;;;0;[;{;IC;" ;T;[;[;@;0; @rt;!@%d;"I"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; ; F; ;;;;I"Bug::Integer.cstr_noembed;F;[[I"str;T0;[[@0tin;T;:cstr_noembed;0;[;{;IC;" ;T;[;[;@;0; @t;!@%d;"I"/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); RBASIC(str2)->flags &= ~RSTRING_EMBED_LEN_MASK; 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; ; F; ;;;;I" Bug::Integer.cstr_embedded?;F;[[I"str;T0;[[@0ti;T;:cstr_embedded?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @t;[;@;0; @t;Mi;!@%d;"I"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; ; F; ;;;;I"#Bug::Integer.rb_str_new_frozen;F;[[I"str;T0;[[@0ti;T;:rb_str_new_frozen;0;[;{;IC;" ;T;[;[;@;0; @t;!@%d;"I"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; ; F; ;;;;I"Bug::Integer.external_new;F;[[I"len;T0[I"enc;T0;[[I"ext/-test-/string/new.c;Ti;T;:external_new;0;[;{;IC;" ;T;[;[;@;0; @t;!@%d;"I"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; ; F; ;;;;I" Bug::Integer.shared_string?;F;[[I"str;T0;[[I"#ext/-test-/string/rb_str_dup.c;Ti;T;:shared_string?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @t;[;@;0; @t;Mi;!@%d;"I"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; ; F; ;;;;I"&Bug::Integer.sharing_with_shared?;F;[[I"str;T0;[[@ti;T;:sharing_with_shared?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @t;[;@;0; @t;Mi;!@%d;"I"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; ; F; ;;;;I" Bug::Integer.encoding_index;F;[[I"str;T0;[[I"&ext/-test-/string/enc_associate.c;Ti;T;:encoding_index;0;[;{;IC;" ;T;[;[;@;0; @t;!@%d;"I"zVALUE bug_str_encoding_index(VALUE self, VALUE str) { int idx = rb_enc_get_index(str); return INT2NUM(idx); };T;#I" VALUE;T;$T;&@%d;'IC;[;&@%d;(IC;[;&@%d;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/-test-/integer/init.c;Ti;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @%d;!@;I"Bug::Integer;F;1@ 5404319552844595 d = 0.3.denominator #=> 18014398509481984 n.fdiv(d) #=> 0.3 See also Float#denominator. ;T;[o;H ;II" overload;F;J0;;;K0;#I"numerator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @u;[;I"@return [Integer];T;0; @u;@F;Mi;N0;[; @u;[;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; @u;@F;Ao;B;CT;Di;Ei;!@9u;"I"static VALUE float_numerator(VALUE self) { double d = RFLOAT_VALUE(self); VALUE r; if (isinf(d) || isnan(d)) return self; r = float_to_r(self); if (canonicalization && k_integer_p(r)) { return r; } return nurat_numerator(r); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#denominator;F;[;[[@ i);T;;;0;[;{;IC;"lReturns the denominator (always positive). The result is machine dependent. See also Float#numerator. ;T;[o;H ;II" overload;F;J0;;;K0;#I"denominator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @u;[;I"@return [Integer];T;0; @u;@F;Mi;N0;[; @u;[;I"Returns the denominator (always positive). The result is machine dependent. See also Float#numerator. @overload denominator @return [Integer];T;0; @u;@F;Ao;B;CT;Di ;Ei';!@9u;"I" static VALUE float_denominator(VALUE self) { double d = RFLOAT_VALUE(self); VALUE r; if (isinf(d) || isnan(d)) return INT2FIX(1); r = float_to_r(self); if (canonicalization && k_integer_p(r)) { return ONE; } return nurat_denominator(r); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#to_r;F;[;[[@ i;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;H ;II" overload;F;J0;;;K0;#I" to_r;T;IC;";T;[;[;I";T;0; @v;@F;Mi;N0;[; @v;[;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; @v;@F;Ao;B;CT;Di{;Ei;!@9u;"I"static VALUE float_to_r(VALUE self) { VALUE f, n; float_decode_internal(self, &f, &n); #if FLT_RADIX == 2 { long ln = FIX2LONG(n); if (ln == 0) return rb_rational_new1(f); if (ln > 0) return rb_rational_new1(rb_int_lshift(f, n)); ln = -ln; return rb_rational_new2(f, rb_int_lshift(ONE, INT2FIX(ln))); } #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; ; F; ;,;;;I"Float#rationalize;F;[[@0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"rationalize([eps]);T;IC;";T;[;[;I";T;0; @-v;@F;Mi;N0;[[I" [eps];T0; @-v;[;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; @-v;@F;Ao;B;CT;Di;Ei;!@9u;"I"lstatic VALUE float_rationalize(int argc, VALUE *argv, VALUE self) { double d = RFLOAT_VALUE(self); if (d < 0.0) return rb_rational_uminus(float_rationalize(argc, argv, DBL2NUM(-d))); if (rb_check_arity(argc, 0, 1)) { return rb_flt_rationalize_with_prec(self, argv[0]); } else { return rb_flt_rationalize(self); } };T;#I"static VALUE;T;$To;9;[[@)i;F;: ROUNDS;;;;;;[;{;IC;"-1:: Indeterminable 0:: Rounding towards zero 1:: Rounding to the nearest number 2:: Rounding towards positive infinity 3:: Rounding towards negative infinity ;T;[;[;I"-1:: Indeterminable 0:: Rounding towards zero 1:: Rounding to the nearest number 2:: Rounding towards positive infinity 3:: Rounding towards negative infinity ;T;0; @Fv;@F;Ao;B;CT;Di;Ei;!@9u;I"Float::ROUNDS;F; 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 { 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;Ao;B;CT;Di;Ei;!@9u;"I"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 { 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;#@w;$T@vo; ; F; ;,;;;I"Float#coerce;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"Returns an array with both +numeric+ and +float+ represented as Float objects. This is achieved by converting +numeric+ to a Float. 1.2.coerce(3) #=> [3.0, 1.2] 2.5.coerce(1.1) #=> [1.1, 2.5] ;T;[o;H ;II" overload;F;J0;;;K0;#I"coerce(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @w;[;I"@return [Array];T;0; @w;@F;Mi;N0;[[I" numeric;T0; @w;[;I"Returns an array with both +numeric+ and +float+ represented as Float objects. This is achieved by converting +numeric+ to a Float. 1.2.coerce(3) #=> [3.0, 1.2] 2.5.coerce(1.1) #=> [1.1, 2.5] @overload coerce(numeric) @return [Array];T;0; @w;@F;Ao;B;CT;Di;Ei;!@9u;"I"[static VALUE flo_coerce(VALUE x, VALUE y) { return rb_assoc_new(rb_Float(y), x); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Float#-@;F;[;[[@)i;T;;;;0;[;{;IC;"Returns +float+, negated. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" -float;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @$w;[;I"@return [Float];T;0; @$w;@F;Mi;N0;[; @$w;[;I"CReturns +float+, negated. @overload -float @return [Float];T;0; @$w;@F;Ao;B;CT;Di;Ei;!@9u;"I"QVALUE rb_float_uminus(VALUE flt) { return DBL2NUM(-RFLOAT_VALUE(flt)); };T;#I" VALUE;T;$To; ; F; ;,;;;I" Float#+;F;[[I"y;T0;[[@)i;T;;(;0;[;{;IC;"AReturns a new Float which is the sum of +float+ and +other+. ;T;[o;H ;II" overload;F;J0;;(;K0;#I" +(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @?w;[;I"@return [Float];T;0; @?w;@F;Mi;N0;[[I" other;T0; @?w;[;I"hReturns a new Float which is the sum of +float+ and +other+. @overload +(other) @return [Float];T;0; @?w;@F;Ao;B;CT;Di;Ei;!@9u;"I"VALUE rb_float_plus(VALUE x, VALUE y) { if (RB_TYPE_P(y, T_FIXNUM)) { return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y)); } else if (RB_TYPE_P(y, T_BIGNUM)) { return DBL2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y)); } else if (RB_TYPE_P(y, T_FLOAT)) { return DBL2NUM(RFLOAT_VALUE(x) + RFLOAT_VALUE(y)); } else { return rb_num_coerce_bin(x, y, '+'); } };T;#I" VALUE;T;$To; ; F; ;,;;;I" Float#-;F;[[I"y;T0;[[@)i;T;;<;0;[;{;IC;"HReturns a new Float which is the difference of +float+ and +other+. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" -(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @^w;[;I"@return [Float];T;0; @^w;@F;Mi;N0;[[I" other;T0; @^w;[;I"oReturns a new Float which is the difference of +float+ and +other+. @overload -(other) @return [Float];T;0; @^w;@F;Ao;B;CT;Di;Ei;!@9u;"I"static VALUE flo_minus(VALUE x, VALUE y) { if (RB_TYPE_P(y, T_FIXNUM)) { return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y)); } else if (RB_TYPE_P(y, T_BIGNUM)) { return DBL2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y)); } else if (RB_TYPE_P(y, T_FLOAT)) { return DBL2NUM(RFLOAT_VALUE(x) - RFLOAT_VALUE(y)); } else { return rb_num_coerce_bin(x, y, '-'); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Float#*;F;[[I"y;T0;[[@)i-;T;;);0;[;{;IC;"EReturns a new Float which is the product of +float+ and +other+. ;T;[o;H ;II" overload;F;J0;;);K0;#I" *(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @}w;[;I"@return [Float];T;0; @}w;@F;Mi;N0;[[I" other;T0; @}w;[;I"lReturns a new Float which is the product of +float+ and +other+. @overload *(other) @return [Float];T;0; @}w;@F;Ao;B;CT;Di&;Ei*;!@9u;"I"~VALUE rb_float_mul(VALUE x, VALUE y) { if (RB_TYPE_P(y, T_FIXNUM)) { return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y)); } else if (RB_TYPE_P(y, T_BIGNUM)) { return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y)); } else if (RB_TYPE_P(y, T_FLOAT)) { return DBL2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y)); } else { return rb_num_coerce_bin(x, y, '*'); } };T;#I" VALUE;T;$To; ; F; ;,;;;I" Float#/;F;[[I"y;T0;[[@)ic;T;;;0;[;{;IC;"LReturns a new Float which is the result of dividing +float+ by +other+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" /(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @w;[;I"@return [Float];T;0; @w;@F;Mi;N0;[[I" other;T0; @w;[;I"sReturns a new Float which is the result of dividing +float+ by +other+. @overload /(other) @return [Float];T;0; @w;@F;Ao;B;CT;Di\;Ei`;!@9u;"I"static VALUE flo_div(VALUE x, VALUE y) { double num = RFLOAT_VALUE(x); double den; double ret; if (RB_TYPE_P(y, T_FIXNUM)) { den = FIX2LONG(y); } else if (RB_TYPE_P(y, T_BIGNUM)) { den = rb_big2dbl(y); } else if (RB_TYPE_P(y, T_FLOAT)) { den = RFLOAT_VALUE(y); } else { return rb_num_coerce_bin(x, y, '/'); } ret = double_div_double(num, den); return DBL2NUM(ret); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#quo;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;";Returns float / numeric, same as Float#/. ;T;[o;H ;II" overload;F;J0;;;K0;#I"fdiv(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @w;[;I"@return [Float];T;0; @w;@F;Mi;N0;[[I" numeric;T0; @wo;H ;II" overload;F;J0;;;K0;#I"quo(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @w;[;I"@return [Float];T;0; @w;@F;Mi;N0;[[I" numeric;T0; @w;[;I"Returns float / numeric, same as Float#/. @overload fdiv(numeric) @return [Float] @overload quo(numeric) @return [Float];T;0; @w;@F;Ao;B;CT;Di{;Ei;!@9u;"I"Sstatic VALUE flo_quo(VALUE x, VALUE y) { return num_funcall1(x, '/', y); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#fdiv;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;";Returns float / numeric, same as Float#/. ;T;[o;H ;II" overload;F;J0;;;K0;#I"fdiv(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @w;[;I"@return [Float];T;0; @w;@F;Mi;N0;[[I" numeric;T0; @wo;H ;II" overload;F;J0;;;K0;#I"quo(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @w;[;I"@return [Float];T;0; @w;@F;Mi;N0;[[I" numeric;T0; @w;[;@w;0; @w;@F;Ao;B;CT;Di{;Ei;!@9u;"I"Sstatic VALUE flo_quo(VALUE x, VALUE y) { return num_funcall1(x, '/', y); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Float#%;F;[[I"y;T0;[[@)i;T;;*;0;[;{;IC;"Returns the modulo after division of +float+ by +other+. 6543.21.modulo(137) #=> 104.21000000000004 6543.21.modulo(137.24) #=> 92.92999999999961 ;T;[o;H ;II" overload;F;J0;;*;K0;#I" %(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @x;[;I"@return [Float];T;0; @x;@F;Mi;N0;[[I" other;T0; @xo;H ;II" overload;F;J0;;;K0;#I"modulo(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @x;[;I"@return [Float];T;0; @x;@F;Mi;N0;[[I" other;T0; @x;[;I"Returns the modulo after division of +float+ by +other+. 6543.21.modulo(137) #=> 104.21000000000004 6543.21.modulo(137.24) #=> 92.92999999999961 @overload %(other) @return [Float] @overload modulo(other) @return [Float];T;0; @x;@F;Ao;B;CT;Di;Ei;!@9u;"I"rstatic VALUE flo_mod(VALUE x, VALUE y) { double fy; if (RB_TYPE_P(y, T_FIXNUM)) { fy = (double)FIX2LONG(y); } else if (RB_TYPE_P(y, T_BIGNUM)) { fy = rb_big2dbl(y); } else if (RB_TYPE_P(y, T_FLOAT)) { 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; ; F; ;,;;;I"Float#modulo;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"Returns the modulo after division of +float+ by +other+. 6543.21.modulo(137) #=> 104.21000000000004 6543.21.modulo(137.24) #=> 92.92999999999961 ;T;[o;H ;II" overload;F;J0;;*;K0;#I" %(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @Dx;[;I"@return [Float];T;0; @Dx;@F;Mi;N0;[[I" other;T0; @Dxo;H ;II" overload;F;J0;;;K0;#I"modulo(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @Dx;[;I"@return [Float];T;0; @Dx;@F;Mi;N0;[[I" other;T0; @Dx;[;@@x;0; @Dx;@F;Ao;B;CT;Di;Ei;!@9u;"I"rstatic VALUE flo_mod(VALUE x, VALUE y) { double fy; if (RB_TYPE_P(y, T_FIXNUM)) { fy = (double)FIX2LONG(y); } else if (RB_TYPE_P(y, T_BIGNUM)) { fy = rb_big2dbl(y); } else if (RB_TYPE_P(y, T_FLOAT)) { 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; ; F; ;,;;;I"Float#divmod;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"[See Numeric#divmod. 42.0.divmod(6) #=> [7, 0.0] 42.0.divmod(5) #=> [8, 2.0] ;T;[o;H ;II" overload;F;J0;;;K0;#I"divmod(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @qx;[;I"@return [Array];T;0; @qx;@F;Mi;N0;[[I" numeric;T0; @qx;[;I"See Numeric#divmod. 42.0.divmod(6) #=> [7, 0.0] 42.0.divmod(5) #=> [8, 2.0] @overload divmod(numeric) @return [Array];T;0; @qx;@F;Ao;B;CT;Di;Ei;!@9u;"I"static VALUE flo_divmod(VALUE x, VALUE y) { double fy, div, mod; volatile VALUE a, b; if (RB_TYPE_P(y, T_FIXNUM)) { fy = (double)FIX2LONG(y); } else if (RB_TYPE_P(y, T_BIGNUM)) { fy = rb_big2dbl(y); } else if (RB_TYPE_P(y, T_FLOAT)) { 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; ; F; ;,;;;I" Float#**;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"ARaises +float+ to the power of +other+. 2.0**3 #=> 8.0 ;T;[o;H ;II" overload;F;J0;;;K0;#I"**(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @x;[;I"@return [Float];T;0; @x;@F;Mi;N0;[[I" other;T0; @x;[;I"iRaises +float+ to the power of +other+. 2.0**3 #=> 8.0 @overload **(other) @return [Float];T;0; @x;@F;Ao;B;CT;Di;Ei ;!@9u;"I"VALUE rb_float_pow(VALUE x, VALUE y) { double dx, dy; if (RB_TYPE_P(y, T_FIXNUM)) { dx = RFLOAT_VALUE(x); dy = (double)FIX2LONG(y); } else if (RB_TYPE_P(y, T_BIGNUM)) { dx = RFLOAT_VALUE(x); dy = rb_big2dbl(y); } else if (RB_TYPE_P(y, T_FLOAT)) { 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; ; F; ;,;;;I" Float#==;F;[;[;F;;S;;0;[;{;IC;" ;T;[;[;@;0; @x;!@9u;$To; ; F; ;,;;;I"Float#===;F;[;[;F;;O;;0;[;{;IC;" ;T;[;[;@;0; @x;!@9u;$To; ; F; ;,;;;I"Float#<=>;F;[[I"y;T0;[[@)i;T;;V;0;[;{;IC;":Returns -1, 0, or +1 depending on whether +float+ is less than, equal to, or greater than +real+. This is the basis for the tests in the Comparable module. The result of NaN <=> NaN is undefined, so an implementation-dependent value is returned. +nil+ is returned if the two values are incomparable. ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @x;[;I" @return [ -1, 0, +1, nil];T;0; @x;@F;Mi;N0;[[I" real;T0; @x;[;I"nReturns -1, 0, or +1 depending on whether +float+ is less than, equal to, or greater than +real+. This is the basis for the tests in the Comparable module. The result of NaN <=> NaN is undefined, so an implementation-dependent value is returned. +nil+ is returned if the two values are incomparable. @overload <=>(real) @return [ -1, 0, +1, nil];T;0; @x;@F;Ao;B;CT;Di;Ei;!@9u;"I"static VALUE flo_cmp(VALUE x, VALUE y) { double a, b; VALUE i; a = RFLOAT_VALUE(x); if (isnan(a)) return Qnil; if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return INT2FIX(-FIX2INT(rel)); return rel; } else if (RB_TYPE_P(y, T_FLOAT)) { 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; ; F; ;,;;;I" Float#>;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"Returns +true+ if +float+ is greater than +real+. The result of NaN > NaN is undefined, so an implementation-dependent value is returned. ;T;[o;H ;II" overload;F;J0;;;K0;#I" >(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @x;[;I"@return [Boolean];T;0; @x;@F;Mi;N0;[[I" real;T0; @x;[;I"Returns +true+ if +float+ is greater than +real+. The result of NaN > NaN is undefined, so an implementation-dependent value is returned. @overload >(real) @return [Boolean];T;0; @x;@F;Ao;B;CT;Di;Ei;!@9u;"I"hVALUE rb_float_gt(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return -FIX2INT(rel) > 0 ? Qtrue : Qfalse; return Qfalse; } else if (RB_TYPE_P(y, T_FLOAT)) { b = RFLOAT_VALUE(y); #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, '>'); } #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(a)) return Qfalse; #endif return (a > b)?Qtrue:Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I" Float#>=;F;[[I"y;T0;[[@)i;T;;;0;[;{;IC;"Returns +true+ if +float+ is greater than or equal to +real+. The result of NaN >= NaN is undefined, so an implementation-dependent value is returned. ;T;[o;H ;II" overload;F;J0;;;K0;#I" >=(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @y;[;I"@return [Boolean];T;0; @y;@F;Mi;N0;[[I" real;T0; @y;[;I"Returns +true+ if +float+ is greater than or equal to +real+. The result of NaN >= NaN is undefined, so an implementation-dependent value is returned. @overload >=(real) @return [Boolean];T;0; @y;@F;Ao;B;CT;Di;Ei;!@9u;"I"mstatic VALUE flo_ge(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return -FIX2INT(rel) >= 0 ? Qtrue : Qfalse; return Qfalse; } else if (RB_TYPE_P(y, T_FLOAT)) { b = RFLOAT_VALUE(y); #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, idGE); } #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(a)) return Qfalse; #endif return (a >= b)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Float#<;F;[[I"y;T0;[[@)i%;T;;;0;[;{;IC;"Returns +true+ if +float+ is less than +real+. The result of NaN < NaN is undefined, so an implementation-dependent value is returned. ;T;[o;H ;II" overload;F;J0;;;K0;#I" <(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @!y;[;I"@return [Boolean];T;0; @!y;@F;Mi;N0;[[I" real;T0; @!y;[;I"Returns +true+ if +float+ is less than +real+. The result of NaN < NaN is undefined, so an implementation-dependent value is returned. @overload <(real) @return [Boolean];T;0; @!y;@F;Ao;B;CT;Di;Ei";!@9u;"I"jstatic VALUE flo_lt(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return -FIX2INT(rel) < 0 ? Qtrue : Qfalse; return Qfalse; } else if (RB_TYPE_P(y, T_FLOAT)) { b = RFLOAT_VALUE(y); #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, '<'); } #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(a)) return Qfalse; #endif return (a < b)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Float#<=;F;[[I"y;T0;[[@)iJ;T;;;0;[;{;IC;"Returns +true+ if +float+ is less than or equal to +real+. The result of NaN <= NaN is undefined, so an implementation-dependent value is returned. ;T;[o;H ;II" overload;F;J0;;;K0;#I" <=(real);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @@y;[;I"@return [Boolean];T;0; @@y;@F;Mi;N0;[[I" real;T0; @@y;[;I"Returns +true+ if +float+ is less than or equal to +real+. The result of NaN <= NaN is undefined, so an implementation-dependent value is returned. @overload <=(real) @return [Boolean];T;0; @@y;@F;Ao;B;CT;Di@;EiG;!@9u;"I"mstatic VALUE flo_le(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return -FIX2INT(rel) <= 0 ? Qtrue : Qfalse; return Qfalse; } else if (RB_TYPE_P(y, T_FLOAT)) { b = RFLOAT_VALUE(y); #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, idLE); } #if defined(_MSC_VER) && _MSC_VER < 1300 if (isnan(a)) return Qfalse; #endif return (a <= b)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#eql?;F;[;[;F;;R;;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @_y;[;@;0; @_y;Mi;!@9u;$To; ; F; ;,;;;I"Float#hash;F;[;[[@)i;T;;U;0;[;{;IC;"?Returns a hash code for this float. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ky;[;I"@return [Integer];T;0; @ky;@F;Mi;N0;[; @ky;[;I"dReturns a hash code for this float. See also Object#hash. @overload hash @return [Integer];T;0; @ky;@F;Ao;B;CT;Di~;Ei;!@9u;"I"Tstatic VALUE flo_hash(VALUE num) { return rb_dbl_hash(RFLOAT_VALUE(num)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#to_f;F;[;[[@)i;T;;>;0;[;{;IC;"6Since +float+ is already a Float, returns +self+. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" to_f;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @y;[;I"@return [self];T;0; @y;@F;Mi;N0;[; @y;[;I"XSince +float+ is already a Float, returns +self+. @overload to_f @return [self];T;0; @y;@F;Ao;B;CT;Di;Ei;!@9u;"I"9static VALUE flo_to_f(VALUE num) { return num; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#abs;F;[;[[@)i;T;;;0;[;{;IC;"Returns the absolute value of +float+. (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 34.56.abs #=> 34.56 Float#magnitude is an alias for Float#abs. ;T;[o;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @y;[;I"@return [Float];T;0; @y;@F;Mi;N0;[; @yo;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @y;[;I"@return [Float];T;0; @y;@F;Mi;N0;[; @y;[;I"Returns the absolute value of +float+. (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 34.56.abs #=> 34.56 Float#magnitude is an alias for Float#abs. @overload abs @return [Float] @overload magnitude @return [Float];T;0; @y;@F;Ao;B;CT;Di;Ei;!@9u;"I"iVALUE rb_float_abs(VALUE flt) { double val = fabs(RFLOAT_VALUE(flt)); return DBL2NUM(val); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Float#magnitude;F;[;[[@)i;T;;;0;[;{;IC;"Returns the absolute value of +float+. (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 34.56.abs #=> 34.56 Float#magnitude is an alias for Float#abs. ;T;[o;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @y;[;I"@return [Float];T;0; @y;@F;Mi;N0;[; @yo;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @y;[;I"@return [Float];T;0; @y;@F;Mi;N0;[; @y;[;@y;0; @y;@F;Ao;B;CT;Di;Ei;!@9u;"I"iVALUE rb_float_abs(VALUE flt) { double val = fabs(RFLOAT_VALUE(flt)); return DBL2NUM(val); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Float#zero?;F;[;[[@)i;T;;;0;[;{;IC;"&Returns +true+ if +float+ is 0.0.;T;[o;H ;II" overload;F;J0;;;K0;#I" zero?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @y;[;I"@return [Boolean];T;0; @y;@F;Mi;N0;[; @y;[;I"LReturns +true+ if +float+ is 0.0. @overload zero? @return [Boolean];T;0; @y;@F;Ao;B;CT;Di;Ei;Mi;!@9u;"I"Xstatic VALUE flo_zero_p(VALUE num) { return flo_iszero(num) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#to_i;F;[;[[@)i) ;T;;=;0;[;{;IC;"Returns the +float+ truncated to an Integer. 1.2.to_i #=> 1 (-1.2).to_i #=> -1 Note that the limited precision of floating point arithmetic might lead to surprising results: (0.3 / 0.1).to_i #=> 2 (!) #to_int is an alias for #to_i. ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ z;[;I"@return [Integer];T;0; @ z;@F;Mi;N0;[; @ zo;H ;II" overload;F;J0;;;K0;#I" to_int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ z;[;I"@return [Integer];T;0; @ z;@F;Mi;N0;[; @ z;[;I"EReturns the +float+ truncated to an Integer. 1.2.to_i #=> 1 (-1.2).to_i #=> -1 Note that the limited precision of floating point arithmetic might lead to surprising results: (0.3 / 0.1).to_i #=> 2 (!) #to_int is an alias for #to_i. @overload to_i @return [Integer] @overload to_int @return [Integer];T;0; @ z;@F;Ao;B;CT;Di ;Ei' ;!@9u;"I"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; ; F; ;,;;;I"Float#to_int;F;[;[[@)i) ;T;;;0;[;{;IC;"Returns the +float+ truncated to an Integer. 1.2.to_i #=> 1 (-1.2).to_i #=> -1 Note that the limited precision of floating point arithmetic might lead to surprising results: (0.3 / 0.1).to_i #=> 2 (!) #to_int is an alias for #to_i. ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @3z;[;I"@return [Integer];T;0; @3z;@F;Mi;N0;[; @3zo;H ;II" overload;F;J0;;;K0;#I" to_int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @3z;[;I"@return [Integer];T;0; @3z;@F;Mi;N0;[; @3z;[;@/z;0; @3z;@F;Ao;B;CT;Di ;Ei' ;!@9u;"I"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; ; F; ;,;;;I"Float#floor;F;[[@0;[[@)i;T;;;0;[;{;IC;"Returns the largest number less than or equal to +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 1.2.floor #=> 1 2.0.floor #=> 2 (-1.2).floor #=> -2 (-2.0).floor #=> -2 1.234567.floor(2) #=> 1.23 1.234567.floor(3) #=> 1.234 1.234567.floor(4) #=> 1.2345 1.234567.floor(5) #=> 1.23456 34567.89.floor(-5) #=> 0 34567.89.floor(-4) #=> 30000 34567.89.floor(-3) #=> 34000 34567.89.floor(-2) #=> 34500 34567.89.floor(-1) #=> 34560 34567.89.floor(0) #=> 34567 34567.89.floor(1) #=> 34567.8 34567.89.floor(2) #=> 34567.89 34567.89.floor(3) #=> 34567.89 Note that the limited precision of floating point arithmetic might lead to surprising results: (0.3 / 0.1).floor #=> 2 (!) ;T;[o;H ;II" overload;F;J0;;;K0;#I"floor([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @Zz;[;I"@return [Integer, Float];T;0; @Zz;@F;Mi;N0;[[I"[ndigits];T0; @Zz;[;I"Returns the largest number less than or equal to +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 1.2.floor #=> 1 2.0.floor #=> 2 (-1.2).floor #=> -2 (-2.0).floor #=> -2 1.234567.floor(2) #=> 1.23 1.234567.floor(3) #=> 1.234 1.234567.floor(4) #=> 1.2345 1.234567.floor(5) #=> 1.23456 34567.89.floor(-5) #=> 0 34567.89.floor(-4) #=> 30000 34567.89.floor(-3) #=> 34000 34567.89.floor(-2) #=> 34500 34567.89.floor(-1) #=> 34560 34567.89.floor(0) #=> 34567 34567.89.floor(1) #=> 34567.8 34567.89.floor(2) #=> 34567.89 34567.89.floor(3) #=> 34567.89 Note that the limited precision of floating point arithmetic might lead to surprising results: (0.3 / 0.1).floor #=> 2 (!) @overload floor([ndigits]) @return [Integer, Float];T;0; @Zz;@F;Ao;B;CT;Dif;Ei;!@9u;"I"static VALUE flo_floor(int argc, VALUE *argv, VALUE num) { double number, f; int ndigits = 0; if (rb_check_arity(argc, 0, 1)) { ndigits = NUM2INT(argv[0]); } number = RFLOAT_VALUE(num); if (number == 0.0) { return ndigits > 0 ? DBL2NUM(number) : INT2FIX(0); } if (ndigits > 0) { int binexp; frexp(number, &binexp); if (float_round_overflow(ndigits, binexp)) return num; if (number > 0.0 && float_round_underflow(ndigits, binexp)) return DBL2NUM(0.0); f = pow(10, ndigits); f = floor(number * f) / f; return DBL2NUM(f); } else { num = dbl2ival(floor(number)); if (ndigits < 0) num = rb_int_floor(num, ndigits); return num; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#ceil;F;[[@0;[[@)i;T;;;0;[;{;IC;"Returns the smallest number greater than or equal to +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 1.2.ceil #=> 2 2.0.ceil #=> 2 (-1.2).ceil #=> -1 (-2.0).ceil #=> -2 1.234567.ceil(2) #=> 1.24 1.234567.ceil(3) #=> 1.235 1.234567.ceil(4) #=> 1.2346 1.234567.ceil(5) #=> 1.23457 34567.89.ceil(-5) #=> 100000 34567.89.ceil(-4) #=> 40000 34567.89.ceil(-3) #=> 35000 34567.89.ceil(-2) #=> 34600 34567.89.ceil(-1) #=> 34570 34567.89.ceil(0) #=> 34568 34567.89.ceil(1) #=> 34567.9 34567.89.ceil(2) #=> 34567.89 34567.89.ceil(3) #=> 34567.89 Note that the limited precision of floating point arithmetic might lead to surprising results: (2.1 / 0.7).ceil #=> 4 (!) ;T;[o;H ;II" overload;F;J0;;;K0;#I"ceil([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @yz;[;I"@return [Integer, Float];T;0; @yz;@F;Mi;N0;[[I"[ndigits];T0; @yz;[;I"Returns the smallest number greater than or equal to +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 1.2.ceil #=> 2 2.0.ceil #=> 2 (-1.2).ceil #=> -1 (-2.0).ceil #=> -2 1.234567.ceil(2) #=> 1.24 1.234567.ceil(3) #=> 1.235 1.234567.ceil(4) #=> 1.2346 1.234567.ceil(5) #=> 1.23457 34567.89.ceil(-5) #=> 100000 34567.89.ceil(-4) #=> 40000 34567.89.ceil(-3) #=> 35000 34567.89.ceil(-2) #=> 34600 34567.89.ceil(-1) #=> 34570 34567.89.ceil(0) #=> 34568 34567.89.ceil(1) #=> 34567.9 34567.89.ceil(2) #=> 34567.89 34567.89.ceil(3) #=> 34567.89 Note that the limited precision of floating point arithmetic might lead to surprising results: (2.1 / 0.7).ceil #=> 4 (!) @overload ceil([ndigits]) @return [Integer, Float];T;0; @yz;@F;Ao;B;CT;Di;Ei;!@9u;"I"static VALUE flo_ceil(int argc, VALUE *argv, VALUE num) { double number, f; int ndigits = 0; if (rb_check_arity(argc, 0, 1)) { ndigits = NUM2INT(argv[0]); } number = RFLOAT_VALUE(num); if (number == 0.0) { return ndigits > 0 ? DBL2NUM(number) : INT2FIX(0); } if (ndigits > 0) { int binexp; frexp(number, &binexp); if (float_round_overflow(ndigits, binexp)) return num; if (number < 0.0 && float_round_underflow(ndigits, binexp)) return DBL2NUM(0.0); f = pow(10, ndigits); f = ceil(number * f) / f; return DBL2NUM(f); } else { num = dbl2ival(ceil(number)); if (ndigits < 0) num = rb_int_ceil(num, ndigits); return num; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#round;F;[[@0;[[@)i;T;;E;0;[;{;IC;"Returns +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 1.4.round #=> 1 1.5.round #=> 2 1.6.round #=> 2 (-1.5).round #=> -2 1.234567.round(2) #=> 1.23 1.234567.round(3) #=> 1.235 1.234567.round(4) #=> 1.2346 1.234567.round(5) #=> 1.23457 34567.89.round(-5) #=> 0 34567.89.round(-4) #=> 30000 34567.89.round(-3) #=> 35000 34567.89.round(-2) #=> 34600 34567.89.round(-1) #=> 34570 34567.89.round(0) #=> 34568 34567.89.round(1) #=> 34567.9 34567.89.round(2) #=> 34567.89 34567.89.round(3) #=> 34567.89 If the optional +half+ keyword argument is given, numbers that are half-way between two possible rounded values will be rounded according to the specified tie-breaking +mode+: * :up or +nil+: round half away from zero (default) * :down: round half toward zero * :even: round half toward the nearest even number 2.5.round(half: :up) #=> 3 2.5.round(half: :down) #=> 2 2.5.round(half: :even) #=> 2 3.5.round(half: :up) #=> 4 3.5.round(half: :down) #=> 3 3.5.round(half: :even) #=> 4 (-2.5).round(half: :up) #=> -3 (-2.5).round(half: :down) #=> -2 (-2.5).round(half: :even) #=> -2 ;T;[o;H ;II" overload;F;J0;;E;K0;#I"$round([ndigits] [, half: mode]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @z;[;I"@return [Integer, Float];T;0; @z;@F;Mi;N0;[[I"[ndigits][, half:;TI" mode];T; @z;[;I"8Returns +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 1.4.round #=> 1 1.5.round #=> 2 1.6.round #=> 2 (-1.5).round #=> -2 1.234567.round(2) #=> 1.23 1.234567.round(3) #=> 1.235 1.234567.round(4) #=> 1.2346 1.234567.round(5) #=> 1.23457 34567.89.round(-5) #=> 0 34567.89.round(-4) #=> 30000 34567.89.round(-3) #=> 35000 34567.89.round(-2) #=> 34600 34567.89.round(-1) #=> 34570 34567.89.round(0) #=> 34568 34567.89.round(1) #=> 34567.9 34567.89.round(2) #=> 34567.89 34567.89.round(3) #=> 34567.89 If the optional +half+ keyword argument is given, numbers that are half-way between two possible rounded values will be rounded according to the specified tie-breaking +mode+: * :up or +nil+: round half away from zero (default) * :down: round half toward zero * :even: round half toward the nearest even number 2.5.round(half: :up) #=> 3 2.5.round(half: :down) #=> 2 2.5.round(half: :even) #=> 2 3.5.round(half: :up) #=> 4 3.5.round(half: :down) #=> 3 3.5.round(half: :even) #=> 4 (-2.5).round(half: :up) #=> -3 (-2.5).round(half: :down) #=> -2 (-2.5).round(half: :even) #=> -2 @overload round([ndigits] [, half: mode]) @return [Integer, Float];T;0; @z;@F;Ao;B;CT;Di;Ei;!@9u;"I"rstatic 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); f = pow(10, ndigits); x = ROUND_CALL(mode, round, (number, f)); return DBL2NUM(x / f); } return num; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#truncate;F;[[@0;[[@)iK ;T;;;0;[;{;IC;"AReturns +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 2.8.truncate #=> 2 (-2.8).truncate #=> -2 1.234567.truncate(2) #=> 1.23 34567.89.truncate(-2) #=> 34500 Note that the limited precision of floating point arithmetic might lead to surprising results: (0.3 / 0.1).truncate #=> 2 (!) ;T;[o;H ;II" overload;F;J0;;;K0;#I"truncate([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI" Float;T; @z;[;I"@return [Integer, Float];T;0; @z;@F;Mi;N0;[[I"[ndigits];T0; @z;[;I"|Returns +float+ 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 floating point number when +ndigits+ is positive, otherwise returns an integer. 2.8.truncate #=> 2 (-2.8).truncate #=> -2 1.234567.truncate(2) #=> 1.23 34567.89.truncate(-2) #=> 34500 Note that the limited precision of floating point arithmetic might lead to surprising results: (0.3 / 0.1).truncate #=> 2 (!) @overload truncate([ndigits]) @return [Integer, Float];T;0; @z;@F;Ao;B;CT;Di4 ;EiI ;!@9u;"I"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; ; F; ;,;;;I"Float#nan?;F;[;[[@)i;T;: nan?;0;[;{;IC;"Returns +true+ if +float+ is an invalid IEEE floating point number. a = -1.0 #=> -1.0 a.nan? #=> false a = 0.0/0.0 #=> NaN a.nan? #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I" nan?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @z;[;I"@return [Boolean];T;0; @z;@F;Mi;N0;[; @z;[;I"Returns +true+ if +float+ is an invalid IEEE floating point number. a = -1.0 #=> -1.0 a.nan? #=> false a = 0.0/0.0 #=> NaN a.nan? #=> true @overload nan? @return [Boolean];T;0; @z;@F;Ao;B;CT;Di;Ei;Mi;!@9u;"I"~static VALUE flo_is_nan_p(VALUE num) { double value = RFLOAT_VALUE(num); return isnan(value) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#infinite?;F;[;[[@i;T;;;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @z;[;@;0; @z;Mi;!@9u;"I"+VALUE rb_flo_is_infinite_p(VALUE num);;T;#I"+VALUE rb_flo_is_infinite_p(VALUE num);;T;$To; ; F; ;,;;;I"Float#finite?;F;[;[[@i;T;;;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @{;[;@;0; @{;Mi;!@9u;"I")VALUE rb_flo_is_finite_p(VALUE num);;T;#I")VALUE rb_flo_is_finite_p(VALUE num);;T;$To; ; F; ;,;;;I"Float#next_float;F;[;[[@)i*;T;:next_float;0;[;{;IC;"EReturns the next representable floating point number. Float::MAX.next_float and Float::INFINITY.next_float is Float::INFINITY. Float::NAN.next_float is Float::NAN. For example: 0.01.next_float #=> 0.010000000000000002 1.0.next_float #=> 1.0000000000000002 100.0.next_float #=> 100.00000000000001 0.01.next_float - 0.01 #=> 1.734723475976807e-18 1.0.next_float - 1.0 #=> 2.220446049250313e-16 100.0.next_float - 100.0 #=> 1.4210854715202004e-14 f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.next_float } #=> 0x1.47ae147ae147bp-7 0.01 # 0x1.47ae147ae147cp-7 0.010000000000000002 # 0x1.47ae147ae147dp-7 0.010000000000000004 # 0x1.47ae147ae147ep-7 0.010000000000000005 # 0x1.47ae147ae147fp-7 0.010000000000000007 # 0x1.47ae147ae148p-7 0.010000000000000009 # 0x1.47ae147ae1481p-7 0.01000000000000001 # 0x1.47ae147ae1482p-7 0.010000000000000012 # 0x1.47ae147ae1483p-7 0.010000000000000014 # 0x1.47ae147ae1484p-7 0.010000000000000016 # 0x1.47ae147ae1485p-7 0.010000000000000018 # 0x1.47ae147ae1486p-7 0.01000000000000002 # 0x1.47ae147ae1487p-7 0.010000000000000021 # 0x1.47ae147ae1488p-7 0.010000000000000023 # 0x1.47ae147ae1489p-7 0.010000000000000024 # 0x1.47ae147ae148ap-7 0.010000000000000026 # 0x1.47ae147ae148bp-7 0.010000000000000028 # 0x1.47ae147ae148cp-7 0.01000000000000003 # 0x1.47ae147ae148dp-7 0.010000000000000031 # 0x1.47ae147ae148ep-7 0.010000000000000033 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. ;T;[o;H ;II" overload;F;J0;;;K0;#I"next_float;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @{;[;I"@return [Float];T;0; @{;@F;Mi;N0;[; @{;[;I"nReturns the next representable floating point number. Float::MAX.next_float and Float::INFINITY.next_float is Float::INFINITY. Float::NAN.next_float is Float::NAN. For example: 0.01.next_float #=> 0.010000000000000002 1.0.next_float #=> 1.0000000000000002 100.0.next_float #=> 100.00000000000001 0.01.next_float - 0.01 #=> 1.734723475976807e-18 1.0.next_float - 1.0 #=> 2.220446049250313e-16 100.0.next_float - 100.0 #=> 1.4210854715202004e-14 f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.next_float } #=> 0x1.47ae147ae147bp-7 0.01 # 0x1.47ae147ae147cp-7 0.010000000000000002 # 0x1.47ae147ae147dp-7 0.010000000000000004 # 0x1.47ae147ae147ep-7 0.010000000000000005 # 0x1.47ae147ae147fp-7 0.010000000000000007 # 0x1.47ae147ae148p-7 0.010000000000000009 # 0x1.47ae147ae1481p-7 0.01000000000000001 # 0x1.47ae147ae1482p-7 0.010000000000000012 # 0x1.47ae147ae1483p-7 0.010000000000000014 # 0x1.47ae147ae1484p-7 0.010000000000000016 # 0x1.47ae147ae1485p-7 0.010000000000000018 # 0x1.47ae147ae1486p-7 0.01000000000000002 # 0x1.47ae147ae1487p-7 0.010000000000000021 # 0x1.47ae147ae1488p-7 0.010000000000000023 # 0x1.47ae147ae1489p-7 0.010000000000000024 # 0x1.47ae147ae148ap-7 0.010000000000000026 # 0x1.47ae147ae148bp-7 0.010000000000000028 # 0x1.47ae147ae148cp-7 0.01000000000000003 # 0x1.47ae147ae148dp-7 0.010000000000000031 # 0x1.47ae147ae148ep-7 0.010000000000000033 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. @overload next_float @return [Float];T;0; @{;@F;Ao;B;CT;Di;Ei(;!@9u;"I"static VALUE flo_next_float(VALUE vx) { double x, y; x = NUM2DBL(vx); y = nextafter(x, HUGE_VAL); return DBL2NUM(y); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#prev_float;F;[;[[@)i];T;:prev_float;0;[;{;IC;"Returns the previous representable floating point number. (-Float::MAX).prev_float and (-Float::INFINITY).prev_float is -Float::INFINITY. Float::NAN.prev_float is Float::NAN. For example: 0.01.prev_float #=> 0.009999999999999998 1.0.prev_float #=> 0.9999999999999999 100.0.prev_float #=> 99.99999999999999 0.01 - 0.01.prev_float #=> 1.734723475976807e-18 1.0 - 1.0.prev_float #=> 1.1102230246251565e-16 100.0 - 100.0.prev_float #=> 1.4210854715202004e-14 f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.prev_float } #=> 0x1.47ae147ae147bp-7 0.01 # 0x1.47ae147ae147ap-7 0.009999999999999998 # 0x1.47ae147ae1479p-7 0.009999999999999997 # 0x1.47ae147ae1478p-7 0.009999999999999995 # 0x1.47ae147ae1477p-7 0.009999999999999993 # 0x1.47ae147ae1476p-7 0.009999999999999992 # 0x1.47ae147ae1475p-7 0.00999999999999999 # 0x1.47ae147ae1474p-7 0.009999999999999988 # 0x1.47ae147ae1473p-7 0.009999999999999986 # 0x1.47ae147ae1472p-7 0.009999999999999985 # 0x1.47ae147ae1471p-7 0.009999999999999983 # 0x1.47ae147ae147p-7 0.009999999999999981 # 0x1.47ae147ae146fp-7 0.00999999999999998 # 0x1.47ae147ae146ep-7 0.009999999999999978 # 0x1.47ae147ae146dp-7 0.009999999999999976 # 0x1.47ae147ae146cp-7 0.009999999999999974 # 0x1.47ae147ae146bp-7 0.009999999999999972 # 0x1.47ae147ae146ap-7 0.00999999999999997 # 0x1.47ae147ae1469p-7 0.009999999999999969 # 0x1.47ae147ae1468p-7 0.009999999999999967 ;T;[o;H ;II" overload;F;J0;;;K0;#I"prev_float;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @+{;[;I"@return [Float];T;0; @+{;@F;Mi;N0;[; @+{;[;I" Returns the previous representable floating point number. (-Float::MAX).prev_float and (-Float::INFINITY).prev_float is -Float::INFINITY. Float::NAN.prev_float is Float::NAN. For example: 0.01.prev_float #=> 0.009999999999999998 1.0.prev_float #=> 0.9999999999999999 100.0.prev_float #=> 99.99999999999999 0.01 - 0.01.prev_float #=> 1.734723475976807e-18 1.0 - 1.0.prev_float #=> 1.1102230246251565e-16 100.0 - 100.0.prev_float #=> 1.4210854715202004e-14 f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.prev_float } #=> 0x1.47ae147ae147bp-7 0.01 # 0x1.47ae147ae147ap-7 0.009999999999999998 # 0x1.47ae147ae1479p-7 0.009999999999999997 # 0x1.47ae147ae1478p-7 0.009999999999999995 # 0x1.47ae147ae1477p-7 0.009999999999999993 # 0x1.47ae147ae1476p-7 0.009999999999999992 # 0x1.47ae147ae1475p-7 0.00999999999999999 # 0x1.47ae147ae1474p-7 0.009999999999999988 # 0x1.47ae147ae1473p-7 0.009999999999999986 # 0x1.47ae147ae1472p-7 0.009999999999999985 # 0x1.47ae147ae1471p-7 0.009999999999999983 # 0x1.47ae147ae147p-7 0.009999999999999981 # 0x1.47ae147ae146fp-7 0.00999999999999998 # 0x1.47ae147ae146ep-7 0.009999999999999978 # 0x1.47ae147ae146dp-7 0.009999999999999976 # 0x1.47ae147ae146cp-7 0.009999999999999974 # 0x1.47ae147ae146bp-7 0.009999999999999972 # 0x1.47ae147ae146ap-7 0.00999999999999997 # 0x1.47ae147ae1469p-7 0.009999999999999969 # 0x1.47ae147ae1468p-7 0.009999999999999967 @overload prev_float @return [Float];T;0; @+{;@F;Ao;B;CT;Di3;Ei[;!@9u;"I"static VALUE flo_prev_float(VALUE vx) { double x, y; x = NUM2DBL(vx); y = nextafter(x, -HUGE_VAL); return DBL2NUM(y); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#positive?;F;[;[[@)i[ ;T;;;0;[;{;IC;"1Returns +true+ if +float+ is greater than 0.;T;[o;H ;II" overload;F;J0;;;K0;#I"positive?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @F{;[;I"@return [Boolean];T;0; @F{;@F;Mi;N0;[; @F{;[;I"[Returns +true+ if +float+ is greater than 0. @overload positive? @return [Boolean];T;0; @F{;@F;Ao;B;CT;DiT ;EiX ;Mi;!@9u;"I"vstatic VALUE flo_positive_p(VALUE num) { double f = RFLOAT_VALUE(num); return f > 0.0 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Float#negative?;F;[;[[@)ii ;T;;;0;[;{;IC;".Returns +true+ if +float+ is less than 0.;T;[o;H ;II" overload;F;J0;;;K0;#I"negative?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @a{;[;I"@return [Boolean];T;0; @a{;@F;Mi;N0;[; @a{;[;I"XReturns +true+ if +float+ is less than 0. @overload negative? @return [Boolean];T;0; @a{;@F;Ao;B;CT;Dib ;Eif ;Mi;!@9u;"I"vstatic VALUE flo_negative_p(VALUE num) { double f = RFLOAT_VALUE(num); return f < 0.0 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$T;&@9u;'IC;[;&@9u;(IC;[;&@9u;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@v;h;.[;[[@)im[@)i;T;;/;;0;;;[;{;IC;"****************************************************************** Float objects represent inexact real numbers 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: - http://docs.sun.com/source/806-3568/ncg_goldberg.html - https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#floats_imprecise - http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems;T;[;[;I"****************************************************************** Float objects represent inexact real numbers 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: - http://docs.sun.com/source/806-3568/ncg_goldberg.html - https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#floats_imprecise - http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems ;T;0; @9u;@F;Ao;B;CT;Dim;Eiy;Mi;!@;I" Float;F;1@m@Edo; ;IC;[;&@{;'IC;[;&@{;(IC;[;&@{;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@)i[@)iS;T;:ZeroDivisionError;;0;;;[;{;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; @{;@F;Ao;B;CT;Di;Ei;!@;I"ZeroDivisionError;F;1o;2 ;30;40;50;;;!@;7@7;F;o; ;IC;[;&@{;'IC;[;&@{;(IC;[;&@{;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@)i[@)iT;T;:FloatDomainError;;0;;;[;{;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; @{;@F;Ao;B;CT;Di;Ei;!@;I"FloatDomainError;F;1o;2 ;30;40;50;:RangeError;!@;7o; ;IC;[;&@{;'IC;[;&@{;(IC;[;&@{;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iu[@i ;T;;;;0;;;[;{;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; @{;@F;Ao;B;CT;Diu;Ei};!@;I"RangeError;F;1@7;F;@mo; ;IC;[o; ; F; ;,;;;I"Process#argv0;F;[;[[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;H ;II" overload;F;J0;;;K0;#I" argv0;T;IC;";T;[;[;I";T;0; @{;@F;Mi;N0;[; @{;[;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;N0;!@{;"I"Lstatic VALUE proc_argv0(VALUE process) { return rb_orig_progname; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.argv0;F;@{;@{;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;H ;II" overload;F;J0;;;K0;#I" argv0;T;IC;";T;[;[;I";T;0; @{;@F;Mi;N0;[; @{;[;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;Ao;B;CT;Div;Ei};Mi;!@{;"@{;#@{;$To; ; F; ;,;;;I"Process#setproctitle;F;[[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;H ;II" overload;F;J0;;;K0;#I"setproctitle(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @{;[;I"@return [String];T;0; @{;@F;Mi;N0;[[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;N0;!@{;"I"hstatic VALUE proc_setproctitle(VALUE process, VALUE title) { return ruby_setproctitle(title); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.setproctitle;F;@{;@{;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;H ;II" overload;F;J0;;;K0;#I"setproctitle(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @|;[;I"@return [String];T;0; @|;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@{;"@|;#@|;$To; ;IC;[o; ; F; ;,;;;I"Process::Status#==;F;[[I"st2;T0;[[@i;T;;S;0;[;{;IC;"IReturns +true+ if the integer value of _stat_ equals other. ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @+|;[;I"@return [Boolean];T;0; @+|;@F;Mi;N0;[[I" other;T0; @+|;[;I"sReturns +true+ if the integer value of _stat_ equals other. @overload ==(other) @return [Boolean];T;0; @+|;@F;Ao;B;CT;Di;Ei;!@)|;"I"{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; ; F; ;,;;;I"Process::Status#&;F;[[I"st2;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" &(num);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @J|;[;I"@return [Integer];T;0; @J|;@F;Mi;N0;[[I"num;T0; @J|;[;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; @J|;@F;Ao;B;CT;Di;Ei;!@)|;"I"|static VALUE pst_bitand(VALUE st1, VALUE st2) { int status = PST2INT(st1) & NUM2INT(st2); return INT2NUM(status); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#>>;F;[[I"st2;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" >>(num);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @i|;[;I"@return [Integer];T;0; @i|;@F;Mi;N0;[[I"num;T0; @i|;[;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; @i|;@F;Ao;B;CT;Di;Ei;!@)|;"I"}static VALUE pst_rshift(VALUE st1, VALUE st2) { int status = PST2INT(st1) >> NUM2INT(st2); return INT2NUM(status); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#to_i;F;[;[[@i%;T;;=;0;[;{;IC;"Returns the bits in _stat_ as a Integer. Poking around in these bits is platform dependent. fork { exit 0xab } #=> 26566 Process.wait #=> 26566 sprintf('%04x', $?.to_i) #=> "ab00" ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|;[;I"@return [Integer];T;0; @|;@F;Mi;N0;[; @|o;H ;II" overload;F;J0;;;K0;#I" to_int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|;[;I"@return [Integer];T;0; @|;@F;Mi;N0;[; @|;[;I",Returns the bits in _stat_ as a 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] @overload to_int @return [Integer];T;0; @|;@F;Ao;B;CT;Di;Ei#;!@)|;"I"Ostatic VALUE pst_to_i(VALUE st) { return rb_ivar_get(st, id_status); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#to_s;F;[;[[@iu;T;;h;0;[;{;IC;"hShow pid and exit status as a string. system("false") p $?.to_s #=> "pid 12766 exit 1" ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @|;[;I"@return [String];T;0; @|;@F;Mi;N0;[; @|;[;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;Ao;B;CT;Dij;Eir;!@)|;"I"static VALUE pst_to_s(VALUE st) { rb_pid_t pid; int status; VALUE str; pid = NUM2PIDT(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; ; F; ;,;;;I"Process::Status#inspect;F;[;[[@i;T;;i;0;[;{;IC;"qOverride the inspection method. system("false") p $?.inspect #=> "#" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @|;[;I"@return [String];T;0; @|;@F;Mi;N0;[; @|;[;I"Override the inspection method. system("false") p $?.inspect #=> "#" @overload inspect @return [String];T;0; @|;@F;Ao;B;CT;Di;Ei;!@)|;"I"static VALUE pst_inspect(VALUE st) { rb_pid_t pid; int status; VALUE vpid, str; vpid = pst_pid(st); if (NIL_P(vpid)) { return rb_sprintf("#<%s: uninitialized>", rb_class2name(CLASS_OF(st))); } pid = NUM2PIDT(vpid); 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; ; F; ;,;;;I"Process::Status#pid;F;[;[[@i8;T;:pid;0;[;{;IC;"Returns the process ID that this status object represents. fork { exit } #=> 26569 Process.wait #=> 26569 $?.pid #=> 26569 ;T;[o;H ;II" overload;F;J0;;;K0;#I"pid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|;[;I"@return [Integer];T;0; @|;@F;Mi;N0;[; @|;[;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;Ao;B;CT;Di-;Ei5;!@)|;"I"Kstatic VALUE pst_pid(VALUE st) { return rb_attr_get(st, id_pid); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#stopped?;F;[;[[@i;T;: stopped?;0;[;{;IC;"Returns +true+ if this process is stopped. This is only returned if the corresponding wait call had the WUNTRACED flag set.;T;[o;H ;II" overload;F;J0;;;K0;#I" stopped?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @};[;I"@return [Boolean];T;0; @};@F;Mi;N0;[; @};[;I"Returns +true+ if this process is stopped. This is only returned if the corresponding wait call had the WUNTRACED flag set. @overload stopped? @return [Boolean];T;0; @};@F;Ao;B;CT;Di;Ei;Mi;!@)|;"I"static VALUE pst_wifstopped(VALUE st) { int status = PST2INT(st); if (WIFSTOPPED(status)) return Qtrue; else return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#stopsig;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" stopsig;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @};[;I"@return [Integer, nil];T;0; @};@F;Mi;N0;[; @};[;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;Ao;B;CT;Di;Ei;!@)|;"I"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; ; F; ;,;;;I"Process::Status#signaled?;F;[;[[@i;T;:signaled?;0;[;{;IC;"GReturns +true+ if _stat_ terminated because of an uncaught signal.;T;[o;H ;II" overload;F;J0;;;K0;#I"signaled?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @8};[;I"@return [Boolean];T;0; @8};@F;Mi;N0;[; @8};[;I"qReturns +true+ if _stat_ terminated because of an uncaught signal. @overload signaled? @return [Boolean];T;0; @8};@F;Ao;B;CT;Di;Ei ;Mi;!@)|;"I"static VALUE pst_wifsignaled(VALUE st) { int status = PST2INT(st); if (WIFSIGNALED(status)) return Qtrue; else return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#termsig;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" termsig;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @S};[;I"@return [Integer, nil];T;0; @S};@F;Mi;N0;[; @S};[;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; @S};@F;Ao;B;CT;Di;Ei!;!@)|;"I"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; ; F; ;,;;;I"Process::Status#exited?;F;[;[[@i8;T;: exited?;0;[;{;IC;"wReturns +true+ if _stat_ exited normally (for example using an exit() call or finishing the program).;T;[o;H ;II" overload;F;J0;;;K0;#I" exited?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @o};[;I"@return [Boolean];T;0; @o};@F;Mi;N0;[; @o};[;I"Returns +true+ if _stat_ exited normally (for example using an exit() call or finishing the program). @overload exited? @return [Boolean];T;0; @o};@F;Ao;B;CT;Di/;Ei5;Mi;!@)|;"I"static VALUE pst_wifexited(VALUE st) { int status = PST2INT(st); if (WIFEXITED(status)) return Qtrue; else return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#exitstatus;F;[;[[@iW;T;:exitstatus;0;[;{;IC;"qReturns 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;H ;II" overload;F;J0;;;K0;#I"exitstatus;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @};[;I"@return [Integer, nil];T;0; @};@F;Mi;N0;[; @};[;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; @};@F;Ao;B;CT;DiD;EiT;!@)|;"I"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; ; F; ;,;;;I"Process::Status#success?;F;[;[[@ij;T;: success?;0;[;{;IC;"qReturns +true+ if _stat_ is successful, +false+ if not. Returns +nil+ if exited? is not +true+.;T;[o;H ;II" overload;F;J0;; ;K0;#I" success?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @};[;I"@return [true, false, nil];T;0; @};@F;Mi;N0;[; @};[;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;Ao;B;CT;Dib;Eig;Mi;!@)|;"I"static VALUE pst_success_p(VALUE st) { int status = PST2INT(st); if (!WIFEXITED(status)) return Qnil; return WEXITSTATUS(status) == EXIT_SUCCESS ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process::Status#coredump?;F;[;[[@i};T;:coredump?;0;[;{;IC;"fReturns +true+ if _stat_ generated a coredump when it terminated. Not available on all platforms.;T;[o;H ;II" overload;F;J0;; ;K0;#I"coredump?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @};[;I"@return [Boolean];T;0; @};@F;Mi;N0;[; @};[;I"Returns +true+ if _stat_ generated a coredump when it terminated. Not available on all platforms. @overload coredump? @return [Boolean];T;0; @};@F;Ao;B;CT;Diu;Eiz;Mi;!@)|;"I"static VALUE pst_wcoredump(VALUE st) { #ifdef WCOREDUMP int status = PST2INT(st); if (WCOREDUMP(status)) return Qtrue; else return Qfalse; #else return Qfalse; #endif };T;#I"static VALUE;T;$T;&@)|;'IC;[;&@)|;(IC;[;&@)|;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;: Status;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!o;2 ;30;40;50;: Process;!@;7@{;F0;I"Process::Status;F;1@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, same as ENV["RUBYSHELL"] (or ENV["COMSPEC"] on Windows NT series), and similar. If the string from the first form (exec("command")) follows these simple rules: * no meta characters * no shell reserved word and no 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;H ;II" overload;F;J0;;;K0;#I"'exec([env,] command... [,options]);T;IC;";T;[;[;I";T;0; @ ~;@F;Mi;N0;[[I"[env,][,options];T0; @ ~;[;@;0; @ ~;@F;Ao;B;CT;Di2 ;Eiw ;!@{;"I"7VALUE rb_f_exec(int argc, const VALUE *argv) { VALUE execarg_obj, fail_str; struct rb_execarg *eargp; #define CHILD_ERRMSG_BUFLEN 80 char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; int err, state; execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE); eargp = rb_execarg_get(execarg_obj); if (mjit_enabled) mjit_finish(FALSE); /* avoid leaking resources, and do not leave files. XXX: JIT-ed handle can leak after exec error is rescued. */ before_exec(); /* stop timer thread before redirects */ rb_protect(rb_execarg_parent_start1, execarg_obj, &state); if (state) { execarg_parent_end(execarg_obj); after_exec(); /* restart timer thread */ rb_jump_tag(state); } fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; err = exec_async_signal_safe(eargp, errmsg, sizeof(errmsg)); after_exec(); /* restart timer thread */ rb_exec_fail(eargp, err, errmsg); RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(err, fail_str); UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To; ; F; ;;;;I"Process.fork;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @#~;!@{;$To; ; F; ;;;;I"Process.spawn;F;[[@0;[[@i;T;;;0;[;{;IC;"a*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;H ;II" overload;F;J0;;;K0;#I"(spawn([env,] command... [,options]);T;IC;";T;[;[;I";T;0; @,~;@F;Mi;N0;[[I"[env,][,options];T0; @,~o;H ;II" overload;F;J0;;;K0;#I"(spawn([env,] command... [,options]);T;IC;";T;[;[;I";T;0; @,~;@F;Mi;N0;[[I"[env,][,options];T0; @,~;[;@=;0; @,~;@F;Ao;B;CT;Di;Ei;!@{;"I"static VALUE rb_f_spawn(int argc, VALUE *argv) { 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; ; F; ;;;;I"Process.exit!;F;[[@0;[[@iB;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;H ;II" overload;F;J0;;;K0;#I"exit!(status=false);T;IC;";T;[;[;I";T;0; @N~;@F;Mi;N0;[[I" status;TI" false;T; @N~;[;@;0; @N~;@F;Ao;B;CT;Di7;Ei>;!@{;"I"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; ; F; ;;;;I"Process.exit;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"exit(status=true);T;IC;";T;[;[;I";T;0; @g~;@F;Mi;N0;[[I" status;TI" true;T; @g~o;H ;II" overload;F;J0;;;K0;#I"Kernel::exit(status=true);T;IC;";T;[;[;I";T;0; @g~;@F;Mi;N0;[[I" status;TI" true;T; @g~o;H ;II" overload;F;J0;;;K0;#I"Process::exit(status=true);T;IC;";T;[;[;I";T;0; @g~;@F;Mi;N0;[[I" status;TI" true;T; @g~;[;@;0; @g~;@F;Ao;B;CT;Di`;Ei;!@{;"I"VALUE rb_f_exit(int argc, const VALUE *argv) { int istatus; if (rb_check_arity(argc, 0, 1) == 1) { istatus = exit_status_code(argv[0]); } else { istatus = EXIT_SUCCESS; } rb_exit(istatus); UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To; ; F; ;;;;I"Process.abort;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I" abort;T;IC;";T;[;[;I";T;0; @~;@F;Mi;N0;[; @~o;H ;II" overload;F;J0;;;K0;#I"Kernel::abort([msg]);T;IC;";T;[;[;I";T;0; @~;@F;Mi;N0;[[I" [msg];T0; @~o;H ;II" overload;F;J0;;;K0;#I"abort([msg]);T;IC;";T;[;[;I";T;0; @~;@F;Mi;N0;[[I" [msg];T0; @~;[;@;0; @~;@F;Ao;B;CT;Di;Ei;!@{;"I"VALUE rb_f_abort(int argc, const VALUE *argv) { rb_check_arity(argc, 0, 1); if (argc == 0) { rb_execution_context_t *ec = GET_EC(); VALUE errinfo = ec->errinfo; if (!NIL_P(errinfo)) { rb_ec_error_print(ec, errinfo); } rb_exit(EXIT_FAILURE); } else { VALUE args[2]; args[1] = args[0] = argv[0]; StringValue(args[0]); rb_io_puts(1, args, rb_stderr); args[0] = INT2NUM(EXIT_FAILURE); rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit)); } UNREACHABLE_RETURN(Qnil); };T;#I" VALUE;T;$To; ; F; ;;;;I"Process.last_status;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I"last_status;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Process::Status;TI"nil;T; @~;[;I"#@return [Process::Status, nil];T;0; @~;@F;Mi;N0;[; @~;[;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;Ao;B;CT;Di;Ei;!@{;"I"Tstatic VALUE proc_s_last_status(VALUE mod) { return rb_last_status_get(); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Process#kill;F;[[@0;[[@i;T;: kill;0;[;{;IC;"tSends 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. _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;H ;II" overload;F;J0;;;K0;#I"kill(signal, pid, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @~;[;I"@return [Integer];T;0; @~;@F;Mi;N0;[[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. _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;N0;!@{;"I"VALUE rb_f_kill(int argc, const VALUE *argv) { #ifndef HAVE_KILLPG #define killpg(pg, sig) kill(-(pg), (sig)) #endif int sig; int i; VALUE str; rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS); if (FIXNUM_P(argv[0])) { sig = FIX2INT(argv[0]); } else { str = argv[0]; sig = signm2signo(&str, TRUE, FALSE, NULL); } if (argc <= 1) return INT2FIX(0); if (sig < 0) { sig = -sig; for (i=1; imain_thread) ? getpid() : -1; int wakeup = 0; for (i=1; imain_thread); } } rb_thread_execute_interrupts(rb_thread_current()); return INT2FIX(i-1); };T;#I" VALUE;T;$To; ; T; ;;;;I"Process.kill;F;@~;@~;T;;;0;@~;{;IC;"tSends 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. _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;H ;II" overload;F;J0;;;K0;#I"kill(signal, pid, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @~;[;I"@return [Integer];T;0; @~;@F;Mi;N0;[[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. _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;Ao;B;CT;Di;Ei;Mi;!@{;"@~;#@~;$To; ; F; ;,;;;I"Process#wait;F;[[@0;[[@i;T;: wait;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;H ;II" overload;F;J0;;;K0;#I" wait();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"wait(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @o;H ;II" overload;F;J0;: waitpid;K0;#I"waitpid(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @;[;I"PWaits 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;N0;!@{;"I"static VALUE proc_wait(int argc, VALUE *argv) { rb_pid_t pid; int flags, status; flags = 0; if (rb_check_arity(argc, 0, 2) == 0) { pid = -1; } else { VALUE vflags; pid = NUM2PIDT(argv[0]); if (argc == 2 && !NIL_P(vflags = argv[1])) { flags = NUM2UINT(vflags); } } if ((pid = rb_waitpid(pid, &status, flags)) < 0) rb_sys_fail(0); if (pid == 0) { rb_last_status_clear(); return Qnil; } return PIDT2NUM(pid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.wait;F;@;@;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;H ;II" overload;F;J0;;;K0;#I" wait();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Y;[;I"@return [Integer];T;0; @Y;@F;Mi;N0;[; @Yo;H ;II" overload;F;J0;;;K0;#I"wait(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Y;[;I"@return [Integer];T;0; @Y;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @Yo;H ;II" overload;F;J0;;;K0;#I"waitpid(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Y;[;I"@return [Integer];T;0; @Y;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @Y;[;I"OWaits 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; @Y;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@W;#@X;$To; ; F; ;,;;;I"Process#wait2;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"wait2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @o;H ;II" overload;F;J0;: waitpid2;K0;#I"waitpid2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;N0;!@{;"I"static VALUE proc_wait2(int argc, VALUE *argv) { 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; ; T; ;;;;I"Process.wait2;F;@;@;T;;;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;H ;II" overload;F;J0;;;K0;#I"wait2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @o;H ;II" overload;F;J0;;;K0;#I"waitpid2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei*;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#waitpid;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" wait();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"wait(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @o;H ;II" overload;F;J0;;;K0;#I"waitpid(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @;[;I"PWaits 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;N0;!@{;"I"static VALUE proc_wait(int argc, VALUE *argv) { rb_pid_t pid; int flags, status; flags = 0; if (rb_check_arity(argc, 0, 2) == 0) { pid = -1; } else { VALUE vflags; pid = NUM2PIDT(argv[0]); if (argc == 2 && !NIL_P(vflags = argv[1])) { flags = NUM2UINT(vflags); } } if ((pid = rb_waitpid(pid, &status, flags)) < 0) rb_sys_fail(0); if (pid == 0) { rb_last_status_clear(); return Qnil; } return PIDT2NUM(pid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.waitpid;F;@;@;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;H ;II" overload;F;J0;;;K0;#I" wait();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @7;[;I"@return [Integer];T;0; @7;@F;Mi;N0;[; @7o;H ;II" overload;F;J0;;;K0;#I"wait(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @7;[;I"@return [Integer];T;0; @7;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @7o;H ;II" overload;F;J0;;;K0;#I"waitpid(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @7;[;I"@return [Integer];T;0; @7;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @7;[;@;0; @7;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@5;#@6;$To; ; F; ;,;;;I"Process#waitpid2;F;[[@0;[[@i,;T;;;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;H ;II" overload;F;J0;;;K0;#I"wait2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @q;[;I"@return [Array];T;0; @q;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @qo;H ;II" overload;F;J0;;;K0;#I"waitpid2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @q;[;I"@return [Array];T;0; @q;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @q;[;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; @q;@F;N0;!@{;"I"static VALUE proc_wait2(int argc, VALUE *argv) { 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; ; T; ;;;;I"Process.waitpid2;F;@s;@u;T;;;0;@w;{;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;H ;II" overload;F;J0;;;K0;#I"wait2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @o;H ;II" overload;F;J0;;;K0;#I"waitpid2(pid=-1, flags=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"pid;TI"-1;T[I" flags;TI"0;T; @;[;@;0; @;@F;Ao;B;CT;Di;Ei*;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#waitall;F;[;[[@iI;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;H ;II" overload;F;J0;;;K0;#I" waitall;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @Ҁ;[;I"@return [Array];T;0; @Ҁ;@F;Mi;N0;[; @Ҁ;[;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;N0;!@{;"I"static VALUE proc_waitall(void) { 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; ; T; ;;;;I"Process.waitall;F;@Ԁ;@Հ;T;;;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;H ;II" overload;F;J0;;;K0;#I" waitall;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di5;EiF;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#detach;F;[[I"pid;T0;[[@i;T;: detach;0;[;{;IC;"aSome 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;H ;II" overload;F;J0;;;K0;#I"detach(pid);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"pid;T0; @;[;I"xSome 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;N0;!@{;"I"dstatic VALUE proc_detach(VALUE obj, VALUE pid) { return rb_detach_process(NUM2PIDT(pid)); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.detach;F;@;@;T;;;0;@;{;IC;"aSome 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;H ;II" overload;F;J0;;;K0;#I"detach(pid);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"pid;T0; @;[;I"ySome 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;Ao;B;CT;Di~;Ei;Mi;!@{;"@;#@;$To; ;IC;[o; ; F; ;,;;;I"Process::Waiter#pid;F;[;[[@ib;T;;;0;[;{;IC;" ;T;[;[;@;0; @.;!@,;"I"gstatic VALUE detach_process_pid(VALUE thread) { return rb_thread_local_aref(thread, id_pid); };T;#I"static VALUE;T;$T;&@,;'IC;[;&@,;(IC;[;&@,;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;: Waiter;;0;;;[;{;IC;" ;T;[;[;@;0; @,;!@{;I"Process::Waiter;F;1o; ;IC;[@o; ; F; ;,;;;I"Thread#set_trace_func;F;[[I" trace;T0;[[@i?;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;H ;II" overload;F;J0;;;K0;#I"set_trace_func(proc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @K;[;I"@return [Proc];T;0; @K;@F;Mi;N0;[[I" proc;T0; @Ko;H ;II" overload;F;J0;;;K0;#I"set_trace_func(nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @K;[;I"@return [nil];T;0; @K;@F;Mi;N0;[[I"nil;T0; @K;[;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; @K;@F;Ao;B;CT;Di4;Ei=;!@I;"I"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; ; F; ;,;;;I"Thread#add_trace_func;F;[[I" trace;T0;[[@i-;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;H ;II" overload;F;J0;;;K0;#I"add_trace_func(proc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @y;[;I"@return [Proc];T;0; @y;@F;Mi;N0;[[I" proc;T0; @y;[;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; @y;@F;Ao;B;CT;Di$;Ei*;!@I;"I"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;$To; ; F; ;,;;;I"Thread#__runnable_sleep__;F;[[I" timeout;T0;[[I"7ext/-test-/gvl/call_without_gvl/call_without_gvl.c;Ti;T;:__runnable_sleep__;0;[;{;IC;" ;T;[;[;@;0; @;!@I;"I"Gstatic 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 thread; };T;#I"static VALUE;T;$To; ;IC;[o; ;IC;[ o; ; F; ;,;;;I"'Thread::Backtrace::Location#lineno;F;[;[[@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;Ao;B;CT;Di;Ei;!@;"I"lstatic VALUE location_lineno_m(VALUE self) { return INT2FIX(location_lineno(location_ptr(self))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&Thread::Backtrace::Location#label;F;[;[[@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;Ao;B;CT;Di;Ei;!@;"I"astatic VALUE location_label_m(VALUE self) { return location_label(location_ptr(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"+Thread::Backtrace::Location#base_label;F;[;[[@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;Ao;B;CT;Di;Ei;!@;"I"kstatic VALUE location_base_label_m(VALUE self) { return location_base_label(location_ptr(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"%Thread::Backtrace::Location#path;F;[;[[@Ki;T;: path;0;[;{;IC;"Returns the file name of this frame. 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. For example, using +caller_locations.rb+ from Thread::Backtrace::Location loc = c(0..1).first loc.path #=> caller_locations.rb ;T;0; @Ձ;@F;Ao;B;CT;Di ;Ei;!@;"I"_static VALUE location_path_m(VALUE self) { return location_path(location_ptr(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I".Thread::Backtrace::Location#absolute_path;F;[;[[@Ki2;T;:absolute_path;0;[;{;IC;"^Returns the full file path of this frame. Same as #path, but includes the absolute path. ;T;[;[;I"_Returns the full file path of this frame. Same as #path, but includes the absolute path. ;T;0; @;@F;Ao;B;CT;Di-;Ei0;!@;"I"lstatic VALUE location_absolute_path_m(VALUE self) { return location_realpath(location_ptr(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"%Thread::Backtrace::Location#to_s;F;[;[[@Kir;T;;h;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;Ao;B;CT;Dio;Eip;!@;"I"cstatic VALUE location_to_str_m(VALUE self) { return location_to_str(location_ptr(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"(Thread::Backtrace::Location#inspect;F;[;[[@Ki|;T;;i;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;Ao;B;CT;Dix;Eiz;!@;"I"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;-{;.[;[[@Ki5;F;: Location;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I" Thread::Backtrace::Location;F;1@<;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Ki;F;:Backtrace;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@I;I"Thread::Backtrace;F;1@ 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; @+;@F;Ao;B;CT;DiP;Eia;!@I;"I"static VALUE thread_s_new(int argc, VALUE *argv, VALUE klass) { rb_thread_t *th; VALUE thread = rb_thread_alloc(klass); if (GET_VM()->main_thread->status == THREAD_KILLED) rb_raise(rb_eThreadError, "can't alloc thread"); rb_obj_call_init(thread, argc, argv); 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; ; F; ;;;;I"Thread.start;F;[[I" args;T0;[[@1i;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;H ;II" overload;F;J0;;;K0;#I"start([args]*);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" args;T; @;;[;I"@yield [args];T;0; @;;@F;Mi;N0;[[I" [args];T0; @;o;H ;II" overload;F;J0;;;K0;#I"fork([args]*);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" args;T; @;;[;I"@yield [args];T;0; @;;@F;Mi;N0;[[I" [args];T0; @;;[;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; @;;@F;Ao;B;CT;Div;Ei~;!@I;"I"{static VALUE thread_start(VALUE klass, VALUE args) { return thread_create_core(rb_thread_alloc(klass), args, 0); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.fork;F;[[I" args;T0;[[@1i;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;H ;II" overload;F;J0;;;K0;#I"start([args]*);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" args;T; @i;[;I"@yield [args];T;0; @i;@F;Mi;N0;[[I" [args];T0; @io;H ;II" overload;F;J0;;;K0;#I"fork([args]*);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" args;T; @i;[;I"@yield [args];T;0; @i;@F;Mi;N0;[[I" [args];T0; @i;[;@e;0; @i;@F;Ao;B;CT;Div;Ei~;!@I;"I"{static VALUE thread_start(VALUE klass, VALUE args) { return thread_create_core(rb_thread_alloc(klass), args, 0); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.main;F;[;[[@1if ;T;: main;0;[;{;IC;"Returns the main thread. ;T;[o;H ;II" overload;F;J0;;!;K0;#I" main;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I".Returns the main thread. @overload main;T;0; @;@F;Ao;B;CT;Di_ ;Eib ;!@I;"I"Pstatic VALUE rb_thread_s_main(VALUE klass) { return rb_thread_main(); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.current;F;[;[[@1iS ;T;: current;0;[;{;IC;"^Returns the currently executing thread. Thread.current #=> # ;T;[o;H ;II" overload;F;J0;;";K0;#I" current;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"rReturns the currently executing thread. Thread.current #=> # @overload current;T;0; @;@F;Ao;B;CT;DiJ ;EiO ;!@I;"I"Sstatic VALUE thread_s_current(VALUE klass) { return rb_thread_current(); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.stop;F;[;[[@1i ;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;H ;II" overload;F;J0;;#;K0;#I" stop;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @‚;[;I"@return [nil];T;0; @‚;@F;Mi;N0;[; @‚;[;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;Ao;B;CT;Di ;Ei ;!@I;"I"VALUE rb_thread_stop(void) { if (rb_thread_alone()) { rb_raise(rb_eThreadError, "stopping only thread\n\tnote: use sleep to stop forever"); } rb_thread_sleep_deadly(); return Qnil; };T;#I" VALUE;T;$To; ; F; ;;;;I"Thread.kill;F;[[I"th;T0;[[@1i ;T;;;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;H ;II" overload;F;J0;;;K0;#I"kill(thread);T;IC;";T;[;[;I";T;0; @݂;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@I;"I"Zstatic VALUE rb_thread_s_kill(VALUE obj, VALUE th) { return rb_thread_kill(th); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.exit;F;[;[[@1i ;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;H ;II" overload;F;J0;;;K0;#I" exit;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei ;!@I;"I"sstatic VALUE rb_thread_exit(void) { rb_thread_t *th = GET_THREAD(); return rb_thread_kill(th->self); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.pass;F;[;[[@1i;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;H ;II" overload;F;J0;;$;K0;#I" pass;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di;Ei;!@I;"I"[static VALUE thread_s_pass(VALUE klass) { rb_thread_schedule(); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.list;F;[;[[@1i0 ;T;: list;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;H ;II" overload;F;J0;;%;K0;#I" list;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @(;[;I"@return [Array];T;0; @(;@F;Mi;N0;[; @(;[;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;Ao;B;CT;Di ;Ei- ;!@I;"I"lVALUE rb_thread_list(void) { VALUE ary = rb_ary_new(); rb_vm_t *vm = GET_THREAD()->vm; rb_thread_t *th = 0; list_for_each(&vm->living_threads, th, vmlt_node) { switch (th->status) { case THREAD_RUNNABLE: case THREAD_STOPPED: case THREAD_STOPPED_FOREVER: rb_ary_push(ary, th->self); default: break; } } return ary; };T;#I" VALUE;T;$To; ; F; ;;;;I"Thread.abort_on_exception;F;[;[[@1i ;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;H ;II" overload;F;J0;;&;K0;#I"abort_on_exception;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @C;[;I"@return [Boolean];T;0; @C;@F;Mi;N0;[; @C;[;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; @C;@F;Ao;B;CT;Dim ;Ei~ ;!@I;"I"zstatic VALUE rb_thread_s_abort_exc(void) { return GET_THREAD()->vm->thread_abort_on_exception ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.abort_on_exception=;F;[[I"val;T0;[[@1i ;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;H ;II" overload;F;J0;;';K0;#I"!abort_on_exception=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @^;[;I"@return [Boolean];T;0; @^;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@I;"I"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; ; F; ;;;;I"Thread.report_on_exception;F;[;[[@1i ;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;H ;II" overload;F;J0;;(;K0;#I"report_on_exception;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @};[;I"@return [Boolean];T;0; @};@F;Mi;N0;[; @};[;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;Ao;B;CT;Di ;Ei ;!@I;"I"|static VALUE rb_thread_s_report_exc(void) { return GET_THREAD()->vm->thread_report_on_exception ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I" Thread.report_on_exception=;F;[[I"val;T0;[[@1i( ;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;H ;II" overload;F;J0;;);K0;#I""report_on_exception=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei% ;!@I;"I"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; ; F; ;;;;I"Thread.DEBUG;F;[;[[@1i(;T;: DEBUG;0;[;{;IC;"VReturns the thread debug level. Available only if compiled with THREAD_DEBUG=-1. ;T;[o;H ;II" overload;F;J0;;*;K0;#I" DEBUG;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[; @;[;I"|Returns the thread debug level. Available only if compiled with THREAD_DEBUG=-1. @overload DEBUG @return [Numeric];T;0; @;@F;Ao;B;CT;Di ;Ei%;!@I;"I"Zstatic VALUE rb_thread_s_debug(void) { return INT2NUM(rb_thread_debug_enabled); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Thread.DEBUG=;F;[[I"val;T0;[[@1i6;T;: DEBUG=;0;[;{;IC;"SSets the thread debug level. Available only if compiled with THREAD_DEBUG=-1. ;T;[o;H ;II" overload;F;J0;;+;K0;#I"DEBUG=(num);T;IC;";T;[;[;I";T;0; @҃;@F;Mi;N0;[[I"num;T0; @҃;[;I"kSets the thread debug level. Available only if compiled with THREAD_DEBUG=-1. @overload DEBUG=(num);T;0; @҃;@F;Ao;B;CT;Di.;Ei2;!@I;"I"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; ; F; ;;;;I"Thread.handle_interrupt;F;[[I" mask_arg;T0;[[@1i;T;:handle_interrupt;0;[;{;IC;"X 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. } ;T;[o;H ;II" overload;F;J0;;,;K0;#I"handle_interrupt(hash);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[[I" hash;T0; @;[;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. } @overload handle_interrupt(hash) @yield [];T;0; @;@F;Ao;B;CT;DiU;Ei;!@I;"I"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; ; F; ;;;;I"Thread.pending_interrupt?;F;[[@0;[[@1iM;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;H ;II" overload;F;J0;;-;K0;#I"$pending_interrupt?(error = nil);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" error;TI"nil;T; @ o;L ;II" return;F;J@;0;K[@; @ ;[;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; @ ;@F;Ao;B;CT;Di;EiI;Mi;!@I;"I"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; ; F; ;,;;;I"Thread#pending_interrupt?;F;[[@0;[[@1i;T;;-;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;H ;II" overload;F;J0;;-;K0;#I"$pending_interrupt?(error = nil);T;IC;";T;[;[;I";T;0; @&;@F;Mi;N0;[[I" error;TI"nil;T; @&o;L ;II" return;F;J@;0;K[@; @&;[;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;Ao;B;CT;Di;Ei;Mi;!@I;"I"static 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"); } if (rb_threadptr_pending_interrupt_include_p(target_th, err)) { return Qtrue; } else { return Qfalse; } } else { return Qtrue; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#initialize;F;[[I" args;T0;[[@1i;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @C;@F;Ao;B;CT;Di;Ei;!@I;"I"static 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 { return thread_create_core(thread, args, NULL); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#raise;F;[[@0;[[@1iL ;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;H ;II" overload;F;J0;;;K0;#I" raise;T;IC;";T;[;[;I";T;0; @S;@F;Mi;N0;[; @So;H ;II" overload;F;J0;;;K0;#I"raise(string);T;IC;";T;[;[;I";T;0; @S;@F;Mi;N0;[[I" string;T0; @So;H ;II" overload;F;J0;;;K0;#I"*raise(exception [, string [, array]]);T;IC;";T;[;[;I";T;0; @S;@F;Mi;N0;[[I""exception[, string [, array]];T0; @S;[;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; @S;@F;Ao;B;CT;Di7 ;EiH ;!@I;"I"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; ; F; ;,;;;I"Thread#join;F;[[@0;[[@1iT;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;H ;II" overload;F;J0;;.;K0;#I" join;T;IC;";T;[;[;I";T;0; @~;@F;Mi;N0;[; @~o;H ;II" overload;F;J0;;.;K0;#I"join(limit);T;IC;";T;[;[;I";T;0; @~;@F;Mi;N0;[[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;Ao;B;CT;Di-;EiP;!@I;"I")static VALUE thread_join_m(int argc, VALUE *argv, VALUE self) { VALUE limit; rb_hrtime_t rel, *to = 0; /* * This supports INFINITY and negative values, so we can't use * rb_time_interval right now... */ if (!rb_check_arity(argc, 0, 1) || NIL_P(argv[0])) { /* unlimited */ } else if (FIXNUM_P(limit = argv[0])) { rel = rb_sec2hrtime(NUM2TIMET(limit)); to = &rel; } else { to = double2hrtime(&rel, rb_num2dbl(limit)); } return thread_join(rb_thread_ptr(self), to); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#value;F;[;[[@1iz;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;H ;II" overload;F;J0;;/;K0;#I" value;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Dil;Eiw;!@I;"I"static VALUE thread_value(VALUE self) { rb_thread_t *th = rb_thread_ptr(self); thread_join(th, 0); return th->value; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#kill;F;[;[[@1ij ;T;;;0;[;{;IC;"Terminates +thr+ 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, exits the process. ;T;[o;H ;II" overload;F;J0;;;K0;#I" exit;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" kill;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:terminate;K0;#I"terminate;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;I"*Terminates +thr+ 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, exits the process. @overload exit @return [nil] @overload kill @return [nil] @overload terminate @return [nil];T;0; @;@F;Ao;B;CT;Di] ;Eii ;!@I;"I"FVALUE 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->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; ; F; ;,;;;I"Thread#terminate;F;[;[[@1ij ;T;;0;0;[;{;IC;"Terminates +thr+ 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, exits the process. ;T;[o;H ;II" overload;F;J0;;;K0;#I" exit;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" kill;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;0;K0;#I"terminate;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di] ;Eii ;!@I;"I"FVALUE 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->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; ; F; ;,;;;I"Thread#exit;F;[;[[@1ij ;T;;;0;[;{;IC;"Terminates +thr+ 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, exits the process. ;T;[o;H ;II" overload;F;J0;;;K0;#I" exit;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @#;[;I"@return [nil];T;0; @#;@F;Mi;N0;[; @#o;H ;II" overload;F;J0;;;K0;#I" kill;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @#;[;I"@return [nil];T;0; @#;@F;Mi;N0;[; @#o;H ;II" overload;F;J0;;0;K0;#I"terminate;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @#;[;I"@return [nil];T;0; @#;@F;Mi;N0;[; @#;[;@;0; @#;@F;Ao;B;CT;Di] ;Eii ;!@I;"I"FVALUE 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->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; ; F; ;,;;;I"Thread#run;F;[;[[@1i ;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;H ;II" overload;F;J0;;1;K0;#I"run;T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[; @W;[;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; @W;@F;Ao;B;CT;Di ;Ei ;!@I;"I"uVALUE rb_thread_run(VALUE thread) { rb_thread_wakeup(thread); rb_thread_schedule(); return thread; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Thread#wakeup;F;[;[[@1i ;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;H ;II" overload;F;J0;;2;K0;#I" wakeup;T;IC;";T;[;[;I";T;0; @m;@F;Mi;N0;[; @m;[;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; @m;@F;Ao;B;CT;Di ;Ei ;!@I;"I"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; ; F; ;,;;;I"Thread#[];F;[[I"key;T0;[[@1i ;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;H ;II" overload;F;J0;;;K0;#I" [](sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dif ;Ei ;!@I;"I"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; ; F; ;,;;;I"Thread#[]=;F;[[I"id;T0[I"val;T0;[[@1i ;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;H ;II" overload;F;J0;;+;K0;#I" []=(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@I;"I"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; ; F; ;,;;;I"Thread#fetch;F;[[@0;[[@1i ;T;;;0;[;{;IC;"VReturns 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;H ;II" overload;F;J0;;;K0;#I"fetch(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ą;[;I"@return [Object];T;0; @ą;@F;Mi;N0;[[I"sym;T0; @ąo;H ;II" overload;F;J0;;;K0;#I"fetch(sym);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @ąo;L ;II" return;F;JI";T;0;K[I" Object;T; @ą;[;I"@yield [] @return [Object];T;0; @ą;@F;Mi;N0;[[I"sym;T0; @ąo;H ;II" overload;F;J0;;;K0;#I"fetch(sym, default);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ą;[;I"@return [Object];T;0; @ą;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@I;"I"$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 && st_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; ; F; ;,;;;I"Thread#key?;F;[[I"key;T0;[[@1iY ;T;;;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;H ;II" overload;F;J0;;;K0;#I"key?(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"sym;T0; @;[;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; @;@F;Ao;B;CT;DiL ;EiV ;Mi;!@I;"I"Astatic VALUE rb_thread_key_p(VALUE self, VALUE key) { ID id = rb_check_id(&key); st_table *local_storage = rb_thread_ptr(self)->ec->local_storage; if (!id || local_storage == NULL) { return Qfalse; } else if (st_lookup(local_storage, id, 0)) { return Qtrue; } else { return Qfalse; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#keys;F;[;[[@1i ;T;;;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;H ;II" overload;F;J0;;;K0;#I" keys;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @$;[;I"@return [Array];T;0; @$;@F;Mi;N0;[; @$;[;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; @$;@F;Ao;B;CT;Diw ;Ei ;!@I;"I"static VALUE rb_thread_keys(VALUE self) { st_table *local_storage = rb_thread_ptr(self)->ec->local_storage; VALUE ary = rb_ary_new(); if (local_storage) { st_foreach(local_storage, thread_keys_i, ary); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#priority;F;[;[[@1i ;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;H ;II" overload;F;J0;;3;K0;#I" priority;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @?;[;I"@return [Integer];T;0; @?;@F;Mi;N0;[; @?;[;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; @?;@F;Ao;B;CT;Di ;Ei ;!@I;"I"kstatic VALUE rb_thread_priority(VALUE thread) { return INT2NUM(rb_thread_ptr(thread)->priority); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#priority=;F;[[I" prio;T0;[[@1i ;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;H ;II" overload;F;J0;;4;K0;#I"priority=(integer);T;IC;";T;[;[;I";T;0; @Z;@F;Mi;N0;[[I" integer;T0; @Z;[;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; @Z;@F;Ao;B;CT;Di ;Ei;!@I;"I"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; ; F; ;,;;;I"Thread#status;F;[;[[@1i ;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;H ;II" overload;F;J0;;5;K0;#I" status;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI" false;TI"nil;T; @t;[;I"!@return [String, false, nil];T;0; @t;@F;Mi;N0;[; @t;[;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; @t;@F;Ao;B;CT;Di ;Ei ;!@I;"I"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; ; F; ;,;;;I"Thread#thread_variable_get;F;[[I"key;T0;[[@1i- ;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;H ;II" overload;F;J0;;6;K0;#I"thread_variable_get(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei* ;!@I;"I"static VALUE rb_thread_variable_get(VALUE thread, VALUE key) { VALUE locals; locals = rb_ivar_get(thread, id_locals); return rb_hash_aref(locals, rb_to_symbol(key)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#thread_variable_set;F;[[I"id;T0[I"val;T0;[[@1i? ;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;H ;II" overload;F;J0;;7;K0;#I"$thread_variable_set(key, value);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di6 ;Ei; ;!@I;"I" static VALUE rb_thread_variable_set(VALUE thread, VALUE id, VALUE val) { VALUE locals; if (OBJ_FROZEN(thread)) { rb_error_frozen("thread locals"); } locals = rb_ivar_get(thread, id_locals); return rb_hash_aset(locals, rb_to_symbol(id), val); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#thread_variables;F;[;[[@1i ;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;H ;II" overload;F;J0;;8;K0;#I"thread_variables;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @φ;[;I"@return [Array];T;0; @φ;@F;Mi;N0;[; @φ;[;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;Ao;B;CT;Di ;Ei ;!@I;"I"static VALUE rb_thread_variables(VALUE thread) { VALUE locals; VALUE ary; locals = rb_ivar_get(thread, id_locals); ary = rb_ary_new(); rb_hash_foreach(locals, keys_i, ary); return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#thread_variable?;F;[[I"key;T0;[[@1i ;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;H ;II" overload;F;J0;;9;K0;#I"thread_variable?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;Mi;!@I;"I"Istatic VALUE rb_thread_variable_p(VALUE thread, VALUE key) { VALUE locals; ID id = rb_check_id(&key); if (!id) return Qfalse; locals = rb_ivar_get(thread, id_locals); if (rb_hash_lookup(locals, ID2SYM(id)) != Qnil) { return Qtrue; } else { return Qfalse; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#alive?;F;[;[[@1i ;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;H ;II" overload;F;J0;;:;K0;#I" alive?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[; @ ;[;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; @ ;@F;Ao;B;CT;Di ;Ei ;Mi;!@I;"I"static VALUE rb_thread_alive_p(VALUE thread) { if (rb_threadptr_dead(rb_thread_ptr(thread))) { return Qfalse; } else { return Qtrue; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#stop?;F;[;[[@1i ;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;H ;II" overload;F;J0;;;;K0;#I" stop?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$;[;I"@return [Boolean];T;0; @$;@F;Mi;N0;[; @$;[;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; @$;@F;Ao;B;CT;Di ;Ei ;Mi;!@I;"I"$static VALUE rb_thread_stop_p(VALUE thread) { rb_thread_t *th = rb_thread_ptr(thread); if (rb_threadptr_dead(th)) { return Qtrue; } else if (th->status == THREAD_STOPPED || th->status == THREAD_STOPPED_FOREVER) { return Qtrue; } else { return Qfalse; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#abort_on_exception;F;[;[[@1i ;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;H ;II" overload;F;J0;;&;K0;#I"abort_on_exception;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @?;[;I"@return [Boolean];T;0; @?;@F;Mi;N0;[; @?;[;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; @?;@F;Ao;B;CT;Di ;Ei ;!@I;"I"~static VALUE rb_thread_abort_exc(VALUE thread) { return rb_thread_ptr(thread)->abort_on_exception ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#abort_on_exception=;F;[[I"val;T0;[[@1i ;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;H ;II" overload;F;J0;;';K0;#I"!abort_on_exception=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Z;[;I"@return [Boolean];T;0; @Z;@F;Mi;N0;[[I" boolean;T0; @Z;[;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; @Z;@F;Ao;B;CT;Di ;Ei ;!@I;"I"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; ; F; ;,;;;I"Thread#report_on_exception;F;[;[[@1i@ ;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;H ;II" overload;F;J0;;(;K0;#I"report_on_exception;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @y;[;I"@return [Boolean];T;0; @y;@F;Mi;N0;[; @y;[;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; @y;@F;Ao;B;CT;Di0 ;Ei= ;!@I;"I"{static VALUE rb_thread_report_exc(VALUE thread) { return rb_thread_ptr(thread)->report_on_exception ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Thread#report_on_exception=;F;[[I"val;T0;[[@1iT ;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;H ;II" overload;F;J0;;);K0;#I""report_on_exception=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiG ;EiQ ;!@I;"I"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; ; F; ;,;;;I"Thread#safe_level;F;[;[[@1i ;T;:safe_level;0;[;{;IC;"rReturns the safe level. This method is obsolete because $SAFE is a process global state. Simply check $SAFE. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"safe_level;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns the safe level. This method is obsolete because $SAFE is a process global state. Simply check $SAFE. @overload safe_level @return [Integer];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@I;"I"^static VALUE rb_thread_safe_level(VALUE thread) { return UINT2NUM(rb_safe_level()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#group;F;[;[[@1if ;T;: group;0;[;{;IC;"Returns the ThreadGroup which contains the given thread, or returns +nil+ if +thr+ is not a member of any group. Thread.main.group #=> # ;T;[o;H ;II" overload;F;J0;;=;K0;#I" group;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @·;[;I"@return [nil];T;0; @·;@F;Mi;N0;[; @·;[;I"Returns the ThreadGroup which contains the given thread, or returns +nil+ if +thr+ is not a member of any group. Thread.main.group #=> # @overload group @return [nil];T;0; @·;@F;Ao;B;CT;Di\ ;Eic ;!@I;"I"VALUE rb_thread_group(VALUE thread) { VALUE group = rb_thread_ptr(thread)->thgroup; return group == 0 ? Qnil : group; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Thread#backtrace;F;[[@0;[[@1i;T;;;0;[;{;IC;"8Returns the current backtrace of the target thread. ;T;[o;H ;II" overload;F;J0;;;K0;#I"backtrace;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"aReturns the current backtrace of the target thread. @overload backtrace @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@I;"I"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; ; F; ;,;;;I"Thread#backtrace_locations;F;[[@0;[[@1i;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"/backtrace_locations(*args) -> array or nil;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@I;"I"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; ; F; ;,;;;I"Thread#name;F;[;[[@1i ;T;: name;0;[;{;IC;"!show the name of the thread. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"Eshow the name of the thread. @overload name @return [String];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@I;"I"]static VALUE rb_thread_getname(VALUE thread) { return rb_thread_ptr(thread)->name; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Thread#name=;F;[[I" name;T0;[[@1i ;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;H ;II" overload;F;J0;;?;K0;#I"name=(name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @9;[;I"@return [String];T;0; @9;@F;Mi;N0;[[I" name;T0; @9;[;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; @9;@F;Ao;B;CT;Di ;Ei ;!@I;"I"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; ; F; ;,;;;I"Thread#to_s;F;[;[[@1i2 ;T;;h;0;[;{;IC;"8Dump the name, id, and status of _thr_ to a string. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @X;[;I"@return [String];T;0; @X;@F;Mi;N0;[; @X;[;I"\Dump the name, id, and status of _thr_ to a string. @overload to_s @return [String];T;0; o; ; F; ;,;;;I"Thread#inspect;F;[;[[@1i-;F;;i;;0;[;{;@_;!@I;"I"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_gc_force_recycle(loc); } rb_str_catf(str, " %s>", status); OBJ_INFECT(str, thread); return str; };T;#I"static VALUE;T;@F;Ao;B;CT;Di+ ;Ei/ ;!@I;"I"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_gc_force_recycle(loc); } rb_str_catf(str, " %s>", status); OBJ_INFECT(str, thread); return str; };T;#@x;$T@po; ; F; ;,;;;I"#Thread#__infinite_loop_dlsym__;F;[[I" name;T0;[[I"4ext/-test-/popen_deadlock/infinite_loop_dlsym.c;Ti%;T;:__infinite_loop_dlsym__;0;[;{;IC;" ;T;[;[;@;0; @{;!@I;"I" 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;$T;&@I;'IC;[;&@I;(IC;[;&@I;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@p;h;.[;[[I" vm.c;Tir [@i ;T;: Thread;;0;;;[;{;IC;"AThreads 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 "Whats 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 #=> "Whats 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 "Whats 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 } === 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 { ... } 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 Any thread can raise an exception using the #raise instance method, which operates similarly to Kernel#raise. However, it's important to note that an exception that occurs in any thread except the main thread depends on #abort_on_exception. This option is +false+ by default, meaning that any unhandled exception will cause the thread to terminate silently when waited on by either #join or #value. You can change this default by either #abort_on_exception= +true+ or setting $DEBUG to +true+. 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"D 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 "Whats 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 #=> "Whats 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 "Whats 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 } === 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 { ... } 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 Any thread can raise an exception using the #raise instance method, which operates similarly to Kernel#raise. However, it's important to note that an exception that occurs in any thread except the main thread depends on #abort_on_exception. This option is +false+ by default, meaning that any unhandled exception will cause the thread to terminate silently when waited on by either #join or #value. You can change this default by either #abort_on_exception= +true+ or setting $DEBUG to +true+. 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; @I;@F;Ao;B;CT;Dir ;Ei ;Mi;!@;I" Thread;F;1@ 27415 ;T;[o;H ;II" overload;F;J0;;;K0;#I"pid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns the process id of this process. Not available on all platforms. Process.pid #=> 27415 @overload pid @return [Integer];T;0; @;@F;N0;!@{;"I"Bstatic VALUE get_pid(void) { return PIDT2NUM(getpid()); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.pid;F;@;@;T;;;0;@;{;IC;"hReturns the process id of this process. Not available on all platforms. Process.pid #=> 27415;T;[o;H ;II" overload;F;J0;;;K0;#I"pid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns the process id of this process. Not available on all platforms. Process.pid #=> 27415 @overload pid @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#ppid;F;[;[[@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;H ;II" overload;F;J0;;B;K0;#I" ppid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @̈;[;I"@return [Integer];T;0; @̈;@F;Mi;N0;[; @̈;[;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;N0;!@{;"I"Dstatic VALUE get_ppid(void) { return PIDT2NUM(getppid()); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.ppid;F;@Έ;@ψ;T;;B;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;H ;II" overload;F;J0;;B;K0;#I" ppid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#getpgrp;F;[;[[@i;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;H ;II" overload;F;J0;;C;K0;#I" getpgrp;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@{;"I":static VALUE proc_getpgrp(void) { 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; ; T; ;;;;I"Process.getpgrp;F;@;@;T;;C;0;@;{;IC;"Returns the process group ID for this process. Not available on all platforms. Process.getpgid(0) #=> 25527 Process.getpgrp #=> 25527;T;[o;H ;II" overload;F;J0;;C;K0;#I" getpgrp;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#setpgrp;F;[;[[@i;T;: setpgrp;0;[;{;IC;"MEquivalent to setpgid(0,0). Not available on all platforms. ;T;[o;H ;II" overload;F;J0;;D;K0;#I" setpgrp;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @*;[;I"@return [0];T;0; @*;@F;Mi;N0;[; @*;[;I"nEquivalent to setpgid(0,0). Not available on all platforms. @overload setpgrp @return [0];T;0; @*;@F;N0;!@{;"I"static VALUE proc_setpgrp(void) { /* 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; ; T; ;;;;I"Process.setpgrp;F;@,;@-;T;;D;0;@/;{;IC;"MEquivalent to setpgid(0,0). Not available on all platforms.;T;[o;H ;II" overload;F;J0;;D;K0;#I" setpgrp;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @D;[;I"@return [0];T;0; @D;@F;Mi;N0;[; @D;[;I"oEquivalent to setpgid(0,0). Not available on all platforms. @overload setpgrp @return [0];T;0; @D;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@B;#@C;$To; ; F; ;,;;;I"Process#getpgid;F;[[I"pid;T0;[[@i7;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;H ;II" overload;F;J0;;E;K0;#I"getpgid(pid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Y;[;I"@return [Integer];T;0; @Y;@F;Mi;N0;[[I"pid;T0; @Y;[;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; @Y;@F;N0;!@{;"I"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; ; T; ;;;;I"Process.getpgid;F;@[;@^;T;;E;0;@`;{;IC;"Returns the process group ID for the given process id. Not available on all platforms. Process.getpgid(Process.ppid()) #=> 25527;T;[o;H ;II" overload;F;J0;;E;K0;#I"getpgid(pid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @w;[;I"@return [Integer];T;0; @w;@F;Mi;N0;[[I"pid;T0; @w;[;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; @w;@F;Ao;B;CT;Di-;Ei4;Mi;!@{;"@u;#@v;$To; ; F; ;,;;;I"Process#setpgid;F;[[I"pid;T0[I" pgrp;T0;[[@iN;T;: setpgid;0;[;{;IC;"wSets the process group ID of _pid_ (0 indicates this process) to integer. Not available on all platforms. ;T;[o;H ;II" overload;F;J0;;F;K0;#I"setpgid(pid, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;N0;!@{;"I"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; ; T; ;;;;I"Process.setpgid;F;@;@;T;;F;0;@;{;IC;"wSets the process group ID of _pid_ (0 indicates this process) to integer. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;F;K0;#I"setpgid(pid, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiF;EiK;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#getsid;F;[[@0;[[@ik;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;H ;II" overload;F;J0;;G;K0;#I" getsid();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ɉ;[;I"@return [Integer];T;0; @ɉ;@F;Mi;N0;[; @ɉo;H ;II" overload;F;J0;;G;K0;#I"getsid(pid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ɉ;[;I"@return [Integer];T;0; @ɉ;@F;Mi;N0;[[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;N0;!@{;"I"static VALUE proc_getsid(int argc, VALUE *argv) { 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; ; T; ;;;;I"Process.getsid;F;@ˉ;@͉;T;;G;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;H ;II" overload;F;J0;;G;K0;#I" getsid();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;G;K0;#I"getsid(pid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di_;Eij;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#setsid;F;[;[[@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;H ;II" overload;F;J0;;H;K0;#I" setsid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@{;"I"static VALUE proc_setsid(void) { rb_pid_t pid; pid = setsid(); if (pid < 0) rb_sys_fail(0); return PIDT2NUM(pid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.setsid;F;@;@;T;;H;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;H ;II" overload;F;J0;;H;K0;#I" setsid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @1;[;I"@return [Integer];T;0; @1;@F;Mi;N0;[; @1;[;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; @1;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@/;#@0;$To; ; F; ;,;;;I"Process#getpriority;F;[[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;H ;II" overload;F;J0;;I;K0;#I"getpriority(kind, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @F;[;I"@return [Integer];T;0; @F;@F;Mi;N0;[[I" kind;T0[I" integer;T0; @F;[;I"]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 @overload getpriority(kind, integer) @return [Integer];T;0; @F;@F;N0;!@{;"I"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; ; T; ;;;;I"Process.getpriority;F;@H;@M;T;;I;0;@O;{;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;H ;II" overload;F;J0;;I;K0;#I"getpriority(kind, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @h;[;I"@return [Integer];T;0; @h;@F;Mi;N0;[[I" kind;T0[I" integer;T0; @h;[;I"^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 @overload getpriority(kind, integer) @return [Integer];T;0; @h;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@f;#@g;$To; ; F; ;,;;;I"Process#setpriority;F;[[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;H ;II" overload;F;J0;;J;K0;#I")setpriority(kind, integer, priority);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" kind;T0[I" integer;T0[I" priority;T0; @;[;I"ZSee 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;N0;!@{;"I"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; ; T; ;;;;I"Process.setpriority;F;@;@;T;;J;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;H ;II" overload;F;J0;;J;K0;#I")setpriority(kind, integer, priority);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" kind;T0[I" integer;T0[I" priority;T0; @;[;I"[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 @overload setpriority(kind, integer, priority) @return [0];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To;9;[[@i;F;:PRIO_PROCESS;;;;;;[;{;IC;"see Process.setpriority ;T;[;[;I"see Process.setpriority;T;0; @Š;@F;Ao;B;CT;Di;Ei;!@{;I"Process::PRIO_PROCESS;F;: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;H ;II" overload;F;J0;;N;K0;#I"getrlimit(resource);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" resource;T0; @;[;I"vGets 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;N0;!@{;"I"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; ; T; ;;;;I"Process.getrlimit;F;@;@;T;;N;0;@;{;IC;"EGets 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;H ;II" overload;F;J0;;N;K0;#I"getrlimit(resource);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" resource;T0; @;[;I"wGets 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;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#setrlimit;F;[[@0;[[@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;H ;II" overload;F;J0;;O;K0;#I".setrlimit(resource, cur_limit, max_limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" resource;T0[I"cur_limit;T0[I"max_limit;T0; @o;H ;II" overload;F;J0;;O;K0;#I"#setrlimit(resource, cur_limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" resource;T0[I"cur_limit;T0; @;[;I"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]) @overload setrlimit(resource, cur_limit, max_limit) @return [nil] @overload setrlimit(resource, cur_limit) @return [nil];T;0; @;@F;N0;!@{;"I"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; ; T; ;;;;I"Process.setrlimit;F;@;@;T;;O;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;H ;II" overload;F;J0;;O;K0;#I".setrlimit(resource, cur_limit, max_limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @M;[;I"@return [nil];T;0; @M;@F;Mi;N0;[[I" resource;T0[I"cur_limit;T0[I"max_limit;T0; @Mo;H ;II" overload;F;J0;;O;K0;#I"#setrlimit(resource, cur_limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @M;[;I"@return [nil];T;0; @M;@F;Mi;N0;[[I" resource;T0[I"cur_limit;T0; @M;[;I"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]) @overload setrlimit(resource, cur_limit, max_limit) @return [nil] @overload setrlimit(resource, cur_limit) @return [nil];T;0; @M;@F;Ao;B;CT;Di;Ei,;Mi;!@{;"@K;#@L;$To;9;[[@i;F;:RLIM_SAVED_MAX;;;;;;[;{;IC;"see Process.setrlimit ;T;[;[;I"see Process.setrlimit;T;0; @y;@F;Ao;B;CT;Di;Ei;!@{;I"Process::RLIM_SAVED_MAX;F; 501 ;T;[o;H ;II" overload;F;J0;;c;K0;#I"uid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @];[;I"@return [Integer];T;0; @];@F;Mi;N0;[; @]o;H ;II" overload;F;J0;:Process::UID.rid;K0;#I"Process::UID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @];[;I"@return [Integer];T;0; @];@F;Mi;N0;[; @]o;H ;II" overload;F;J0;:Process::Sys.getuid;K0;#I"Process::Sys.getuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @];[;I"@return [Integer];T;0; @];@F;Mi;N0;[; @];[;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;N0;!@{;"I"cstatic VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.uid;F;@_;@`;T;;c;0;@b;{;IC;"JReturns the (real) user ID of this process. Process.uid #=> 501;T;[o;H ;II" overload;F;J0;;c;K0;#I"uid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;d;K0;#I"Process::UID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;e;K0;#I"Process::Sys.getuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di|;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#uid=;F;[[I"id;T0;[[@i;T;: uid=;0;[;{;IC;"NSets the (user) user ID for this process. Not available on all platforms. ;T;[o;H ;II" overload;F;J0;;f;K0;#I"uid=(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[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;N0;!@{;"I"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; ; T; ;;;;I"Process.uid=;F;@Œ;@Ō;T;;f;0;@nj;{;IC;"NSets the (user) user ID for this process. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;f;K0;#I"uid=(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @ތ;[;I"@return [Numeric];T;0; @ތ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@{;"@܌;#@݌;$To; ; F; ;,;;;I"Process#gid;F;[;[[@i;T;:gid;0;[;{;IC;"LReturns the (real) group ID for this process. Process.gid #=> 500 ;T;[o;H ;II" overload;F;J0;;g;K0;#I"gid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:Process::GID.rid;K0;#I"Process::GID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:Process::Sys.getgid;K0;#I"Process::Sys.getgid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@{;"I"cstatic VALUE proc_getgid(VALUE obj) { rb_gid_t gid = getgid(); return GIDT2NUM(gid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.gid;F;@;@;T;;g;0;@;{;IC;"LReturns the (real) group ID for this process. Process.gid #=> 500;T;[o;H ;II" overload;F;J0;;g;K0;#I"gid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @);[;I"@return [Integer];T;0; @);@F;Mi;N0;[; @)o;H ;II" overload;F;J0;;h;K0;#I"Process::GID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @);[;I"@return [Integer];T;0; @);@F;Mi;N0;[; @)o;H ;II" overload;F;J0;;i;K0;#I"Process::Sys.getgid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @);[;I"@return [Integer];T;0; @);@F;Mi;N0;[; @);[;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;Ao;B;CT;Di;Ei;Mi;!@{;"@';#@(;$To; ; F; ;,;;;I"Process#gid=;F;[[I"id;T0;[[@i.;T;: gid=;0;[;{;IC;"(Sets the group ID for this process. ;T;[o;H ;II" overload;F;J0;;j;K0;#I"gid=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @X;[;I"@return [Integer];T;0; @X;@F;Mi;N0;[[I" integer;T0; @X;[;I"USets the group ID for this process. @overload gid=(integer) @return [Integer];T;0; @X;@F;N0;!@{;"I"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; ; T; ;;;;I"Process.gid=;F;@Z;@];T;;j;0;@_;{;IC;"(Sets the group ID for this process.;T;[o;H ;II" overload;F;J0;;j;K0;#I"gid=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @v;[;I"@return [Integer];T;0; @v;@F;Mi;N0;[[I" integer;T0; @v;[;I"VSets the group ID for this process. @overload gid=(integer) @return [Integer];T;0; @v;@F;Ao;B;CT;Di';Ei+;Mi;!@{;"@t;#@u;$To; ; F; ;,;;;I"Process#euid;F;[;[[@iT;T;: euid;0;[;{;IC;"OReturns the effective user ID for this process. Process.euid #=> 501 ;T;[o;H ;II" overload;F;J0;;k;K0;#I" euid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:Process::UID.eid;K0;#I"Process::UID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:Process::Sys.geteuid;K0;#I"Process::Sys.geteuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@{;"I"gstatic VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.euid;F;@;@;T;;k;0;@;{;IC;"OReturns the effective user ID for this process. Process.euid #=> 501;T;[o;H ;II" overload;F;J0;;k;K0;#I" euid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;l;K0;#I"Process::UID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;m;K0;#I"Process::Sys.geteuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiI;EiS;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#euid=;F;[[I" euid;T0;[[@i{;T;: euid=;0;[;{;IC;"QSets the effective user ID for this process. Not available on all platforms. ;T;[o;H ;II" overload;F;J0;;n;K0;#I"euid=(user);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" user;T0; @;[;I"hSets the effective user ID for this process. Not available on all platforms. @overload euid=(user) ;T;0; @;@F;N0;!@{;"I"static VALUE proc_seteuid_m(VALUE mod, VALUE euid) { check_uid_switch(); proc_seteuid(OBJ2UID(euid)); return euid; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.euid=;F;@;@;T;;n;0;@;{;IC;"QSets the effective user ID for this process. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;n;K0;#I"euid=(user);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" user;T0; @ ;[;I"iSets the effective user ID for this process. Not available on all platforms. @overload euid=(user);T;0; @ ;@F;Ao;B;CT;Dis;Eiw;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#egid;F;[;[[@i;T;: egid;0;[;{;IC;"pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 ;T;[o;H ;II" overload;F;J0;;o;K0;#I" egid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:Process::GID.eid;K0;#I"Process::GID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:Process::Sys.geteid;K0;#I"Process::Sys.geteid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@{;"I"hstatic VALUE proc_getegid(VALUE obj) { rb_gid_t egid = getegid(); return GIDT2NUM(egid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.egid;F;@;@;T;;o;0;@ ;{;IC;"pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500;T;[o;H ;II" overload;F;J0;;o;K0;#I" egid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @O;[;I"@return [Integer];T;0; @O;@F;Mi;N0;[; @Oo;H ;II" overload;F;J0;;p;K0;#I"Process::GID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @O;[;I"@return [Integer];T;0; @O;@F;Mi;N0;[; @Oo;H ;II" overload;F;J0;;q;K0;#I"Process::Sys.geteid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @O;[;I"@return [Integer];T;0; @O;@F;Mi;N0;[; @O;[;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; @O;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@M;#@N;$To; ; F; ;,;;;I"Process#egid=;F;[;[;F;: egid=;;0;[;{;IC;" ;T;[;[;I";F;0; @~;@F;N0;!@{;$To; ; T; ;;;;I"Process.egid=;F;@;@;F;;r;;0;@;{;IC;" ;T;[;[;@;0; @;Mi;!@{;$To; ; F; ;,;;;I"Process#initgroups;F;[[I" uname;T0[I" base_grp;T0;[[@i;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;H ;II" overload;F;J0;;s;K0;#I"initgroups(username, gid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" username;T0[I"gid;T0; @;[;I">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] @overload initgroups(username, gid) @return [Array];T;0; @;@F;N0;!@{;"I"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; ; T; ;;;;I"Process.initgroups;F;@;@;T;;s;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;H ;II" overload;F;J0;;s;K0;#I"initgroups(username, gid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" username;T0[I"gid;T0; @;[;I"@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] @overload initgroups(username, gid) @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#groups;F;[;[[@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;H ;II" overload;F;J0;;t;K0;#I" groups;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @Ɏ;[;I"@return [Array];T;0; @Ɏ;@F;Mi;N0;[; @Ɏ;[;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;N0;!@{;"I"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; ; T; ;;;;I"Process.groups;F;@ˎ;@̎;T;;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;H ;II" overload;F;J0;;t;K0;#I" groups;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di~;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#groups=;F;[[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;H ;II" overload;F;J0;;u;K0;#I"groups=(array);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;N0;!@{;"I"_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; ; T; ;;;;I"Process.groups=;F;@;@;T;;u;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;H ;II" overload;F;J0;;u;K0;#I"groups=(array);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#maxgroups;F;[;[[@i;T;:maxgroups;0;[;{;IC;"uReturns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32 ;T;[o;H ;II" overload;F;J0;;v;K0;#I"maxgroups;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-;[;I"@return [Integer];T;0; @-;@F;Mi;N0;[; @-;[;I"Returns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32 @overload maxgroups @return [Integer];T;0; @-;@F;N0;!@{;"I"Sstatic VALUE proc_getmaxgroups(VALUE obj) { return INT2FIX(maxgroups()); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.maxgroups;F;@/;@0;T;;v;0;@2;{;IC;"uReturns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32;T;[o;H ;II" overload;F;J0;;v;K0;#I"maxgroups;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @G;[;I"@return [Integer];T;0; @G;@F;Mi;N0;[; @G;[;I"Returns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32 @overload maxgroups @return [Integer];T;0; @G;@F;Ao;B;CT;Di;Ei ;Mi;!@{;"@E;#@F;$To; ; F; ;,;;;I"Process#maxgroups=;F;[[I"val;T0;[[@i ;T;:maxgroups=;0;[;{;IC;"SSets the maximum number of gids allowed in the supplemental group access list. ;T;[o;H ;II" overload;F;J0;;w;K0;#I"maxgroups=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\;[;I"@return [Integer];T;0; @\;@F;Mi;N0;[[I" integer;T0; @\;[;I"Sets the maximum number of gids allowed in the supplemental group access list. @overload maxgroups=(integer) @return [Integer];T;0; @\;@F;N0;!@{;"I"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 shold 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; ; T; ;;;;I"Process.maxgroups=;F;@^;@a;T;;w;0;@c;{;IC;"SSets the maximum number of gids allowed in the supplemental group access list.;T;[o;H ;II" overload;F;J0;;w;K0;#I"maxgroups=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @z;[;I"@return [Integer];T;0; @z;@F;Mi;N0;[[I" integer;T0; @z;[;I"Sets the maximum number of gids allowed in the supplemental group access list. @overload maxgroups=(integer) @return [Integer];T;0; @z;@F;Ao;B;CT;Di;Ei;Mi;!@{;"@x;#@y;$To; ; F; ;,;;;I"Process#daemon;F;[[@0;[[@iH;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;H ;II" overload;F;J0;;x;K0;#I" daemon();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;x;K0;#I"$daemon(nochdir=nil,noclose=nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;N0;!@{;"I"Sstatic VALUE proc_daemon(int argc, VALUE *argv) { int n, nochdir = FALSE, noclose = FALSE; switch (rb_check_arity(argc, 0, 2)) { case 2: noclose = RTEST(argv[1]); case 1: nochdir = RTEST(argv[0]); } prefork(); n = rb_daemon(nochdir, noclose); if (n < 0) rb_sys_fail("daemon"); return INT2FIX(n); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process.daemon;F;@;@;T;;x;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;H ;II" overload;F;J0;;x;K0;#I" daemon();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;x;K0;#I"$daemon(nochdir=nil,noclose=nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di:;EiF;Mi;!@{;"@;#@;$To; ; F; ;,;;;I"Process#times;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" times;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"aProcessTms;T; @;[;I"@return [aProcessTms];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@{;"I"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; ; T; ;;;;I"Process.times;F;@;@;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;H ;II" overload;F;J0;;;K0;#I" times;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"aProcessTms;T; @;[;I"@return [aProcessTms];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@{;"@;#@;$To;9;[[@il [@io ;F;:CLOCK_REALTIME;;;;;;[;{;IC;"see Process.clock_gettime ;T;[;[;I"see Process.clock_gettime;T;0; @;@F;Ao;B;CT;Din ;Ein ;!@{;I"Process::CLOCK_REALTIME;F; 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 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, 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 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;H ;II" overload;F;J0;;;K0;#I"%clock_gettime(clock_id [, unit]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @-;[;I"@return [Numeric];T;0; @-;@F;Mi;N0;[[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 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, 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 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;N0;!@{;"I"VALUE rb_clock_gettime(int argc, VALUE *argv) { 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" VALUE;T;$To; ; T; ;;;;I"Process.clock_gettime;F;@/;@1;T;;;0;@3;{;IC;"LReturns 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 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, 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 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;H ;II" overload;F;J0;;;K0;#I"%clock_gettime(clock_id [, unit]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @J;[;I"@return [Numeric];T;0; @J;@F;Mi;N0;[[I"clock_id[, unit];T0; @J;[;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 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, 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 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; @J;@F;Ao;B;CT;Di;Ei0;Mi;!@{;"@H;#@I;$To; ; F; ;,;;;I"Process#clock_getres;F;[[@0;[[@i;T;:clock_getres;0;[;{;IC;"Returns the time resolution returned by POSIX clock_getres() function. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as +Process.clock_gettime+. However the result may not be accurate. For example, +Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME)+ returns 1.0e-06 which means 1 microsecond, but actual resolution can be more coarse. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means a the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for times() function and CLOCKS_PER_SEC for 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;H ;II" overload;F;J0;;;K0;#I"$clock_getres(clock_id [, unit]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @a;[;I"@return [Numeric];T;0; @a;@F;Mi;N0;[[I"clock_id[, unit];T0; @a;[;I"Returns the time resolution returned by POSIX clock_getres() function. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as +Process.clock_gettime+. However the result may not be accurate. For example, +Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME)+ returns 1.0e-06 which means 1 microsecond, but actual resolution can be more coarse. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means a the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for times() function and CLOCKS_PER_SEC for 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; @a;@F;N0;!@{;"I" VALUE rb_clock_getres(int argc, VALUE *argv) { 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" VALUE;T;$To; ; T; ;;;;I"Process.clock_getres;F;@c;@e;T;;;0;@g;{;IC;"Returns the time resolution returned by POSIX clock_getres() function. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as +Process.clock_gettime+. However the result may not be accurate. For example, +Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME)+ returns 1.0e-06 which means 1 microsecond, but actual resolution can be more coarse. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means a the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for times() function and CLOCKS_PER_SEC for 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;H ;II" overload;F;J0;;;K0;#I"$clock_getres(clock_id [, unit]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @~;[;I"@return [Numeric];T;0; @~;@F;Mi;N0;[[I"clock_id[, unit];T0; @~;[;I"Returns the time resolution returned by POSIX clock_getres() function. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as +Process.clock_gettime+. However the result may not be accurate. For example, +Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME)+ returns 1.0e-06 which means 1 microsecond, but actual resolution can be more coarse. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means a the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for times() function and CLOCKS_PER_SEC for 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;Ao;B;CT;Di;Ei;Mi;!@{;"@|;#@};$To; ;IC;[o; ; F; ;,;;;I"Process::UID#rid;F;[;[[@i;T;:rid;0;[;{;IC;"JReturns the (real) user ID of this process. Process.uid #=> 501 ;T;[o;H ;II" overload;F;J0;;c;K0;#I"uid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;d;K0;#I"Process::UID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;e;K0;#I"Process::Sys.getuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"cstatic VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::UID.rid;F;@;@;T;;;0;@;{;IC;"JReturns the (real) user ID of this process. Process.uid #=> 501;T;[o;H ;II" overload;F;J0;;c;K0;#I"uid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ˑ;[;I"@return [Integer];T;0; @ˑ;@F;Mi;N0;[; @ˑo;H ;II" overload;F;J0;;d;K0;#I"Process::UID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ˑ;[;I"@return [Integer];T;0; @ˑ;@F;Mi;N0;[; @ˑo;H ;II" overload;F;J0;;e;K0;#I"Process::Sys.getuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ˑ;[;I"@return [Integer];T;0; @ˑ;@F;Mi;N0;[; @ˑ;[;@;0; @ˑ;@F;Ao;B;CT;Di|;Ei;Mi;!@;"@ɑ;#@ʑ;$To; ; F; ;,;;;I"Process::UID#eid;F;[;[[@iT;T;:eid;0;[;{;IC;"OReturns the effective user ID for this process. Process.euid #=> 501 ;T;[o;H ;II" overload;F;J0;;k;K0;#I" euid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;l;K0;#I"Process::UID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;m;K0;#I"Process::Sys.geteuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"gstatic VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::UID.eid;F;@;@;T;;;0;@;{;IC;"OReturns the effective user ID for this process. Process.euid #=> 501;T;[o;H ;II" overload;F;J0;;k;K0;#I" euid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-;[;I"@return [Integer];T;0; @-;@F;Mi;N0;[; @-o;H ;II" overload;F;J0;;l;K0;#I"Process::UID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-;[;I"@return [Integer];T;0; @-;@F;Mi;N0;[; @-o;H ;II" overload;F;J0;;m;K0;#I"Process::Sys.geteuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-;[;I"@return [Integer];T;0; @-;@F;Mi;N0;[; @-;[;@;0; @-;@F;Ao;B;CT;DiI;EiS;Mi;!@;"@+;#@,;$To; ; F; ;,;;;I""Process::UID#change_privilege;F;[[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;H ;II" overload;F;J0;:"Process::UID.change_privilege;K0;#I"(Process::UID.change_privilege(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @[;[;I"@return [Integer];T;0; @[;@F;Mi;N0;[[I" user;T0; @[;[;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; @[;@F;N0;!@;"I"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; ; T; ;;;;I""Process::UID.change_privilege;F;@];@`;T;;;0;@b;{;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;H ;II" overload;F;J0;;;K0;#I"(Process::UID.change_privilege(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @y;[;I"@return [Integer];T;0; @y;@F;Mi;N0;[[I" user;T0; @y;[;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; @y;@F;Ao;B;CT;Di;Ei;Mi;!@;"@w;#@x;$To; ; F; ;,;;;I"!Process::UID#grant_privilege;F;[[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;H ;II" overload;F;J0;:!Process::UID.grant_privilege;K0;#I"'Process::UID.grant_privilege(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" user;T0; @o;H ;II" overload;F;J0;:Process::UID.eid=;K0;#I"Process::UID.eid= user;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"qstatic VALUE p_uid_grant_privilege(VALUE obj, VALUE id) { rb_seteuid_core(OBJ2UID(id)); return id; };T;#I"static VALUE;T;$To; ; T; ;;;;I"!Process::UID.grant_privilege;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"'Process::UID.grant_privilege(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" user;T0; @o;H ;II" overload;F;J0;;;K0;#I"Process::UID.eid= user;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::UID#re_exchange;F;[;[[@ih;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;H ;II" overload;F;J0;:Process::UID.re_exchange;K0;#I"Process::UID.re_exchange;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"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; ; T; ;;;;I"Process::UID.re_exchange;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"Process::UID.re_exchange;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di\;Eie;Mi;!@;"@;#@;$To; ; F; ;,;;;I""Process::UID#re_exchangeable?;F;[;[[@iO;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;H ;II" overload;F;J0;:"Process::UID.re_exchangeable?;K0;#I""Process::UID.re_exchangeable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"static VALUE p_uid_exchangeable(void) { #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; ; T; ;;;;I""Process::UID.re_exchangeable?;F;@;@;T;;;0;@;{;IC;"mReturns +true+ if the real and effective user IDs of a process may be exchanged on the current platform.;T;[o;H ;II" overload;F;J0;;;K0;#I""Process::UID.re_exchangeable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @,;[;I"@return [Boolean];T;0; @,;@F;Mi;N0;[; @,;[;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;Ao;B;CT;DiF;EiL;Mi;!@;"@*;#@+;$To; ; F; ;,;;;I" Process::UID#sid_available?;F;[;[[@i;T;:sid_available?;0;[;{;IC;"LReturns +true+ if the current platform has saved user ID functionality. ;T;[o;H ;II" overload;F;J0;: Process::UID.sid_available?;K0;#I" Process::UID.sid_available?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A;[;I"@return [Boolean];T;0; @A;@F;Mi;N0;[; @A;[;I"Returns +true+ if the current platform has saved user ID functionality. @overload Process::UID.sid_available? @return [Boolean];T;0; @A;@F;N0;!@;"I"static VALUE p_uid_have_saved_id(void) { #if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS) return Qtrue; #else return Qfalse; #endif };T;#I"static VALUE;T;$To; ; T; ;;;;I" Process::UID.sid_available?;F;@C;@D;T;;;0;@F;{;IC;"LReturns +true+ if the current platform has saved user ID functionality.;T;[o;H ;II" overload;F;J0;;;K0;#I" Process::UID.sid_available?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @[;[;I"@return [Boolean];T;0; @[;@F;Mi;N0;[; @[;[;I"Returns +true+ if the current platform has saved user ID functionality. @overload Process::UID.sid_available? @return [Boolean];T;0; @[;@F;Ao;B;CT;Di;Ei;Mi;!@;"@Y;#@Z;$To; ; F; ;,;;;I"Process::UID#switch;F;[;[[@i;T;: switch;0;[;{;IC;" ;T;[;[;I";F;0; @p;@F;N0;!@;"I"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; ; T; ;;;;I"Process::UID.switch;F;@r;@s;T;;;0;@u;{;IC;" ;T;[;[;@;0; @};Mi;!@;"@{;#@|;$To; ; F; ;,;;;I"Process::UID#from_name;F;[[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;H ;II" overload;F;J0;:Process::UID.from_name;K0;#I"!Process::UID.from_name(name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;N0;!@;"I"]static VALUE p_uid_from_name(VALUE self, VALUE id) { return UIDT2NUM(OBJ2UID(id)); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::UID.from_name;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"!Process::UID.from_name(name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i ;F;:UID;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@{;I"Process::UID;Fo; ;IC;[o; ; F; ;,;;;I"Process::GID#rid;F;[;[[@i;T;;;0;[;{;IC;"LReturns the (real) group ID for this process. Process.gid #=> 500 ;T;[o;H ;II" overload;F;J0;;g;K0;#I"gid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I"Process::GID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;i;K0;#I"Process::Sys.getgid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"cstatic VALUE proc_getgid(VALUE obj) { rb_gid_t gid = getgid(); return GIDT2NUM(gid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::GID.rid;F;@;@“;T;;;0;@ē;{;IC;"LReturns the (real) group ID for this process. Process.gid #=> 500;T;[o;H ;II" overload;F;J0;;g;K0;#I"gid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I"Process::GID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;i;K0;#I"Process::Sys.getgid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@V;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::GID#eid;F;[;[[@i;T;;;0;[;{;IC;"pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 ;T;[o;H ;II" overload;F;J0;;o;K0;#I" egid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @!;[;I"@return [Integer];T;0; @!;@F;Mi;N0;[; @!o;H ;II" overload;F;J0;;p;K0;#I"Process::GID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @!;[;I"@return [Integer];T;0; @!;@F;Mi;N0;[; @!o;H ;II" overload;F;J0;;q;K0;#I"Process::Sys.geteid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @!;[;I"@return [Integer];T;0; @!;@F;Mi;N0;[; @!;[;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;N0;!@;"I"hstatic VALUE proc_getegid(VALUE obj) { rb_gid_t egid = getegid(); return GIDT2NUM(egid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::GID.eid;F;@#;@$;T;;;0;@&;{;IC;"pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500;T;[o;H ;II" overload;F;J0;;o;K0;#I" egid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U;[;I"@return [Integer];T;0; @U;@F;Mi;N0;[; @Uo;H ;II" overload;F;J0;;p;K0;#I"Process::GID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U;[;I"@return [Integer];T;0; @U;@F;Mi;N0;[; @Uo;H ;II" overload;F;J0;;q;K0;#I"Process::Sys.geteid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U;[;I"@return [Integer];T;0; @U;@F;Mi;N0;[; @U;[;@|;0; @U;@F;Ao;B;CT;Di;Ei;Mi;!@;"@S;#@T;$To; ; F; ;,;;;I""Process::GID#change_privilege;F;[[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;H ;II" overload;F;J0;:"Process::GID.change_privilege;K0;#I")Process::GID.change_privilege(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I""Process::GID.change_privilege;F;@;@;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;H ;II" overload;F;J0;;;K0;#I")Process::GID.change_privilege(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"!Process::GID#grant_privilege;F;[[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;H ;II" overload;F;J0;:!Process::GID.grant_privilege;K0;#I"(Process::GID.grant_privilege(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" group;T0; @o;H ;II" overload;F;J0;;p;K0;#I"Process::GID.eid = group;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"qstatic VALUE p_gid_grant_privilege(VALUE obj, VALUE id) { rb_setegid_core(OBJ2GID(id)); return id; };T;#I"static VALUE;T;$To; ; T; ;;;;I"!Process::GID.grant_privilege;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"(Process::GID.grant_privilege(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" group;T0; @o;H ;II" overload;F;J0;;p;K0;#I"Process::GID.eid = group;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di0;Ei<;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::GID#re_exchange;F;[;[[@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;H ;II" overload;F;J0;:Process::GID.re_exchange;K0;#I"Process::GID.re_exchange;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[; @ ;[;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;N0;!@;"I"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; ; T; ;;;;I"Process::GID.re_exchange;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"Process::GID.re_exchange;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @';[;I"@return [Integer];T;0; @';@F;Mi;N0;[; @';[;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;Ao;B;CT;Di;Ei;Mi;!@;"@%;#@&;$To; ; F; ;,;;;I""Process::GID#re_exchangeable?;F;[;[[@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;H ;II" overload;F;J0;:"Process::GID.re_exchangeable?;K0;#I""Process::GID.re_exchangeable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @<;[;I"@return [Boolean];T;0; @<;@F;Mi;N0;[; @<;[;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; @<;@F;N0;!@;"I"static VALUE p_gid_exchangeable(void) { #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; ; T; ;;;;I""Process::GID.re_exchangeable?;F;@>;@?;T;;;0;@A;{;IC;"nReturns +true+ if the real and effective group IDs of a process may be exchanged on the current platform.;T;[o;H ;II" overload;F;J0;;;K0;#I""Process::GID.re_exchangeable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @V;[;I"@return [Boolean];T;0; @V;@F;Mi;N0;[; @V;[;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; @V;@F;Ao;B;CT;Di;Ei;Mi;!@;"@T;#@U;$To; ; F; ;,;;;I" Process::GID#sid_available?;F;[;[[@i>;T;;;0;[;{;IC;"MReturns +true+ if the current platform has saved group ID functionality. ;T;[o;H ;II" overload;F;J0;: Process::GID.sid_available?;K0;#I" Process::GID.sid_available?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @k;[;I"@return [Boolean];T;0; @k;@F;Mi;N0;[; @k;[;I"Returns +true+ if the current platform has saved group ID functionality. @overload Process::GID.sid_available? @return [Boolean];T;0; @k;@F;N0;!@;"I"static VALUE p_gid_have_saved_id(void) { #if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS) return Qtrue; #else return Qfalse; #endif };T;#I"static VALUE;T;$To; ; T; ;;;;I" Process::GID.sid_available?;F;@m;@n;T;;;0;@p;{;IC;"MReturns +true+ if the current platform has saved group ID functionality.;T;[o;H ;II" overload;F;J0;;;K0;#I" Process::GID.sid_available?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"Returns +true+ if the current platform has saved group ID functionality. @overload Process::GID.sid_available? @return [Boolean];T;0; @;@F;Ao;B;CT;Di5;Ei;;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::GID#switch;F;[;[[@i;T;;;0;[;{;IC;" ;T;[;[;I";F;0; @;@F;N0;!@;"I"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; ; T; ;;;;I"Process::GID.switch;F;@;@;T;;;0;@;{;IC;" ;T;[;[;@;0; @;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::GID#from_name;F;[[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;H ;II" overload;F;J0;:Process::GID.from_name;K0;#I"!Process::GID.from_name(name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;N0;!@;"I"]static VALUE p_gid_from_name(VALUE self, VALUE id) { return GIDT2NUM(OBJ2GID(id)); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::GID.from_name;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"!Process::GID.from_name(name);T;IC;";T;[;[;I";T;0; @ƕ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@ĕ;#@ŕ;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i ;F;:GID;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@{;I"Process::GID;Fo; ;IC;[#o; ; F; ;,;;;I"Process::Sys#getuid;F;[;[[@i;T;: getuid;0;[;{;IC;"JReturns the (real) user ID of this process. Process.uid #=> 501 ;T;[o;H ;II" overload;F;J0;;c;K0;#I"uid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;d;K0;#I"Process::UID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;e;K0;#I"Process::Sys.getuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"cstatic VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::Sys.getuid;F;@;@;T;;;0;@;{;IC;"JReturns the (real) user ID of this process. Process.uid #=> 501;T;[o;H ;II" overload;F;J0;;c;K0;#I"uid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;d;K0;#I"Process::UID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;e;K0;#I"Process::Sys.getuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di|;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::Sys#geteuid;F;[;[[@iT;T;: geteuid;0;[;{;IC;"OReturns the effective user ID for this process. Process.euid #=> 501 ;T;[o;H ;II" overload;F;J0;;k;K0;#I" euid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @K;[;I"@return [Integer];T;0; @K;@F;Mi;N0;[; @Ko;H ;II" overload;F;J0;;l;K0;#I"Process::UID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @K;[;I"@return [Integer];T;0; @K;@F;Mi;N0;[; @Ko;H ;II" overload;F;J0;;m;K0;#I"Process::Sys.geteuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @K;[;I"@return [Integer];T;0; @K;@F;Mi;N0;[; @K;[;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; @K;@F;N0;!@;"I"gstatic VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::Sys.geteuid;F;@M;@N;T;;;0;@P;{;IC;"OReturns the effective user ID for this process. Process.euid #=> 501;T;[o;H ;II" overload;F;J0;;k;K0;#I" euid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;l;K0;#I"Process::UID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;m;K0;#I"Process::Sys.geteuid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;DiI;EiS;Mi;!@;"@};#@~;$To; ; F; ;,;;;I"Process::Sys#getgid;F;[;[[@i;T;: getgid;0;[;{;IC;"LReturns the (real) group ID for this process. Process.gid #=> 500 ;T;[o;H ;II" overload;F;J0;;g;K0;#I"gid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I"Process::GID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;i;K0;#I"Process::Sys.getgid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"cstatic VALUE proc_getgid(VALUE obj) { rb_gid_t gid = getgid(); return GIDT2NUM(gid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::Sys.getgid;F;@;@;T;;;0;@;{;IC;"LReturns the (real) group ID for this process. Process.gid #=> 500;T;[o;H ;II" overload;F;J0;;g;K0;#I"gid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I"Process::GID.rid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;i;K0;#I"Process::Sys.getgid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@V;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"@ߖ;#@;$To; ; F; ;,;;;I"Process::Sys#getegid;F;[;[[@i;T;: getegid;0;[;{;IC;"pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 ;T;[o;H ;II" overload;F;J0;;o;K0;#I" egid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;p;K0;#I"Process::GID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;q;K0;#I"Process::Sys.geteid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"hstatic VALUE proc_getegid(VALUE obj) { rb_gid_t egid = getegid(); return GIDT2NUM(egid); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::Sys.getegid;F;@;@;T;;;0;@;{;IC;"pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500;T;[o;H ;II" overload;F;J0;;o;K0;#I" egid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @C;[;I"@return [Integer];T;0; @C;@F;Mi;N0;[; @Co;H ;II" overload;F;J0;;p;K0;#I"Process::GID.eid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @C;[;I"@return [Integer];T;0; @C;@F;Mi;N0;[; @Co;H ;II" overload;F;J0;;q;K0;#I"Process::Sys.geteid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @C;[;I"@return [Integer];T;0; @C;@F;Mi;N0;[; @C;[;@|;0; @C;@F;Ao;B;CT;Di;Ei;Mi;!@;"@A;#@B;$To; ; F; ;,;;;I"Process::Sys#setuid;F;[[I"id;T0;[[@i ;T;: setuid;0;[;{;IC;"VSet the user ID of the current process to _user_. Not available on all platforms. ;T;[o;H ;II" overload;F;J0;:Process::Sys.setuid;K0;#I"Process::Sys.setuid(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @q;[;I"@return [nil];T;0; @q;@F;Mi;N0;[[I" user;T0; @q;[;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; @q;@F;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.setuid;F;@s;@v;T;;;0;@x;{;IC;"VSet the user ID of the current process to _user_. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;;K0;#I"Process::Sys.setuid(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::Sys#setgid;F;[[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;H ;II" overload;F;J0;:Process::Sys.setgid;K0;#I"Process::Sys.setgid(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.setgid;F;@;@;T;;;0;@;{;IC;"XSet the group ID of the current process to _group_. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;;K0;#I"Process::Sys.setgid(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ė;[;I"@return [nil];T;0; @ė;@F;Mi;N0;[[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;Ao;B;CT;Di|;Ei;Mi;!@;"@—;#@×;$To; ; F; ;,;;;I"Process::Sys#setruid;F;[[I"id;T0;[[@i;T;: setruid;0;[;{;IC;"[Set the real user ID of the calling process to _user_. Not available on all platforms. ;T;[o;H ;II" overload;F;J0;:Process::Sys.setruid;K0;#I"Process::Sys.setruid(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ۗ;[;I"@return [nil];T;0; @ۗ;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.setruid;F;@ݗ;@;T;;;0;@;{;IC;"[Set the real user ID of the calling process to _user_. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;;K0;#I"Process::Sys.setruid(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::Sys#setrgid;F;[[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;H ;II" overload;F;J0;:Process::Sys.setrgid;K0;#I" Process::Sys.setrgid(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.setrgid;F;@;@;T;;;0;@;{;IC;"]Set the real group ID of the calling process to _group_. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;;K0;#I" Process::Sys.setrgid(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @.;[;I"@return [nil];T;0; @.;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@,;#@-;$To; ; F; ;,;;;I"Process::Sys#seteuid;F;[[I"id;T0;[[@i5;T;: seteuid;0;[;{;IC;"aSet the effective user ID of the calling process to _user_. Not available on all platforms. ;T;[o;H ;II" overload;F;J0;:Process::Sys.seteuid;K0;#I"Process::Sys.seteuid(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @E;[;I"@return [nil];T;0; @E;@F;Mi;N0;[[I" user;T0; @E;[;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; @E;@F;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.seteuid;F;@G;@J;T;;;0;@L;{;IC;"aSet the effective user ID of the calling process to _user_. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;;K0;#I"Process::Sys.seteuid(user);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @c;[;I"@return [nil];T;0; @c;@F;Mi;N0;[[I" user;T0; @c;[;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; @c;@F;Ao;B;CT;Di,;Ei2;Mi;!@;"@a;#@b;$To; ; F; ;,;;;I"Process::Sys#setegid;F;[[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;H ;II" overload;F;J0;:Process::Sys.setegid;K0;#I" Process::Sys.setegid(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @z;[;I"@return [nil];T;0; @z;@F;Mi;N0;[[I" group;T0; @z;[;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; @z;@F;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.setegid;F;@|;@;T;;;0;@;{;IC;"cSet the effective group ID of the calling process to _group_. Not available on all platforms.;T;[o;H ;II" overload;F;J0;;;K0;#I" Process::Sys.setegid(group);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::Sys#setreuid;F;[[I"rid;T0[I"eid;T0;[[@iM;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;H ;II" overload;F;J0;:Process::Sys.setreuid;K0;#I"$Process::Sys.setreuid(rid, eid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.setreuid;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"$Process::Sys.setreuid(rid, eid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ј;[;I"@return [nil];T;0; @ј;@F;Mi;N0;[[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;Ao;B;CT;DiB;EiJ;Mi;!@;"@Ϙ;#@И;$To; ; F; ;,;;;I"Process::Sys#setregid;F;[[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;H ;II" overload;F;J0;:Process::Sys.setregid;K0;#I"$Process::Sys.setregid(rid, eid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"static VALUE p_sys_setregid(VALUE obj, VALUE rid, VALUE eid) { rb_gid_t rgid, egid; PREPARE_GETGRNAM; check_gid_switch(); rgid = OBJ2GID(rid); egid = OBJ2GID(eid); FINISH_GETGRNAM; if (setregid(rgid, egid) != 0) rb_sys_fail(0); return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::Sys.setregid;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"$Process::Sys.setregid(rid, eid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"@return [nil];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@ ;#@ ;$To; ; F; ;,;;;I"Process::Sys#setresuid;F;[[I"rid;T0[I"eid;T0[I"sid;T0;[[@ij;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;H ;II" overload;F;J0;:Process::Sys.setresuid;K0;#I"*Process::Sys.setresuid(rid, eid, sid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @%;[;I"@return [nil];T;0; @%;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"Process::Sys.setresuid;F;@';@.;T;;;0;@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;H ;II" overload;F;J0;;;K0;#I"*Process::Sys.setresuid(rid, eid, sid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @K;[;I"@return [nil];T;0; @K;@F;Mi;N0;[[I"rid;T0[I"eid;T0[I"sid;T0; @K;[;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; @K;@F;Ao;B;CT;Di_;Eig;Mi;!@;"@I;#@J;$To; ; F; ;,;;;I"Process::Sys#setresgid;F;[[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;H ;II" overload;F;J0;:Process::Sys.setresgid;K0;#I"*Process::Sys.setresgid(rid, eid, sid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @f;[;I"@return [nil];T;0; @f;@F;Mi;N0;[[I"rid;T0[I"eid;T0[I"sid;T0; @f;[;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; @f;@F;N0;!@;"I"Dstatic VALUE p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) { rb_gid_t rgid, egid, sgid; PREPARE_GETGRNAM; check_gid_switch(); rgid = OBJ2GID(rid); egid = OBJ2GID(eid); sgid = OBJ2GID(sid); FINISH_GETGRNAM; if (setresgid(rgid, egid, sgid) != 0) rb_sys_fail(0); return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::Sys.setresgid;F;@h;@o;T;;;0;@q;{;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;H ;II" overload;F;J0;;;K0;#I"*Process::Sys.setresgid(rid, eid, sid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Process::Sys#issetugid;F;[;[[@i;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;H ;II" overload;F;J0;:Process::Sys.issetugid;K0;#I"Process::Sys.issetugid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"}static VALUE p_sys_issetugid(VALUE obj) { if (issetugid()) { return Qtrue; } else { return Qfalse; } };T;#I"static VALUE;T;$To; ; T; ;;;;I"Process::Sys.issetugid;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"Process::Sys.issetugid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i ;F;:Sys;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@{;I"Process::Sys;F;&@{;'IC;[;&@{;(IC;[;&@{;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@iz;T;; ;;0;;;[;{;IC;" Module to handle processes.;T;[;[;I"" Module to handle processes. ;T;0; @{;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Process;Fo;9;[[@{i ;F;: ARGV;;;;;;[;{;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;Ao;B;CT;Di ;Ei ;!@;I" ARGV;F;= 0) close(p[0]); if (p[1] >= 0) close(p[1]); if (kqfd >= 0) close(kqfd); if (msg) { if (e) rb_syserr_fail(e, msg); rb_raise(rb_eRuntimeError, "%s", msg); } return ret; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#console_info;F;[;[[I")ext/-test-/win32/console/attribute.c;Ti;T;:console_info;0;[;{;IC;" ;T;[;[;@;0; @2;!@;"I"static VALUE console_info(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; ; F; ;,;;;I"IO#console_attribute;F;[[I" attr;T0;[[@7i$;T;:console_attribute;0;[;{;IC;" ;T;[;[;@;0; @?;!@;"I"static VALUE console_set_attribute(VALUE io, VALUE attr) { HANDLE h = io_handle(io); SetConsoleTextAttribute(h, (WORD)NUM2INT(attr)); return Qnil; };T;#I"static VALUE;T;$To; ;IC;[;&@M;'IC;[;&@M;(IC;[;&@M;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3[I"ext/openssl/ossl_ssl.c;TiQ ;F;:WaitReadable;;0;;;[;{;IC;" ;T;[;[;@;0; @M;!@;I"IO::WaitReadable;Fo; ;IC;[;&@`;'IC;[;&@`;(IC;[;&@`;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3[@YiR ;F;:WaitWritable;;0;;;[;{;IC;" ;T;[;[;@;0; @`;!@;I"IO::WaitWritable;Fo; ;IC;[;&@r;'IC;[;&@r;(IC;[@M;&@r;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3;F;:EAGAINWaitReadable;;0;;;[;{;IC;" ;T;[;[;@;0; @r;!@;I"IO::EAGAINWaitReadable;F;1o;2 ;30;40;50;: EAGAIN;!@;70;F;o; ;IC;[;&@;'IC;[;&@;(IC;[@`;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3;F;:EAGAINWaitWritable;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I"IO::EAGAINWaitWritable;F;1o;2 ;30;40;50;;;!@;70;F;o; ;IC;[;&@;'IC;[;&@;(IC;[@M;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3;F;:EWOULDBLOCKWaitReadable;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I" IO::EWOULDBLOCKWaitReadable;F;1o;2 ;30;40;50;:EWOULDBLOCK;!@;70;F;o; ;IC;[;&@;'IC;[;&@;(IC;[@`;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3;F;:EWOULDBLOCKWaitWritable;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I" IO::EWOULDBLOCKWaitWritable;F;1o;2 ;30;40;50;;;!@;70;F;o; ;IC;[;&@;'IC;[;&@;(IC;[@M;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3;F;:EINPROGRESSWaitReadable;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I" IO::EINPROGRESSWaitReadable;F;1o;2 ;30;40;50;:EINPROGRESS;!@;70;F;o; ;IC;[;&@̚;'IC;[;&@̚;(IC;[@`;&@̚;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i3;F;:EINPROGRESSWaitWritable;;0;;;[;{;IC;" ;T;[;[;@;0; @̚;!@;I" IO::EINPROGRESSWaitWritable;F;1o;2 ;30;40;50;;;!@;70;F;o; ; F; ;;;;I" IO.new;F;[[@0;[[@i ;T;; ;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @ޚ;@F;Ao;B;CT;Di ;Ei ;!@;"I")static 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(argc, argv, klass); };T;#I"static VALUE;T;$To; ; F; ;;;;I" IO.open;F;[[@0;[[@if;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; @;@F;Ao;B;CT;DiW;Eib;!@;"I"static VALUE rb_io_s_open(int argc, VALUE *argv, VALUE klass) { VALUE io = rb_class_new_instance(argc, argv, klass); if (rb_block_given_p()) { return rb_ensure(rb_yield, io, io_close, io); } return io; };T;#I"static VALUE;T;$To; ; F; ;;;;I"IO.sysopen;F;[[@0;[[@i|;T;: sysopen;0;[;{;IC;"|Opens the given path, returning the underlying file descriptor as a Integer. IO.sysopen("testfile") #=> 3 ;T;[o;H ;II" overload;F;J0;;;K0;#I""sysopen(path, [mode, [perm]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" path;T0[I"[mode, [perm]];T0; @;[;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; @;@F;Ao;B;CT;Dir;Eiy;!@;"I"static VALUE rb_io_s_sysopen(int argc, VALUE *argv) { 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; ; F; ;;;;I"IO.for_fd;F;[[@0;[[@i ;T;;;0;[;{;IC;"%Synonym for IO.new. ;T;[o;H ;II" overload;F;J0;;;K0;#I"for_fd(fd, mode [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@return [IO];T;0; @;@F;Mi;N0;[[I"fd;T0[I"mode[, opt];T0; @;[;I"ZSynonym for IO.new. @overload for_fd(fd, mode [, opt]) @return [IO];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;;;;I" IO.popen;F;[[@0;[[@i;T;: popen;0;[;{;IC;" 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;H ;II" overload;F;J0;;;K0;#I"(popen([env,] cmd, mode="r" [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @<;[;I"@return [IO];T;0; @<;@F;Mi;N0;[[I" [env,];T0[I" mode;TI""r"[, opt];T; @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; @<;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_io_s_popen(int argc, VALUE *argv, VALUE klass) { const char *modestr; VALUE pname, pmode = Qnil, port, tmp, opt = Qnil, env = Qnil, execarg_obj = Qnil; int oflags, fmode; convconfig_t convconfig; 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); } } tmp = rb_check_array_type(pname); if (!NIL_P(tmp)) { long len = RARRAY_LEN(tmp); #if SIZEOF_LONG > SIZEOF_INT if (len > INT_MAX) { rb_raise(rb_eArgError, "too many arguments"); } #endif execarg_obj = rb_execarg_new((int)len, RARRAY_CONST_PTR(tmp), FALSE, FALSE); RB_GC_GUARD(tmp); } else { SafeStringValue(pname); execarg_obj = Qnil; if (!is_popen_fork(pname)) execarg_obj = rb_execarg_new(1, &pname, TRUE, FALSE); } if (!NIL_P(execarg_obj)) { if (!NIL_P(opt)) opt = rb_execarg_extract_options(execarg_obj, opt); if (!NIL_P(env)) rb_execarg_setenv(execarg_obj, env); } rb_io_extract_modeenc(&pmode, 0, opt, &oflags, &fmode, &convconfig); modestr = rb_io_oflags_modestr(oflags); port = pipe_open(execarg_obj, modestr, fmode, &convconfig); if (NIL_P(port)) { /* child */ if (rb_block_given_p()) { rb_yield(Qnil); rb_io_flush(rb_stdout); rb_io_flush(rb_stderr); _exit(0); } return Qnil; } RBASIC_SET_CLASS(port, klass); if (rb_block_given_p()) { return rb_ensure(rb_yield, port, pipe_close, port); } return port; };T;#I"static VALUE;T;$To; ; F; ;;;;I"IO.foreach;F;[[@0;[[@i(;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. IO.foreach("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;H ;II" overload;F;J0;;;K0;#I"6foreach(name, sep=$/ [, getline_args, open_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @to;L ;II" return;F;JI";T;0;K[I"nil;T; @t;[;I" @yield [line] @return [nil];T;0; @t;@F;Mi;N0;[[I" name;T0[I"sep;TI""$/[, getline_args, open_args];T; @to;H ;II" overload;F;J0;;;K0;#I"5foreach(name, limit [, getline_args, open_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @to;L ;II" return;F;JI";T;0;K[I"nil;T; @t;[;I" @yield [line] @return [nil];T;0; @t;@F;Mi;N0;[[I" name;T0[I"%limit[, getline_args, open_args];T0; @to;H ;II" overload;F;J0;;;K0;#I":foreach(name, sep, limit [, getline_args, open_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @to;L ;II" return;F;JI";T;0;K[I"nil;T; @t;[;I" @yield [line] @return [nil];T;0; @t;@F;Mi;N0;[[I" name;T0[I"sep;T0[I"%limit[, getline_args, open_args];T0; @to;H ;II" overload;F;J0;;;K0;#I"foreach(...);T;IC;";T;[;[;I";T;0; @t;@F;Mi;N0;[[I"...;T0; @t;[;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. IO.foreach("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(...);T;0; @t;@F;Ao;B;CT;Did(;Ei(;!@;"I"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; ; F; ;;;;I"IO.readlines;F;[[@0;[[@i(;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. a = IO.readlines("testfile") a[0] #=> "This is line one\n" b = IO.readlines("testfile", chomp: true) b[0] #=> "This is line one" 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 open_args. ;T;[o;H ;II" overload;F;J0;;;K0;#I"8readlines(name, sep=$/ [, getline_args, open_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @қ;[;I"@return [Array];T;0; @қ;@F;Mi;N0;[[I" name;T0[I"sep;TI""$/[, getline_args, open_args];T; @қo;H ;II" overload;F;J0;;;K0;#I"7readlines(name, limit [, getline_args, open_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @қ;[;I"@return [Array];T;0; @қ;@F;Mi;N0;[[I" name;T0[I"%limit[, getline_args, open_args];T0; @қo;H ;II" overload;F;J0;;;K0;#I"name as individual lines, and returns those lines in an array. Lines are separated by sep. a = IO.readlines("testfile") a[0] #=> "This is line one\n" b = IO.readlines("testfile", chomp: true) b[0] #=> "This is line one" 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 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];T;0; @қ;@F;Ao;B;CT;Di(;Ei(;!@;"I" 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; ; F; ;;;;I" IO.read;F;[[@0;[[@i);T;: read;0;[;{;IC;"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 ("|"), a subprocess is created in the same way as Kernel#open, and its output is returned. === 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: IO.read("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" IO.read("testfile", 20) #=> "This is line one\nThi" IO.read("testfile", 20, 10) #=> "ne one\nThis is line " IO.read("binfile", mode: "rb") #=> "\xF7\x00\x00\x0E\x12" ;T;[o;H ;II" overload;F;J0;;;K0;#I"-read(name, [length [, offset]] [, opt] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" name;T0[I"[length [, offset]][, opt];T0; @;[;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 ("|"), a subprocess is created in the same way as Kernel#open, and its output is returned. === 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: IO.read("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" IO.read("testfile", 20) #=> "This is line one\nThi" IO.read("testfile", 20, 10) #=> "ne one\nThis is line " IO.read("binfile", mode: "rb") #=> "\xF7\x00\x00\x0E\x12" @overload read(name, [length [, offset]] [, opt] ) @return [String];T;0; @;@F;Ao;B;CT;Di(;Ei);!@;"I"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; ; F; ;;;;I"IO.binread;F;[[@0;[[@i*);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". IO.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" IO.binread("testfile", 20) #=> "This is line one\nThi" IO.binread("testfile", 20, 10) #=> "ne one\nThis is line " ;T;[o;H ;II" overload;F;J0;;;K0;#I"(binread(name, [length [, offset]] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @7;[;I"@return [String];T;0; @7;@F;Mi;N0;[[I" name;T0[I"[length [, offset]];T0; @7;[;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". IO.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" IO.binread("testfile", 20) #=> "This is line one\nThi" IO.binread("testfile", 20, 10) #=> "ne one\nThis is line " @overload binread(name, [length [, offset]] ) @return [String];T;0; @7;@F;Ao;B;CT;Di);Ei');!@;"I"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; ; F; ;;;;I" IO.write;F;[[@0;[[@i);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. IO.write("testfile", "0123456789", 20) #=> 10 # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n" IO.write("testfile", "0123456789") #=> 10 # File would now read: "0123456789" 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. ;T;[o;H ;II" overload;F;J0;;;K0;#I"#write(name, string [, offset]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @W;[;I"@return [Integer];T;0; @W;@F;Mi;N0;[[I" name;T0[I"string[, offset];T0; @Wo;H ;II" overload;F;J0;;;K0;#I"+write(name, string [, offset] [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @W;[;I"@return [Integer];T;0; @W;@F;Mi;N0;[[I" name;T0[I"string[, offset][, opt];T0; @W;[;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. IO.write("testfile", "0123456789", 20) #=> 10 # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n" IO.write("testfile", "0123456789") #=> 10 # File would now read: "0123456789" 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. @overload write(name, string [, offset]) @return [Integer] @overload write(name, string [, offset] [, opt]) @return [Integer];T;0; @W;@F;Ao;B;CT;Di);Ei);!@;"I"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; ; F; ;;;;I"IO.binwrite;F;[[@0;[[@i);T;: binwrite;0;[;{;IC;"tSame as IO.write except opening the file in binary mode and ASCII-8BIT encoding ("wb:ASCII-8BIT"). ;T;[o;H ;II" overload;F;J0;;;K0;#I"&binwrite(name, string, [offset] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" name;T0[I" string;T0[I" [offset];T0; @o;H ;II" overload;F;J0;;;K0;#I"1binwrite(name, string, [offset], open_args );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[ [I" name;T0[I" string;T0[I" [offset];T0[I"open_args;T0; @;[;I"Same as IO.write except opening the file in binary mode and ASCII-8BIT encoding ("wb:ASCII-8BIT"). @overload binwrite(name, string, [offset] ) @return [Integer] @overload binwrite(name, string, [offset], open_args ) @return [Integer];T;0; @;@F;Ao;B;CT;Di);Ei);!@;"I"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; ; F; ;;;;I"IO.select;F;[[@0;[[@i%;T;;;0;[;{;IC;"YCalls 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;H ;II" overload;F;J0;;;K0;#I"Cselect(read_array [, write_array [, error_array [, timeout]]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I":read_array[, write_array [, error_array [, timeout]]];T0; @;[;@ ;0; @;@F;Ao;B;CT;Di$;Ei%;!@;"I" static VALUE rb_f_select(int argc, VALUE *argv, VALUE obj) { VALUE timeout; struct select_args args; struct timeval timerec; int i; rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout); if (NIL_P(timeout)) { args.timeout = 0; } else { timerec = rb_time_interval(timeout); args.timeout = &timerec; } for (i = 0; i < numberof(args.fdsets); ++i) rb_fd_init(&args.fdsets[i]); return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args); };T;#I"static VALUE;T;$To; ; F; ;;;;I" IO.pipe;F;[[@0;[[@i';T;: pipe;0;[;{;IC;"=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: ;T;[ o;H ;II" overload;F;J0;;;K0;#I" pipe;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ݜ;[;I"@return [Array];T;0; @ݜ;@F;Mi;N0;[; @ݜo;H ;II" overload;F;J0;;;K0;#I"pipe(ext_enc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ݜ;[;I"@return [Array];T;0; @ݜ;@F;Mi;N0;[[I" ext_enc;T0; @ݜo;H ;II" overload;F;J0;;;K0;#I"$pipe("ext_enc:int_enc" [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ݜ;[;I"@return [Array];T;0; @ݜ;@F;Mi;N0;[[""ext_enc:"int_enc"[, opt]; @ݜo;H ;II" overload;F;J0;;;K0;#I"#pipe(ext_enc, int_enc [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ݜ;[;I"@return [Array];T;0; @ݜ;@F;Mi;N0;[[I" ext_enc;T0[I"int_enc[, opt];T0; @ݜ;[;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; @ݜ;@F;Ao;B;CT;Di';Ei';!@;"I"|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 DEFAULT_TEXTMODE if ((fptr->mode & FMODE_TEXTMODE) && (fmode & FMODE_BINMODE)) { fptr->mode &= ~FMODE_TEXTMODE; setmode(fptr->fd, O_BINARY); } #if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) 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; ; F; ;;;;I"IO.try_convert;F;[[I"io;T0;[[@i;T;; ;0;[;{;IC;"Try to convert obj into an IO, using to_io method. Returns converted IO or +nil+ if obj cannot be converted for any reason. IO.try_convert(STDOUT) #=> STDOUT IO.try_convert("STDOUT") #=> nil require 'zlib' f = open("/tmp/zz.gz") #=> # z = Zlib::GzipReader.open(f) #=> # IO.try_convert(z) #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"try_convert(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;TI"nil;T; @);[;I"@return [IO, nil];T;0; @);@F;Mi;N0;[[I"obj;T0; @);[;I"Try to convert obj into an IO, using to_io method. Returns converted IO or +nil+ if obj cannot be converted for any reason. IO.try_convert(STDOUT) #=> STDOUT IO.try_convert("STDOUT") #=> nil require 'zlib' f = open("/tmp/zz.gz") #=> # z = Zlib::GzipReader.open(f) #=> # IO.try_convert(z) #=> # @overload try_convert(obj) @return [IO, nil];T;0; @);@F;Ao;B;CT;Di;Ei;!@;"I"_static VALUE rb_io_s_try_convert(VALUE dummy, VALUE io) { return rb_io_check_io(io); };T;#I"static VALUE;T;$To; ; F; ;;;;I"IO.copy_stream;F;[[@0;[[@i-;T;:copy_stream;0;[;{;IC;"xIO.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;H ;II" overload;F;J0;;;K0;#I"copy_stream(src, dst);T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[[I"src;T0[I"dst;T0; @Io;H ;II" overload;F;J0;;;K0;#I"'copy_stream(src, dst, copy_length);T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[[I"src;T0[I"dst;T0[I"copy_length;T0; @Io;H ;II" overload;F;J0;;;K0;#I"3copy_stream(src, dst, copy_length, src_offset);T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[ [I"src;T0[I"dst;T0[I"copy_length;T0[I"src_offset;T0; @I;[;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; @I;@F;Ao;B;CT;Di,;Ei-;!@;"I"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; 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; ; F; ;,;;;I"IO#initialize;F;[[@0;[[@i& ;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(fd [, mode] [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@return [IO];T;0; @;@F;Mi;N0;[[I"fd[, mode][, opt];T0; @;[;I"LReturns 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; @;@F;Ao;B;CT;Di;Ei# ;!@;"I"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->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; ; F; ;,;;;I"IO#initialize_copy;F;[[I"io;T0;[[@i;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#reopen;F;[[@0;[[@i;T;: reopen;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;H ;II" overload;F;J0;;;K0;#I"reopen(other_IO);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@return [IO];T;0; @;@F;Mi;N0;[[I" other_IO;T0; @o;H ;II" overload;F;J0;;;K0;#I"reopen(path, mode [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@return [IO];T;0; @;@F;Mi;N0;[[I" path;T0[I"mode[, opt];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I" 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(0); } 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; ; F; ;,;;;I" IO#print;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" print;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ߝ;[;I"@return [nil];T;0; @ߝ;@F;Mi;N0;[; @ߝo;H ;II" overload;F;J0;;;K0;#I"print(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ߝ;[;I"@return [nil];T;0; @ߝ;@F;Mi;N0;[[I"obj;T0[I"...;T0; @ߝ;[;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; @ߝ;@F;Ao;B;CT;Dil;Ei;!@;"I"VALUE 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; } 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; ; F; ;,;;;I" IO#putc;F;[[I"ch;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"putc(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ ;[;I"fIf 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; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" IO#puts;F;[[@0;[[@i0;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;H ;II" overload;F;J0;;;K0;#I"puts(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @+;[;I"@return [nil];T;0; @+;@F;Mi;N0;[[I"obj;T0[I"...;T0; @+;[;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; @+;@F;Ao;B;CT;Di;Ei-;!@;"I"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;H ;II" overload;F;J0;;;K0;#I"'printf(format_string [, obj, ...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @K;[;I"@return [nil];T;0; @K;@F;Mi;N0;[[I"format_string[, obj, ...];T0; @K;[;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; @K;@F;Ao;B;CT;Di>;EiD;!@;"I"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; ; F; ;,;;;I" IO#each;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I""each(sep=$/ [, getline_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @io;L ;II" return;F;JI";T;0;K[I"IO;T; @i;[;I"@yield [line] @return [IO];T;0; @i;@F;Mi;N0;[[I"sep;TI"$/[, getline_args];T; @io;H ;II" overload;F;J0;;;K0;#I"!each(limit [, getline_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @io;L ;II" return;F;JI";T;0;K[I"IO;T; @i;[;I"@yield [line] @return [IO];T;0; @i;@F;Mi;N0;[[I"limit[, getline_args];T0; @io;H ;II" overload;F;J0;;;K0;#I"&each(sep, limit [, getline_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @io;L ;II" return;F;JI";T;0;K[I"IO;T; @i;[;I"@yield [line] @return [IO];T;0; @i;@F;Mi;N0;[[I"sep;T0[I"limit[, getline_args];T0; @io;H ;II" overload;F;J0;;;K0;#I"each(...);T;IC;";T;[;[;I";T;0; @i;@F;Mi;N0;[[I"...;T0; @i;[;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; @i;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#each_line;F;[[@0;[[@i;T;;w;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;H ;II" overload;F;J0;;;K0;#I""each(sep=$/ [, getline_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@yield [line] @return [IO];T;0; @;@F;Mi;N0;[[I"sep;TI"$/[, getline_args];T; @o;H ;II" overload;F;J0;;;K0;#I"!each(limit [, getline_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@yield [line] @return [IO];T;0; @;@F;Mi;N0;[[I"limit[, getline_args];T0; @o;H ;II" overload;F;J0;;;K0;#I"&each(sep, limit [, getline_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@yield [line] @return [IO];T;0; @;@F;Mi;N0;[[I"sep;T0[I"limit[, getline_args];T0; @o;H ;II" overload;F;J0;;;K0;#I"each(...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"...;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#each_byte;F;[;[[@i;T;;x;0;[;{;IC;"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 ;T;[o;H ;II" overload;F;J0;;x;K0;#I"each_byte;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" byte;T; @o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@yield [byte] @return [IO];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;x;K0;#I"each_byte;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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)); errno = 0; } rb_io_check_byte_readable(fptr); READ_CHECK(fptr); } while (io_fillbuf(fptr) >= 0); return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#each_char;F;[;[[@i;T;;y;0;[;{;IC;"FCalls 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;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"c;T; @@o;L ;II" return;F;JI";T;0;K[I"IO;T; @@;[;I"@yield [c] @return [IO];T;0; @@;@F;Mi;N0;[; @@o;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[; @@;[;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; @@;@F;Ao;B;CT;Diz;Ei;!@;"I"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; ; F; ;,;;;I"IO#each_codepoint;F;[;[[@i;T;;z;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;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"c;T; @ho;L ;II" return;F;JI";T;0;K[I"IO;T; @h;[;I"@yield [c] @return [IO];T;0; @h;@F;Mi;N0;[; @ho;H ;II" overload;F;J0;;L;K0;#I"codepoints;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"c;T; @ho;L ;II" return;F;JI";T;0;K[I"IO;T; @h;[;I"@yield [c] @return [IO];T;0; @h;@F;Mi;N0;[; @ho;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[;[;I";T;0; @h;@F;Mi;N0;[; @ho;H ;II" overload;F;J0;;L;K0;#I"codepoints;T;IC;";T;[;[;I";T;0; @h;@F;Mi;N0;[; @h;[;I"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. @overload each_codepoint @yield [c] @return [IO] @overload codepoints @yield [c] @return [IO] @overload each_codepoint @overload codepoints;T;0; @h;@F;Ao;B;CT;Di;Ei;!@;"I" 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)); } } 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)) { invalid: rb_raise(rb_eArgError, "invalid byte sequence in %s", rb_enc_name(enc)); } 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; } } return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#lines;F;[[@0;[[@i;T;;I;0;[;{;IC;";This is a deprecated alias for each_line. ;T;[;[;I"each_line. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_io_lines(int argc, VALUE *argv, VALUE io) { rb_warn("IO#lines is deprecated; use #each_line instead"); if (!rb_block_given_p()) return rb_enumeratorize(io, ID2SYM(rb_intern("each_line")), argc, argv); return rb_io_each_line(argc, argv, io); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#bytes;F;[;[[@i;T;;J;0;[;{;IC;";This is a deprecated alias for each_byte. ;T;[;[;I"each_byte. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_io_bytes(VALUE io) { rb_warn("IO#bytes is deprecated; use #each_byte instead"); if (!rb_block_given_p()) return rb_enumeratorize(io, ID2SYM(rb_intern("each_byte")), 0, 0); return rb_io_each_byte(io); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#chars;F;[;[[@i;T;;K;0;[;{;IC;";This is a deprecated alias for each_char. ;T;[;[;I"each_char. ;T;0; @ǟ;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_io_chars(VALUE io) { rb_warn("IO#chars is deprecated; use #each_char instead"); if (!rb_block_given_p()) return rb_enumeratorize(io, ID2SYM(rb_intern("each_char")), 0, 0); return rb_io_each_char(io); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#codepoints;F;[;[[@i ;T;;L;0;[;{;IC;"@This is a deprecated alias for each_codepoint. ;T;[;[;I"AThis is a deprecated alias for each_codepoint. ;T;0; @՟;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_io_codepoints(VALUE io) { rb_warn("IO#codepoints is deprecated; use #each_codepoint instead"); if (!rb_block_given_p()) return rb_enumeratorize(io, ID2SYM(rb_intern("each_codepoint")), 0, 0); return rb_io_each_codepoint(io); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#syswrite;F;[[I"str;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"syswrite(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"`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 @overload syswrite(string) @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Gstatic 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->fd, 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; ; F; ;,;;;I"IO#sysread;F;[[@0;[[@i;T;: sysread;0;[;{;IC;"9Reads 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;H ;II" overload;F;J0;;;K0;#I"sysread(maxlen[, outbuf]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"maxlen[, outbuf];T0; @;[;I"rReads 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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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"); } /* * FIXME: removing rb_thread_wait_fd() here changes sysread semantics * on non-blocking IOs. However, it's still currently possible * for sysread to raise Errno::EAGAIN if another thread read()s * the IO after we return from rb_thread_wait_fd() but before * we call read() */ rb_thread_wait_fd(fptr->fd); rb_io_check_closed(fptr); io_setstrbuf(&str, ilen); iis.fd = fptr->fd; iis.nonblock = 1; /* for historical reasons, maybe (see above) */ 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(); } OBJ_TAINT(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#pread;F;[[@0;[[@ih;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;H ;II" overload;F;J0;;;K0;#I"$pread(maxlen, offset[, outbuf]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[I" maxlen;T0[I"offset[, outbuf];T0; @ ;[;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; @ ;@F;Ao;B;CT;DiQ;Eif;!@;"I"Sstatic 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(); } OBJ_TAINT(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#pwrite;F;[[I"str;T0[I" offset;T0;[[@i;T;: pwrite;0;[;{;IC;"qWrites 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;H ;II" overload;F;J0;;;K0;#I"pwrite(string, offset);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @@;[;I"@return [Integer];T;0; @@;@F;Mi;N0;[[I" string;T0[I" offset;T0; @@;[;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; @@;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#fileno;F;[;[[@i;T;: fileno;0;[;{;IC;"Returns an integer representing the numeric file descriptor for ios. $stdin.fileno #=> 0 $stdout.fileno #=> 1 ;T;[o;H ;II" overload;F;J0;;;K0;#I" fileno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @c;[;I"@return [Integer];T;0; @c;@F;Mi;N0;[; @co;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @c;[;I"@return [Integer];T;0; @c;@F;Mi;N0;[; @c;[;I"Returns an integer representing the numeric file descriptor for ios. $stdin.fileno #=> 0 $stdout.fileno #=> 1 @overload fileno @return [Integer] @overload to_i @return [Integer];T;0; o; ; F; ;,;;;I" IO#to_i;F;[;[[@i^3;F;;=;;0;[;{;@j;!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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;#@;$T@o; ; F; ;,;;;I" IO#to_io;F;[;[[@iF ;T;: to_io;0;[;{;IC;"Returns ios. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_io;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@return [IO];T;0; @;@F;Mi;N0;[; @;[;I";Returns ios. @overload to_io @return [IO];T;0; @;@F;Ao;B;CT;Di? ;EiC ;!@;"I":static VALUE rb_io_to_io(VALUE io) { return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#fsync;F;[;[[@i;T;: fsync;0;[;{;IC;"Immediately writes all buffered data in ios to disk. Note that fsync differs from using IO#sync=. The latter ensures that data is flushed from Ruby's buffers, but does not guarantee that the underlying operating system actually writes it to disk. NotImplementedError is raised if the underlying operating system does not support fsync(2). ;T;[o;H ;II" overload;F;J0;;;K0;#I" fsync;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI"nil;T; @;[;I"@return [0, nil];T;0; @;@F;Mi;N0;[; @;[;I"Immediately writes all buffered data in ios to disk. Note that fsync differs from using IO#sync=. The latter ensures that data is flushed from Ruby's buffers, but does not guarantee that the underlying operating system actually writes it to disk. NotImplementedError is raised if the underlying operating system does not support fsync(2). @overload fsync @return [0, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"'static VALUE rb_io_fsync(VALUE io) { rb_io_t *fptr; io = GetWriteIO(io); GetOpenFile(io, fptr); if (io_fflush(fptr) < 0) rb_sys_fail(0); 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; ; F; ;,;;;I"IO#fdatasync;F;[;[[@i;T;:fdatasync;0;[;{;IC;"Immediately writes all buffered data in ios to disk. If the underlying operating system does not support fdatasync(2), IO#fsync is called instead (which might raise a NotImplementedError). ;T;[o;H ;II" overload;F;J0;;;K0;#I"fdatasync;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI"nil;T; @ʠ;[;I"@return [0, nil];T;0; @ʠ;@F;Mi;N0;[; @ʠ;[;I"Immediately writes all buffered data in ios to disk. If the underlying operating system does not support fdatasync(2), IO#fsync is called instead (which might raise a NotImplementedError). @overload fdatasync @return [0, nil];T;0; @ʠ;@F;Ao;B;CT;Di;Ei;!@;"I"?static VALUE rb_io_fdatasync(VALUE io) { rb_io_t *fptr; io = GetWriteIO(io); GetOpenFile(io, fptr); if (io_fflush(fptr) < 0) rb_sys_fail(0); 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; ; F; ;,;;;I" IO#sync;F;[;[[@if;T;: sync;0;[;{;IC;" Returns the current ``sync mode'' of ios. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered by Ruby internally. See also IO#fsync. f = File.new("testfile") f.sync #=> false ;T;[o;H ;II" overload;F;J0;;;K0;#I" sync;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"/Returns the current ``sync mode'' of ios. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered by Ruby internally. See also IO#fsync. f = File.new("testfile") f.sync #=> false @overload sync @return [Boolean];T;0; @;@F;Ao;B;CT;DiY;Eic;!@;"I"static VALUE rb_io_sync(VALUE io) { rb_io_t *fptr; io = GetWriteIO(io); GetOpenFile(io, fptr); return (fptr->mode & FMODE_SYNC) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#sync=;F;[[I" sync;T0;[[@i;T;: sync=;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"bstatic VALUE rb_io_set_sync(VALUE io, VALUE sync) { rb_notimplement(); UNREACHABLE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#lineno;F;[;[[@i4;T;;;0;[;{;IC;"VReturns 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;H ;II" overload;F;J0;;;K0;#I" lineno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"}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 @overload lineno @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei1;!@;"I"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; ; F; ;,;;;I"IO#lineno=;F;[[I" lineno;T0;[[@iO;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;H ;II" overload;F;J0;;;K0;#I"lineno=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @*;[;I"@return [Integer];T;0; @*;@F;Mi;N0;[[I" integer;T0; @*;[;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; @*;@F;Ao;B;CT;Di>;EiL;!@;"I"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; ; F; ;,;;;I"IO#readlines;F;[[@0;[[@i;T;;;0;[;{;IC;"|Reads 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;H ;II" overload;F;J0;;;K0;#I"'readlines(sep=$/ [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @I;[;I"@return [Array];T;0; @I;@F;Mi;N0;[[I"sep;TI"$/[, getline_args];T; @Io;H ;II" overload;F;J0;;;K0;#I"&readlines(limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @I;[;I"@return [Array];T;0; @I;@F;Mi;N0;[[I"limit[, getline_args];T0; @Io;H ;II" overload;F;J0;;;K0;#I"+readlines(sep, limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @I;[;I"@return [Array];T;0; @I;@F;Mi;N0;[[I"sep;T0[I"limit[, getline_args];T0; @I;[;I">Reads 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; @I;@F;Ao;B;CT;Diq;Ei;!@;"I"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; ; F; ;,;;;I"IO#__read_nonblock;F;[[I" length;T0[I"str;T0[I"ex;T0;[[@iw ;T;:__read_nonblock;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Div ;Eiv ;!@;"I"static VALUE io_read_nonblock(VALUE io, VALUE length, VALUE str, VALUE ex) { rb_io_t *fptr; long n, len; struct io_internal_read_struct iis; int shrinkable; if ((len = NUM2LONG(length)) < 0) { rb_raise(rb_eArgError, "negative length %ld given", len); } shrinkable = io_setstrbuf(&str, len); OBJ_TAINT(str); GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); if (len == 0) return str; n = read_buffered_data(RSTRING_PTR(str), len, fptr); if (n <= 0) { rb_io_set_nonblock(fptr); shrinkable |= io_setstrbuf(&str, len); iis.fd = fptr->fd; iis.nonblock = 1; iis.buf = RSTRING_PTR(str); iis.capa = len; n = read_internal_locktmp(str, &iis); if (n < 0) { int e = errno; if ((e == EWOULDBLOCK || e == EAGAIN)) { if (ex == Qfalse) return sym_wait_readable; rb_readwrite_syserr_fail(RB_IO_WAIT_READABLE, e, "read would block"); } rb_syserr_fail_path(e, fptr->pathv); } } io_set_read_length(str, n, shrinkable); if (n == 0) { if (ex == Qfalse) return Qnil; rb_eof_error(); } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#__write_nonblock;F;[[I"str;T0[I"ex;T0;[[@i ;T;:__write_nonblock;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE io_write_nonblock(VALUE io, VALUE str, VALUE ex) { rb_io_t *fptr; long n; 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 (io_fflush(fptr) < 0) rb_sys_fail(0); rb_io_set_nonblock(fptr); n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str)); RB_GC_GUARD(str); if (n < 0) { int e = errno; if (e == EWOULDBLOCK || e == EAGAIN) { if (ex == Qfalse) { return sym_wait_writable; } else { rb_readwrite_syserr_fail(RB_IO_WAIT_WRITABLE, e, "write would block"); } } rb_syserr_fail_path(e, fptr->pathv); } return LONG2FIX(n); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#readpartial;F;[[@0;[[@ib ;T;:readpartial;0;[;{;IC;"} Reads at most maxlen bytes from the I/O stream. It blocks only if ios has no data immediately available. It doesn't block if some data available. 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 file. readpartial is designed for streams such as pipe, socket, tty, etc. It blocks only when no data immediately available. This means that it blocks only when following all conditions hold. * the byte buffer in the IO object is empty. * the content of the stream is empty. * the stream is not reached to EOF. When readpartial blocks, it waits data or EOF on the stream. If some data is reached, readpartial returns with the data. If EOF is reached, readpartial raises EOFError. When readpartial doesn't blocks, it returns or raises immediately. If the byte buffer is not empty, it returns the data in the buffer. Otherwise if the stream has some content, it returns the data in the stream. Otherwise if the stream is reached to EOF, it raises EOFError. r, w = IO.pipe # buffer pipe content w << "abc" # "" "abc". r.readpartial(4096) #=> "abc" "" "" r.readpartial(4096) # blocks because buffer and pipe is empty. r, w = IO.pipe # buffer pipe content w << "abc" # "" "abc" w.close # "" "abc" EOF r.readpartial(4096) #=> "abc" "" EOF r.readpartial(4096) # raises EOFError r, w = IO.pipe # buffer pipe content 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" "" "" Note that readpartial behaves 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 retry the system call. The latter means that readpartial is nonblocking-flag insensitive. It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode. ;T;[o;H ;II" overload;F;J0;;;K0;#I"readpartial(maxlen);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" maxlen;T0; @o;H ;II" overload;F;J0;;;K0;#I" readpartial(maxlen, outbuf);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" maxlen;T0[I" outbuf;T0; @;[;I" Reads at most maxlen bytes from the I/O stream. It blocks only if ios has no data immediately available. It doesn't block if some data available. 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 file. readpartial is designed for streams such as pipe, socket, tty, etc. It blocks only when no data immediately available. This means that it blocks only when following all conditions hold. * the byte buffer in the IO object is empty. * the content of the stream is empty. * the stream is not reached to EOF. When readpartial blocks, it waits data or EOF on the stream. If some data is reached, readpartial returns with the data. If EOF is reached, readpartial raises EOFError. When readpartial doesn't blocks, it returns or raises immediately. If the byte buffer is not empty, it returns the data in the buffer. Otherwise if the stream has some content, it returns the data in the stream. Otherwise if the stream is reached to EOF, it raises EOFError. r, w = IO.pipe # buffer pipe content w << "abc" # "" "abc". r.readpartial(4096) #=> "abc" "" "" r.readpartial(4096) # blocks because buffer and pipe is empty. r, w = IO.pipe # buffer pipe content w << "abc" # "" "abc" w.close # "" "abc" EOF r.readpartial(4096) #=> "abc" "" EOF r.readpartial(4096) # raises EOFError r, w = IO.pipe # buffer pipe content 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" "" "" Note that readpartial behaves 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 retry the system call. The latter means that readpartial is nonblocking-flag insensitive. It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode. @overload readpartial(maxlen) @return [String] @overload readpartial(maxlen, outbuf);T;0; @;@F;Ao;B;CT;Di% ;Ei_ ;!@;"I"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; ; F; ;,;;;I" IO#read;F;[[@0;[[@i ;T;;;0;[;{;IC;"Reads _length_ bytes from the I/O stream. _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. When this method is called at end of file, it returns +nil+ or "", depending on _length_: +read+, read(nil), and read(0) return "", read(positive_integer) returns +nil+. f = File.new("testfile") f.read(16) #=> "This is line one" # read whole file open("file") do |f| data = f.read # This returns a string even if the file is empty. # ... end # iterate over fixed length records open("fixed-record-file") do |f| while record = f.read(256) # ... end end # iterate over variable length records, # each record is prefixed by its 32-bit length open("variable-record-file") do |f| while len = f.read(4) len = len.unpack("N")[0] # 32-bit length record = f.read(len) # This returns a string even if len is 0. end end 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 (or until EOF). This behavior is preserved even if ios 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;H ;II" overload;F;J0;;;K0;#I"read([length [, outbuf]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ء;[;I"@return [String, nil];T;0; @ء;@F;Mi;N0;[[I"[length [, outbuf]];T0; @ء;[;I"Reads _length_ bytes from the I/O stream. _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. When this method is called at end of file, it returns +nil+ or "", depending on _length_: +read+, read(nil), and read(0) return "", read(positive_integer) returns +nil+. f = File.new("testfile") f.read(16) #=> "This is line one" # read whole file open("file") do |f| data = f.read # This returns a string even if the file is empty. # ... end # iterate over fixed length records open("fixed-record-file") do |f| while record = f.read(256) # ... end end # iterate over variable length records, # each record is prefixed by its 32-bit length open("variable-record-file") do |f| while len = f.read(4) len = len.unpack("N")[0] # 32-bit length record = f.read(len) # This returns a string even if len is 0. end end 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 (or until EOF). This behavior is preserved even if ios 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([length [, outbuf]]) @return [String, nil];T;0; @ء;@F;Ao;B;CT;Di ;Ei ;!@;"I"vstatic VALUE io_read(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr; long n, len; VALUE length, str; int shrinkable; #if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) 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 defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) 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 defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) if (previous_mode == O_TEXT) { setmode(fptr->fd, O_TEXT); } #endif if (n == 0) return Qnil; OBJ_TAINT(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#write;F;[[@0;[[@i;T;;;0;[;{;IC;"uWrites the given strings to ios. The stream must be opened for writing. Arguments that are not a string will be converted to a string using to_s. Returns the number of bytes written in total. count = $stdout.write("This is", " a test\n") puts "That was #{count} bytes of data" produces: This is a test That was 15 bytes of data ;T;[o;H ;II" overload;F;J0;;;K0;#I"write(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @;[;I"Writes the given strings to ios. The stream must be opened for writing. Arguments that are not a string will be converted to a string using to_s. Returns the number of bytes written in total. count = $stdout.write("This is", " a test\n") puts "That was #{count} bytes of data" produces: This is a test That was 15 bytes of data @overload write(string, ...) @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" IO#gets;F;[[@0;[[@i;T;;;0;[;{;IC;"Reads the next ``line'' from the I/O stream; lines are separated by sep. A separator of +nil+ reads the entire contents, and a zero-length separator reads the input a paragraph at a time (two successive newlines in the input separate paragraphs). The stream must be opened for reading or an IOError will be raised. The line read in will be returned and also assigned to $_. Returns +nil+ if called at end of file. 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. File.new("testfile").gets #=> "This is line one\n" $_ #=> "This is line one\n" File.new("testfile").gets(4)#=> "This" If IO contains multibyte characters byte then gets(1) returns character entirely: # Russian characters take 2 bytes File.write("testfile", "\u{442 435 441 442}") File.open("testfile") {|f|f.gets(1)} #=> "\u0442" File.open("testfile") {|f|f.gets(2)} #=> "\u0442" File.open("testfile") {|f|f.gets(3)} #=> "\u0442\u0435" File.open("testfile") {|f|f.gets(4)} #=> "\u0442\u0435" ;T;[o;H ;II" overload;F;J0;;;K0;#I""gets(sep=$/ [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I"sep;TI"$/[, getline_args];T; @o;H ;II" overload;F;J0;;;K0;#I"!gets(limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I"limit[, getline_args];T0; @o;H ;II" overload;F;J0;;;K0;#I"&gets(sep, limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I"sep;T0[I"limit[, getline_args];T0; @;[;I"JReads the next ``line'' from the I/O stream; lines are separated by sep. A separator of +nil+ reads the entire contents, and a zero-length separator reads the input a paragraph at a time (two successive newlines in the input separate paragraphs). The stream must be opened for reading or an IOError will be raised. The line read in will be returned and also assigned to $_. Returns +nil+ if called at end of file. 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. File.new("testfile").gets #=> "This is line one\n" $_ #=> "This is line one\n" File.new("testfile").gets(4)#=> "This" If IO contains multibyte characters byte then gets(1) returns character entirely: # Russian characters take 2 bytes File.write("testfile", "\u{442 435 441 442}") File.open("testfile") {|f|f.gets(1)} #=> "\u0442" File.open("testfile") {|f|f.gets(2)} #=> "\u0442" File.open("testfile") {|f|f.gets(3)} #=> "\u0442\u0435" File.open("testfile") {|f|f.gets(4)} #=> "\u0442\u0435" @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;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"IO#readline;F;[[@0;[[@id;T;;;0;[;{;IC;"cReads a line as with IO#gets, but raises an EOFError on end of file. ;T;[o;H ;II" overload;F;J0;;;K0;#I"&readline(sep=$/ [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[[I"sep;TI"$/[, getline_args];T; @Yo;H ;II" overload;F;J0;;;K0;#I"%readline(limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[[I"limit[, getline_args];T0; @Yo;H ;II" overload;F;J0;;;K0;#I"*readline(sep, limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[[I"sep;T0[I"limit[, getline_args];T0; @Y;[;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; @Y;@F;Ao;B;CT;DiZ;Eic;!@;"I"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; ; F; ;,;;;I" IO#getc;F;[;[[@i6;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;H ;II" overload;F;J0;;;K0;#I" getc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di*;Ei3;!@;"I"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; ; F; ;,;;;I"IO#getbyte;F;[;[[@ig;T;;5;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;H ;II" overload;F;J0;;5;K0;#I" getbyte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di[;Eid;!@;"I"6VALUE rb_io_getbyte(VALUE io) { rb_io_t *fptr; int c; GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); READ_CHECK(fptr); if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) && RB_TYPE_P(rb_stdout, T_FILE)) { rb_io_t *ofp; GetOpenFile(rb_stdout, ofp); if (ofp->mode & FMODE_TTY) { rb_io_flush(rb_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; ; F; ;,;;;I"IO#readchar;F;[;[[@iP;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;H ;II" overload;F;J0;;;K0;#I" readchar;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Т;[;I"@return [String];T;0; @Т;@F;Mi;N0;[; @Т;[;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; @Т;@F;Ao;B;CT;DiD;EiM;!@;"I"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; ; F; ;,;;;I"IO#readbyte;F;[;[[@i;T;: readbyte;0;[;{;IC;"fReads a byte as with IO#getbyte, but raises an EOFError on end of file. ;T;[o;H ;II" overload;F;J0;;;K0;#I" readbyte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Reads a byte as with IO#getbyte, but raises an EOFError on end of file. @overload readbyte @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#ungetbyte;F;[[I"b;T0;[[@i;T;:ungetbyte;0;[;{;IC;"Pushes back bytes (passed as a parameter) onto ios, such that a subsequent buffered read will return it. Only one byte may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several bytes that have been pushed back). Has no effect with unbuffered reads (such as IO#sysread). f = File.new("testfile") #=> # b = f.getbyte #=> 0x38 f.ungetbyte(b) #=> nil f.getbyte #=> 0x38 ;T;[o;H ;II" overload;F;J0;;;K0;#I"ungetbyte(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" string;T0; @o;H ;II" overload;F;J0;;;K0;#I"ungetbyte(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" integer;T0; @;[;I"^Pushes back bytes (passed as a parameter) onto ios, such that a subsequent buffered read will return it. Only one byte may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several bytes that have been pushed back). Has no effect with unbuffered reads (such as IO#sysread). f = File.new("testfile") #=> # b = f.getbyte #=> 0x38 f.ungetbyte(b) #=> nil f.getbyte #=> 0x38 @overload ungetbyte(string) @return [nil] @overload ungetbyte(integer) @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_io_ungetbyte(VALUE io, VALUE b) { rb_io_t *fptr; VALUE v; unsigned char c; GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); switch (TYPE(b)) { case T_NIL: return Qnil; case T_FIXNUM: case T_BIGNUM: ; v = rb_int_modulo(b, INT2FIX(256)); 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; ; F; ;,;;;I"IO#ungetc;F;[[I"c;T0;[[@i;T;: ungetc;0;[;{;IC;"Pushes back one character (passed as a parameter) onto ios, such that a subsequent buffered character read will return it. Only one character may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several characters that have been pushed back). Has no effect with unbuffered reads (such as IO#sysread). f = File.new("testfile") #=> # c = f.getc #=> "8" f.ungetc(c) #=> nil f.getc #=> "8" ;T;[o;H ;II" overload;F;J0;;;K0;#I"ungetc(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @4;[;I"@return [nil];T;0; @4;@F;Mi;N0;[[I" string;T0; @4;[;I"HPushes back one character (passed as a parameter) onto ios, such that a subsequent buffered character read will return it. Only one character may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several characters that have been pushed back). Has no effect with unbuffered reads (such as IO#sysread). f = File.new("testfile") #=> # c = f.getc #=> "8" f.ungetc(c) #=> nil f.getc #=> "8" @overload ungetc(string) @return [nil];T;0; @4;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_io_ungetc(VALUE io, VALUE c) { rb_io_t *fptr; long len; GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); if (NIL_P(c)) return Qnil; if (FIXNUM_P(c)) { c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr)); } else if (RB_TYPE_P(c, T_BIGNUM)) { 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; ; F; ;,;;;I" IO#<<;F;[[I"str;T0;[[@i;T;;Q;0;[;{;IC;"String Output---Writes obj to ios. obj will be converted to a string using to_s. $stdout << "Hello " << "world!\n" produces: Hello world! ;T;[o;H ;II" overload;F;J0;;Q;K0;#I" <<(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @S;[;I"@return [IO];T;0; @S;@F;Mi;N0;[[I"obj;T0; @S;[;I"String Output---Writes obj to ios. obj will be converted to a string using to_s. $stdout << "Hello " << "world!\n" produces: Hello world! @overload <<(obj) @return [IO];T;0; @S;@F;Ao;B;CT;Di;Ei ;!@;"I"YVALUE rb_io_addstr(VALUE io, VALUE str) { rb_io_write(io, str); return io; };T;#I" VALUE;T;$To; ; F; ;,;;;I" IO#flush;F;[;[[@iL;T;: flush;0;[;{;IC;"Flushes any buffered data within ios to the underlying operating system (note that this is Ruby internal buffering only; the OS may buffer the data as well). $stdout.print "no newline" $stdout.flush produces: no newline ;T;[o;H ;II" overload;F;J0;;;K0;#I" flush;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @r;[;I"@return [IO];T;0; @r;@F;Mi;N0;[; @r;[;I"Flushes any buffered data within ios to the underlying operating system (note that this is Ruby internal buffering only; the OS may buffer the data as well). $stdout.print "no newline" $stdout.flush produces: no newline @overload flush @return [IO];T;0; @r;@F;Ao;B;CT;Di<;EiI;!@;"I"GVALUE rb_io_flush(VALUE io) { return rb_io_flush_raw(io, 1); };T;#I" VALUE;T;$To; ; F; ;,;;;I" IO#tell;F;[;[[@i_;T;: tell;0;[;{;IC;"Returns the current offset (in bytes) of ios. f = File.new("testfile") f.pos #=> 0 f.gets #=> "This is line one\n" f.pos #=> 17 ;T;[o;H ;II" overload;F;J0;:pos;K0;#I"pos;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" tell;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns the current offset (in bytes) of ios. f = File.new("testfile") f.pos #=> 0 f.gets #=> "This is line one\n" f.pos #=> 17 @overload pos @return [Integer] @overload tell @return [Integer];T;0; @;@F;Ao;B;CT;DiR;Ei];!@;"I"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; ; F; ;,;;;I" IO#seek;F;[[@0;[[@i;T;: seek;0;[;{;IC;"Seeks to a given offset anInteger in the stream according to the value of whence: :CUR or IO::SEEK_CUR | Seeks to _amount_ plus current position ----------------------+-------------------------------------------------- :END or IO::SEEK_END | Seeks to _amount_ plus end of stream (you | probably want a negative value for _amount_) ----------------------+-------------------------------------------------- :SET or IO::SEEK_SET | Seeks to the absolute location given by _amount_ Example: f = File.new("testfile") f.seek(-13, IO::SEEK_END) #=> 0 f.readline #=> "And so on...\n" ;T;[o;H ;II" overload;F;J0;;;K0;#I"&seek(amount, whence=IO::SEEK_SET);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" amount;T0[I" whence;TI"IO::SEEK_SET;T; @;[;I"Seeks to a given offset anInteger in the stream according to the value of whence: :CUR or IO::SEEK_CUR | Seeks to _amount_ plus current position ----------------------+-------------------------------------------------- :END or IO::SEEK_END | Seeks to _amount_ plus end of stream (you | probably want a negative value for _amount_) ----------------------+-------------------------------------------------- :SET or IO::SEEK_SET | Seeks to the absolute location given by _amount_ Example: f = File.new("testfile") f.seek(-13, IO::SEEK_END) #=> 0 f.readline #=> "And so on...\n" @overload seek(amount, whence=IO::SEEK_SET) @return [0];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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;9;[[@i3;F;: SEEK_SET;;;;;;[;{;IC;"(Set I/O position from the beginning ;T;[;[;I"(Set I/O position from the beginning;T;0; @֣;@F;Ao;B;CT;Di~3;Ei~3;!@;I"IO::SEEK_SET;F;ios to the beginning of input, resetting lineno to zero. f = File.new("testfile") f.readline #=> "This is line one\n" f.rewind #=> 0 f.lineno #=> 0 f.readline #=> "This is line one\n" Note that it cannot be used with streams such as pipes, ttys, and sockets. ;T;[o;H ;II" overload;F;J0;;;K0;#I" rewind;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[; @;[;I"`Positions ios to the beginning of input, resetting lineno to zero. f = File.new("testfile") f.readline #=> "This is line one\n" f.rewind #=> 0 f.lineno #=> 0 f.readline #=> "This is line one\n" Note that it cannot be used with streams such as pipes, ttys, and sockets. @overload rewind @return [0];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" IO#pos;F;[;[[@i_;T;;;0;[;{;IC;"Returns the current offset (in bytes) of ios. f = File.new("testfile") f.pos #=> 0 f.gets #=> "This is line one\n" f.pos #=> 17 ;T;[o;H ;II" overload;F;J0;;;K0;#I"pos;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-;[;I"@return [Integer];T;0; @-;@F;Mi;N0;[; @-o;H ;II" overload;F;J0;;;K0;#I" tell;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-;[;I"@return [Integer];T;0; @-;@F;Mi;N0;[; @-;[;@;0; @-;@F;Ao;B;CT;DiR;Ei];!@;"I"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; ; F; ;,;;;I" IO#pos=;F;[[I" offset;T0;[[@i;T;: pos=;0;[;{;IC;"Seeks to the given position (in bytes) in ios. It is not guaranteed that seeking to the right position when ios is textmode. f = File.new("testfile") f.pos = 17 f.gets #=> "This is line two\n" ;T;[o;H ;II" overload;F;J0;;;K0;#I"pos=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @T;[;I"@return [Integer];T;0; @T;@F;Mi;N0;[[I" integer;T0; @T;[;I" Seeks to the given position (in bytes) in ios. It is not guaranteed that seeking to the right position when ios is textmode. f = File.new("testfile") f.pos = 17 f.gets #=> "This is line two\n" @overload pos=(integer) @return [Integer];T;0; @T;@F;Ao;B;CT;Di;Ei;!@;"I" 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; ; F; ;,;;;I" IO#eof;F;[;[[@iC;T;:eof;0;[;{;IC;"\Returns true if ios is at end of file that means there are no more data to read. The stream must be opened for reading or an IOError will be raised. f = File.new("testfile") dummy = f.readlines f.eof #=> true If ios is a stream such as pipe or socket, IO#eof? 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 blocking r, w = IO.pipe Thread.new { sleep 1; w.puts "a" } r.eof? #=> false after 1 second blocking r, w = IO.pipe r.eof? # blocks forever Note that IO#eof? 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). ;T;[o;H ;II" overload;F;J0;;;K0;#I"eof;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @s;[;I"@return [Boolean];T;0; @s;@F;Mi;N0;[; @so;H ;II" overload;F;J0;: eof?;K0;#I" eof?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @s;[;I"@return [Boolean];T;0; @s;@F;Mi;N0;[; @s;[;I"Returns true if ios is at end of file that means there are no more data to read. The stream must be opened for reading or an IOError will be raised. f = File.new("testfile") dummy = f.readlines f.eof #=> true If ios is a stream such as pipe or socket, IO#eof? 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 blocking r, w = IO.pipe Thread.new { sleep 1; w.puts "a" } r.eof? #=> false after 1 second blocking r, w = IO.pipe r.eof? # blocks forever Note that IO#eof? 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). @overload eof @return [Boolean] @overload eof? @return [Boolean];T;0; @s;@F;Ao;B;CT;Di!;EiA;!@;"I"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 defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) if (!NEED_READCONV(fptr) && NEED_NEWLINE_DECORATOR_ON_READ(fptr)) { return eof(fptr->fd) ? Qtrue : Qfalse; } #endif if (io_fillbuf(fptr) < 0) { return Qtrue; } return Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I" IO#eof?;F;[;[[@iC;T;;;0;[;{;IC;"\Returns true if ios is at end of file that means there are no more data to read. The stream must be opened for reading or an IOError will be raised. f = File.new("testfile") dummy = f.readlines f.eof #=> true If ios is a stream such as pipe or socket, IO#eof? 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 blocking r, w = IO.pipe Thread.new { sleep 1; w.puts "a" } r.eof? #=> false after 1 second blocking r, w = IO.pipe r.eof? # blocks forever Note that IO#eof? 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).;T;[o;H ;II" overload;F;J0;;;K0;#I"eof;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" eof?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di!;EiA;Mi;!@;"I"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 defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) if (!NEED_READCONV(fptr) && NEED_NEWLINE_DECORATOR_ON_READ(fptr)) { return eof(fptr->fd) ? Qtrue : Qfalse; } #endif if (io_fillbuf(fptr) < 0) { return Qtrue; } return Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"IO#close_on_exec?;F;[;[[@i ;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;H ;II" overload;F;J0;;;K0;#I"close_on_exec?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @¤;[;I"@return [Boolean];T;0; @¤;@F;Mi;N0;[; @¤;[;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; @¤;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"IO#close_on_exec=;F;[[I"arg;T0;[[@iP;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;H ;II" overload;F;J0;;;K0;#I"close_on_exec=(bool);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ݤ;[;I"@return [Boolean];T;0; @ݤ;@F;Mi;N0;[[I" bool;T0; @ݤ;[;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; @ݤ;@F;Ao;B;CT;Di<;EiM;!@;"I"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; ; F; ;,;;;I" IO#close;F;[;[[@i;T;: close;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;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#closed?;F;[;[[@i;T;: closed?;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;H ;II" overload;F;J0;;;K0;#I" closed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"tstatic 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 0 <= fptr->fd ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#close_read;F;[;[[@iA;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;H ;II" overload;F;J0;;;K0;#I"close_read;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @2;[;I"@return [nil];T;0; @2;@F;Mi;N0;[; @2;[;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; @2;@F;Ao;B;CT;Di-;Ei>;!@;"I"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; ; F; ;,;;;I"IO#close_write;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I"close_write;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @M;[;I"@return [nil];T;0; @M;@F;Mi;N0;[; @M;[;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; @M;@F;Ao;B;CT;Dij;Ei|;!@;"I"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; ; F; ;,;;;I"IO#isatty;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" isatty;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @h;[;I"@return [Boolean];T;0; @h;@F;Mi;N0;[; @ho;H ;II" overload;F;J0;: tty?;K0;#I" tty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @h;[;I"@return [Boolean];T;0; @h;@F;Mi;N0;[; @h;[;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; @h;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_io_isatty(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); if (isatty(fptr->fd) == 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#tty?;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" isatty;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" tty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE rb_io_isatty(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); if (isatty(fptr->fd) == 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#binmode;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" binmode;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@return [IO];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#binmode?;F;[;[[@i%;T;: binmode?;0;[;{;IC;":Returns true if ios is binmode.;T;[o;H ;II" overload;F;J0;; ;K0;#I" binmode?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ҥ;[;I"@return [Boolean];T;0; @ҥ;@F;Mi;N0;[; @ҥ;[;I"cReturns true if ios is binmode. @overload binmode? @return [Boolean];T;0; @ҥ;@F;Ao;B;CT;Di;Ei#;Mi;!@;"I"static VALUE rb_io_binmode_p(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); return fptr->mode & FMODE_BINMODE ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#sysseek;F;[[@0;[[@i;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;H ;II" overload;F;J0;; ;K0;#I")sysseek(offset, whence=IO::SEEK_SET);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" offset;T0[I" whence;TI"IO::SEEK_SET;T; @;[;I"pSeeks 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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IO#advise;F;[[@0;[[@io$;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;H ;II" overload;F;J0;; ;K0;#I"$advise(advice, offset=0, len=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" advice;T0[I" offset;TI"0;T[I"len;TI"0;T; @;[;I"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. @overload advise(advice, offset=0, len=0) @return [nil];T;0; @;@F;Ao;B;CT;DiE$;Eim$;!@;"I"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; ; F; ;,;;;I" IO#ioctl;F;[[@0;[[@i\&;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;H ;II" overload;F;J0;; ;K0;#I"ioctl(integer_cmd, arg);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @2;[;I"@return [Integer];T;0; @2;@F;Mi;N0;[[I"integer_cmd;T0[I"arg;T0; @2;[;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; @2;@F;Ao;B;CT;DiP&;EiY&;!@;"I"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; ; F; ;,;;;I" IO#fcntl;F;[[@0;[[@i&;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;H ;II" overload;F;J0;; ;K0;#I"fcntl(integer_cmd, arg);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @R;[;I"@return [Integer];T;0; @R;@F;Mi;N0;[[I"integer_cmd;T0[I"arg;T0; @R;[;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; @R;@F;Ao;B;CT;Di&;Ei&;!@;"I"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; ; F; ;,;;;I" IO#pid;F;[;[[@i ;T;;;0;[;{;IC;"XReturns the process ID of a child process associated with ios. This will be set 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 produces: In child, pid is 26209 In parent, child pid is 26209 ;T;[o;H ;II" overload;F;J0;;;K0;#I"pid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @r;[;I"@return [Integer];T;0; @r;@F;Mi;N0;[; @r;[;I"|Returns the process ID of a child process associated with ios. This will be set 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 produces: In child, pid is 26209 In parent, child pid is 26209 @overload pid @return [Integer];T;0; @r;@F;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;,;;;I"IO#inspect;F;[;[[@i" ;T;;i;0;[;{;IC;"/Return a string describing this IO object. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"VReturn a string describing this IO object. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"IO#external_encoding;F;[;[[@i'-;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;H ;II" overload;F;J0;;;K0;#I"external_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @;[;I"@return [Encoding];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di-;Ei$-;!@;"I"lstatic VALUE rb_io_external_encoding(VALUE io) { rb_io_t *fptr; GetOpenFile(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; ; F; ;,;;;I"IO#internal_encoding;F;[;[[@i@-;T;:internal_encoding;0;[;{;IC;"fReturns the Encoding of the internal string if conversion is specified. Otherwise returns +nil+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"internal_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @æ;[;I"@return [Encoding];T;0; @æ;@F;Mi;N0;[; @æ;[;I"Returns the Encoding of the internal string if conversion is specified. Otherwise returns +nil+. @overload internal_encoding @return [Encoding];T;0; @æ;@F;Ao;B;CT;Di8-;Ei=-;!@;"I"static VALUE rb_io_internal_encoding(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); if (!fptr->encs.enc2) return Qnil; return rb_enc_from_encoding(io_read_encoding(fptr)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#set_encoding;F;[[@0;[[@i]-;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;H ;II" overload;F;J0;;;K0;#I"set_encoding(ext_enc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @ަ;[;I"@return [IO];T;0; @ަ;@F;Mi;N0;[[I" ext_enc;T0; @ަo;H ;II" overload;F;J0;;;K0;#I"$set_encoding("ext_enc:int_enc");T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @ަ;[;I"@return [IO];T;0; @ަ;@F;Mi;N0;[[""ext_enc:" int_enc"; @ަo;H ;II" overload;F;J0;;;K0;#I"#set_encoding(ext_enc, int_enc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @ަ;[;I"@return [IO];T;0; @ަ;@F;Mi;N0;[[I" ext_enc;T0[I" int_enc;T0; @ަo;H ;II" overload;F;J0;;;K0;#I")set_encoding("ext_enc:int_enc", opt);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @ަ;[;I"@return [IO];T;0; @ަ;@F;Mi;N0;[[""ext_enc:" int_enc"[I"opt;T0; @ަo;H ;II" overload;F;J0;;;K0;#I"(set_encoding(ext_enc, int_enc, opt);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @ަ;[;I"@return [IO];T;0; @ަ;@F;Mi;N0;[[I" ext_enc;T0[I" int_enc;T0[I"opt;T0; @ަ;[;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; @ަ;@F;Ao;B;CT;DiJ-;Ei^-;!@;"I"cstatic 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 rb_funcallv(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; ; F; ;,;;;I"IO#autoclose?;F;[;[[@i ;T;:autoclose?;0;[;{;IC;"~Returns +true+ if the underlying file descriptor of _ios_ will be closed automatically at its finalization, otherwise +false+.;T;[o;H ;II" overload;F;J0;;;K0;#I"autoclose?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @B;[;I"@return [Boolean];T;0; @B;@F;Mi;N0;[; @B;[;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; @B;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I"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; ; F; ;,;;;I"IO#autoclose=;F;[[I"autoclose;T0;[[@i ;T;:autoclose=;0;[;{;IC;"Sets auto-close flag. f = open("/dev/null") IO.for_fd(f.fileno) # ... f.gets # may cause IOError f = open("/dev/null") IO.for_fd(f.fileno).autoclose = true # ... f.gets # won't cause IOError ;T;[o;H ;II" overload;F;J0;;;K0;#I"autoclose=(bool);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @];[;I"@return [Boolean];T;0; @];@F;Mi;N0;[[I" bool;T0; @];[;I" Sets auto-close flag. f = open("/dev/null") IO.for_fd(f.fileno) # ... f.gets # may cause IOError f = open("/dev/null") IO.for_fd(f.fileno).autoclose = true # ... f.gets # won't cause IOError @overload autoclose=(bool) @return [Boolean];T;0; @];@F;Ao;B;CT;Di ;Ei ;!@;"I"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 io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#pathconf;F;[[I"arg;T0;[[@xci;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; @|;@F;Ao;B;CT;Dix;Ei;!@;"I"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; ; F; ;,;;;I" IO#raw;F;[[@0;[[I"ext/io/console/console.c;Ti6;T;:raw;0;[;{;IC;"Yields +self+ within raw mode. 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) Refer to the manual page of termios for further details. You must require 'io/console' to use this method. ;T;[o;H ;II" overload;F;J0;;;K0;#I"raw(min: nil, time: nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"io;T; @;[;I"@yield [io];T;0; @;@F;Mi;N0;[[I" min:;TI"nil;T[I" time:;TI"nil;T; @;[;I"Yields +self+ within raw mode. 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) 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) @yield [io];T;0; @;@F;Ao;B;CT;Di";Ei4;!@;"I"static VALUE console_raw(int argc, VALUE *argv, VALUE io) { rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts); return ttymode(io, rb_yield, set_rawmode, optp); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#raw!;F;[[@0;[[@iI;T;: raw!;0;[;{;IC;"Enables raw mode. 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;H ;II" overload;F;J0;;;K0;#I"raw!(min: nil, time: nil);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" min:;TI"nil;T[I" time:;TI"nil;T; @;[;I"Enables raw mode. 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);T;0; @;@F;Ao;B;CT;Di=;EiF;!@;"I"cstatic 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, &opts); GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!getattr(fd, &t)) rb_sys_fail(0); set_rawmode(&t, optp); if (!setattr(fd, &t)) rb_sys_fail(0); return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#cooked;F;[;[[@ie;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;H ;II" overload;F;J0;;;K0;#I" cooked;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"io;T; @̧;[;I"@yield [io];T;0; @̧;@F;Mi;N0;[; @̧;[;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;Ao;B;CT;DiY;Eic;!@;"I"fstatic VALUE console_cooked(VALUE io) { return ttymode(io, rb_yield, set_cookedmode, NULL); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#cooked!;F;[;[[@iu;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;H ;II" overload;F;J0;;;K0;#I" cooked!;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Dik;Eir;!@;"I"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)) rb_sys_fail(0); set_cookedmode(&t, NULL); if (!setattr(fd, &t)) rb_sys_fail(0); return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#getch;F;[[@0;[[@i;T;: getch;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;H ;II" overload;F;J0;;;K0;#I"getch(min: nil, time: nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" min:;TI"nil;T[I" time:;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) @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE console_getch(int argc, VALUE *argv, VALUE io) { rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts); return ttymode(io, getc_call, set_rawmode, optp); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#echo=;F;[[I"f;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"echo=(flag);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"Bstatic 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)) rb_sys_fail(0); if (RTEST(f)) set_echo(&t, NULL); else set_noecho(&t, NULL); if (!setattr(fd, &t)) rb_sys_fail(0); return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#echo?;F;[;[[@i;T;: echo?;0;[;{;IC;"_Returns +true+ if echo back is enabled. You must require 'io/console' to use this method.;T;[o;H ;II" overload;F;J0;;;K0;#I" echo?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @9;[;I"@return [Boolean];T;0; @9;@F;Mi;N0;[; @9;[;I"Returns +true+ if echo back is enabled. You must require 'io/console' to use this method. @overload echo? @return [Boolean];T;0; @9;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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)) rb_sys_fail(0); return echo_p(&t) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#noecho;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" noecho;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"io;T; @T;[;I"@yield [io];T;0; @T;@F;Mi;N0;[; @T;[;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; @T;@F;Ao;B;CT;Di;Ei;!@;"I"bstatic VALUE console_noecho(VALUE io) { return ttymode(io, rb_yield, set_noecho, NULL); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#winsize;F;[;[[@i;T;: winsize;0;[;{;IC;"MReturns console size. You must require 'io/console' to use this method. ;T;[o;H ;II" overload;F;J0;;;K0;#I" winsize;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @o;[;I"@return [Array];T;0; @o;@F;Mi;N0;[; @o;[;I"sReturns console size. You must require 'io/console' to use this method. @overload winsize @return [Array];T;0; @o;@F;Ao;B;CT;Di;Ei;!@;"I"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)) rb_sys_fail(0); return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#winsize=;F;[[I" size;T0;[[@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; @;@F;Ao;B;CT;Di;Ei ;!@;"I"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)) rb_sys_fail(0); #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; ; F; ;,;;;I"IO#iflush;F;[;[[@i\;T;: iflush;0;[;{;IC;"WFlushes input buffer in kernel. You must require 'io/console' to use this method. ;T;[o;H ;II" overload;F;J0;;;K0;#I" iflush;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"jFlushes input buffer in kernel. You must require 'io/console' to use this method. @overload iflush;T;0; @;@F;Ao;B;CT;DiT;EiY;!@;"I"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)) rb_sys_fail(0); #endif (void)fd; return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#oflush;F;[;[[@is;T;: oflush;0;[;{;IC;"XFlushes output buffer in kernel. You must require 'io/console' to use this method. ;T;[o;H ;II" overload;F;J0;;;K0;#I" oflush;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"kFlushes output buffer in kernel. You must require 'io/console' to use this method. @overload oflush;T;0; @;@F;Ao;B;CT;Dik;Eip;!@;"I"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)) rb_sys_fail(0); #endif (void)fd; return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#ioflush;F;[;[[@i;T;: ioflush;0;[;{;IC;"cFlushes input and output buffers in kernel. You must require 'io/console' to use this method. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" ioflush;T;IC;";T;[;[;I";T;0; @ƨ;@F;Mi;N0;[; @ƨ;[;I"wFlushes input and output buffers in kernel. You must require 'io/console' to use this method. @overload ioflush;T;0; @ƨ;@F;Ao;B;CT;Di;Ei;!@;"I"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)) rb_sys_fail(0); if (tcflush(fd2, TCOFLUSH)) rb_sys_fail(0); } else { if (tcflush(fd1, TCIOFLUSH)) rb_sys_fail(0); } #endif return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#beep;F;[;[[@i;T;: beep;0;[;{;IC;" ;T;[;[;@;0; @ܨ;!@;"I"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) rb_sys_fail(0); #endif return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#goto;F;[[I"x;T0[I"y;T0;[[@i;T;: goto;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"Qstatic VALUE console_goto(VALUE io, VALUE x, VALUE y) { rb_io_t *fptr; int fd; COORD pos; GetOpenFile(io, fptr); fd = GetWriteFD(fptr); pos.X = NUM2UINT(x); pos.Y = NUM2UINT(y); if (!SetConsoleCursorPosition((HANDLE)rb_w32_get_osfhandle(fd), pos)) { rb_syserr_fail(LAST_ERROR, 0); } return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#cursor;F;[;[[@i;T;: cursor;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"lstatic VALUE console_cursor_pos(VALUE io) { rb_io_t *fptr; int fd; rb_console_size_t ws; GetOpenFile(io, fptr); fd = GetWriteFD(fptr); if (!GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), &ws)) { rb_syserr_fail(LAST_ERROR, 0); } return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.X), UINT2NUM(ws.dwCursorPosition.Y)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#cursor=;F;[[I" cpos;T0;[[@i;T;: cursor=;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"IO#pressed?;F;[[I"k;T0;[[@i;T;: pressed?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;Mi;!@;"I"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; ; F; ;,;;;I"IO#getpass;F;[[@0;[[@i;T;: getpass;0;[;{;IC;"Reads and returns a line without echo back. Prints +prompt+ unless it is +nil+. You must require 'io/console' to use this method. ;T;[o;H ;II" overload;F;J0;;&;K0;#I"getpass(prompt=nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I"@return [String];T;0; @#;@F;Mi;N0;[[I" prompt;TI"nil;T; @#;[;I"Reads and returns a line without echo back. Prints +prompt+ unless it is +nil+. You must require 'io/console' to use this method. @overload getpass(prompt=nil) @return [String];T;0; @#;@F;Ao;B;CT;Di;Ei;!@;"I"=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; ; F; ;;;;I"IO.console;F;[[@0;[[@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;H ;II" overload;F;J0;;';K0;#I" console;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I"#];T;0; @B;@F;Mi;N0;[; @Bo;H ;II" overload;F;J0;;';K0;#I"console(sym, *args);T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;,;;;I"IO::generic_readable#getch;F;[[@0;[[@ie;T;;;0;[;{;IC;"See IO#getch. ;T;[o;H ;II" overload;F;J0;;;K0;#I"getch(min: nil, time: nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @l;[;I"@return [String];T;0; @l;@F;Mi;N0;[[I" min:;TI"nil;T[I" time:;TI"nil;T; @l;[;I"LSee IO#getch. @overload getch(min: nil, time: nil) @return [String];T;0; @l;@F;Ao;B;CT;Di_;Eic;!@j;"I"pstatic VALUE io_getch(int argc, VALUE *argv, VALUE io) { return rb_funcallv(io, id_getc, argc, argv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!IO::generic_readable#getpass;F;[[@0;[[@i;T;;&;0;[;{;IC;"See IO#getpass. ;T;[o;H ;II" overload;F;J0;;&;K0;#I"getpass(prompt=nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" prompt;TI"nil;T; @;[;I"GSee IO#getpass. @overload getpass(prompt=nil) @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@j;"I"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; ; F; ;,;;;I""IO::generic_readable#readchar;F;[;[[I"ext/stringio/stringio.c;Tic;T;;;0;[;{;IC;"See IO#readchar. ;T;[o;H ;II" overload;F;J0;;;K0;#I" readchar;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"=See IO#readchar. @overload readchar @return [String];T;0; @;@F;Ao;B;CT;Di];Eia;!@j;"I"static VALUE strio_readchar(VALUE self) { VALUE c = rb_funcall2(self, rb_intern("getc"), 0, 0); if (NIL_P(c)) rb_eof_error(); return c; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""IO::generic_readable#readbyte;F;[;[[@iq;T;;;0;[;{;IC;"See IO#readbyte. ;T;[o;H ;II" overload;F;J0;;;K0;#I" readbyte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @ɩ;[;I"@return [Fixnum];T;0; @ɩ;@F;Mi;N0;[; @ɩ;[;I"=See IO#readbyte. @overload readbyte @return [Fixnum];T;0; @ɩ;@F;Ao;B;CT;Dik;Eio;!@j;"I"static VALUE strio_readbyte(VALUE self) { VALUE c = rb_funcall2(self, rb_intern("getbyte"), 0, 0); if (NIL_P(c)) rb_eof_error(); return c; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""IO::generic_readable#readline;F;[[@0;[[@i;T;;;0;[;{;IC;"See IO#readline. ;T;[o;H ;II" overload;F;J0;;;K0;#I"readline(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"sep;TI"$/;T; @o;H ;II" overload;F;J0;;;K0;#I"readline(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I" limit;T0; @o;H ;II" overload;F;J0;;;K0;#I"readline(sep, limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @;[;I"See IO#readline. @overload readline(sep=$/) @return [String] @overload readline(limit) @return [String, nil] @overload readline(sep, limit) @return [String, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@j;"I"static VALUE strio_readline(int argc, VALUE *argv, VALUE self) { VALUE line = rb_funcall2(self, rb_intern("gets"), argc, argv); if (NIL_P(line)) rb_eof_error(); return line; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!IO::generic_readable#sysread;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"sysread(integer[, outbuf]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @%;[;I"@return [String];T;0; @%;@F;Mi;N0;[[I"integer[, outbuf];T0; @%o;H ;II" overload;F;J0;;;K0;#I"#readpartial(integer[, outbuf]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @%;[;I"@return [String];T;0; @%;@F;Mi;N0;[[I"integer[, outbuf];T0; @%;[;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; @%;@F;Ao;B;CT;Di;Ei;!@j;"I"static VALUE strio_sysread(int argc, VALUE *argv, VALUE self) { VALUE val = rb_funcall2(self, rb_intern("read"), argc, argv); if (NIL_P(val)) { rb_eof_error(); } return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"%IO::generic_readable#readpartial;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"sysread(integer[, outbuf]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @R;[;I"@return [String];T;0; @R;@F;Mi;N0;[[I"integer[, outbuf];T0; @Ro;H ;II" overload;F;J0;;;K0;#I"#readpartial(integer[, outbuf]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @R;[;I"@return [String];T;0; @R;@F;Mi;N0;[[I"integer[, outbuf];T0; @R;[;@N;0; @R;@F;Ao;B;CT;Di;Ei;!@j;"I"static VALUE strio_sysread(int argc, VALUE *argv, VALUE self) { VALUE val = rb_funcall2(self, rb_intern("read"), argc, argv); if (NIL_P(val)) { rb_eof_error(); } return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"'IO::generic_readable#read_nonblock;F;[[@0;[[@i;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;H ;II" overload;F;J0;;(;K0;#I".read_nonblock(integer[, outbuf [, opts]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @~;[;I"@return [String];T;0; @~;@F;Mi;N0;[[I"integer[, outbuf [, opts]];T0; @~;[;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; @~;@F;Ao;B;CT;Di;Ei;!@j;"I"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;&@j;'IC;[;&@j;(IC;[;&@j;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;F;:generic_readable;;0;;;[;{;IC;" ;T;[;[;@;0; @j;Mi;!@;I"IO::generic_readable;Fo; ; F; ;,;;;I" IO#nread;F;[;[[I"ext/io/wait/wait.c;TiT;T;: nread;0;[;{;IC;"iReturns number of bytes that can be read without blocking. Returns zero if no information available. ;T;[o;H ;II" overload;F;J0;;*;K0;#I" nread;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns number of bytes that can be read without blocking. Returns zero if no information available. @overload nread @return [Integer];T;0; @;@F;Ao;B;CT;DiL;EiQ;!@;"I"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; ; F; ;,;;;I"IO#ready?;F;[;[[@im;T;: ready?;0;[;{;IC;"iReturns true if input available without blocking, or false. Returns nil if no information available.;T;[o;H ;II" overload;F;J0;;+;K0;#I" ready?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @Ȫ;[;I"@return [true, false, nil];T;0; @Ȫ;@F;Mi;N0;[; @Ȫ;[;I"Returns true if input available without blocking, or false. Returns nil if no information available. @overload ready? @return [true, false, nil];T;0; @Ȫ;@F;Ao;B;CT;Die;Eij;Mi;!@;"I"static VALUE io_ready_p(VALUE io) { rb_io_t *fptr; struct timeval tv = {0, 0}; GetOpenFile(io, fptr); rb_io_check_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; if (wait_for_single_fd(fptr, RB_WAITFD_IN, &tv)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" IO#wait;F;[[@0;[[@i;T;;;0;[;{;IC;"Waits until IO is readable or writable without blocking and returns +self+, or +nil+ when times out. Returns +true+ immediately when buffered data is available. Optional parameter +mode+ is one of +:read+, +:write+, or +:read_write+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"&wait(timeout = nil, mode = :read);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI"nil;T; @;[;I"@return [true, nil];T;0; @;@F;Mi;N0;[[I" timeout;TI"nil;T[I" mode;TI" :read;T; @;[;I"-Waits until IO is readable or writable without blocking and returns +self+, or +nil+ when times out. Returns +true+ immediately when buffered data is available. Optional parameter +mode+ is one of +:read+, +:write+, or +:read_write+. @overload wait(timeout = nil, mode = :read) @return [true, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE io_wait_readwrite(int argc, VALUE *argv, VALUE io) { 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; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#wait_readable;F;[[@0;[[@i;T;:wait_readable;0;[;{;IC;"Waits until IO is readable without blocking and returns +self+, or +nil+ when times out. Returns +true+ immediately when buffered data is available. ;T;[o;H ;II" overload;F;J0;;,;K0;#I"wait_readable;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI"nil;T; @;[;I"@return [true, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;,;K0;#I"wait_readable(timeout);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI"nil;T; @;[;I"@return [true, nil];T;0; @;@F;Mi;N0;[[I" timeout;T0; @;[;I"Waits until IO is readable without blocking and returns +self+, or +nil+ when times out. Returns +true+ immediately when buffered data is available. @overload wait_readable @return [true, nil] @overload wait_readable(timeout) @return [true, nil];T;0; @;@F;Ao;B;CT;Di{;Ei~;!@;"I"zstatic VALUE io_wait_readable(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr; struct timeval timerec; struct timeval *tv; GetOpenFile(io, fptr); rb_io_check_readable(fptr); tv = get_timeout(argc, argv, &timerec); if (rb_io_read_pending(fptr)) return Qtrue; if (wait_for_single_fd(fptr, RB_WAITFD_IN, tv)) { return io; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#wait_writable;F;[[@0;[[@i;T;:wait_writable;0;[;{;IC;"\Waits until IO is writable without blocking and returns +self+ or +nil+ when times out. ;T;[o;H ;II" overload;F;J0;;-;K0;#I"wait_writable;T;IC;";T;[;[;I";T;0; @5;@F;Mi;N0;[; @5o;H ;II" overload;F;J0;;-;K0;#I"wait_writable(timeout);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @5;[;I"@return [nil];T;0; @5;@F;Mi;N0;[[I" timeout;T0; @5;[;I"Waits until IO is writable without blocking and returns +self+ or +nil+ when times out. @overload wait_writable @overload wait_writable(timeout) @return [nil];T;0; @5;@F;Ao;B;CT;Di;Ei;!@;"I"Kstatic VALUE io_wait_writable(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr; struct timeval timerec; struct timeval *tv; GetOpenFile(io, fptr); rb_io_check_writable(fptr); tv = get_timeout(argc, argv, &timerec); if (wait_for_single_fd(fptr, RB_WAITFD_OUT, tv)) { return io; } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#nonblock?;F;[;[[I"ext/io/nonblock/nonblock.c;Ti,;T;:nonblock?;0;[;{;IC;"fd) & O_NONBLOCK) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"IO#nonblock=;F;[[I"nb;T0;[[@`iS;T;:nonblock=;0;[;{;IC;"eEnables non-blocking mode on a stream when set to +true+, and blocking mode when set to +false+. ;T;[o;H ;II" overload;F;J0;;/;K0;#I"nonblock=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @w;[;I"@return [Boolean];T;0; @w;@F;Mi;N0;[[I" boolean;T0; @w;[;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; @w;@F;Ao;B;CT;DiL;EiQ;!@;"I"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; ; F; ;,;;;I"IO#nonblock;F;[[@0;[[@`ir;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;H ;II" overload;F;J0;;0;K0;#I" nonblock;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"io;T; @o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@yield [io] @return [IO];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;0;K0;#I"nonblock(boolean);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"io;T; @o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@yield [io] @return [IO];T;0; @;@F;Mi;N0;[[I" boolean;T0; @;[;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; @;@F;Ao;B;CT;Dih;Eis;!@;"I"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;[ o; ; F; ;,;;;I"IO::generic_writable#<<;F;[;[;F;;Q;;0;[;{;IC;" ;T;[;[;@;0; @ͫ;!@˫;$To; ; F; ;,;;;I"IO::generic_writable#print;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @֫;!@˫;$To; ; F; ;,;;;I" IO::generic_writable#printf;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @߫;!@˫;$To; ; F; ;,;;;I"IO::generic_writable#puts;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @;!@˫;$To; ; F; ;,;;;I""IO::generic_writable#syswrite;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @;!@˫;$To; ; F; ;,;;;I"(IO::generic_writable#write_nonblock;F;[[@0;[[@i;T;:write_nonblock;0;[;{;IC;" ;T;[;[;@;0; @;!@˫;"I"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;&@˫;'IC;[;&@˫;(IC;[;&@˫;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;:generic_writable;;0;;;[;{;IC;" ;T;[;[;@;0; @˫;!@;I"IO::generic_writable;Fo; ; F; ;,;;;I" IO#stat;F;[;[[@ki;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;H ;II" overload;F;J0;;3;K0;#I" stat;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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;$T;&@;'IC;[;&@;(IC;[o;2 ;30;40;50;;1;!@;7@C;F0o; ;IC;[o;9;[[@ki;F;: RDONLY;;;;;;[;{;IC;"open for reading only ;T;[;[;I"open for reading only;T;0; @1;@F;Ao;B;CT;Di;Ei;!@/;I"File::Constants::RDONLY;F; 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; @X;@F;Ao;B;CT;DiW;Eib;!@V;"I"static VALUE rb_io_s_open(int argc, VALUE *argv, VALUE klass) { VALUE io = rb_class_new_instance(argc, argv, klass); if (rb_block_given_p()) { return rb_ensure(rb_yield, io, io_close, io); } return io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File#initialize;F;[[@0;[[@i{ ;T;;;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;H ;II" overload;F;J0;; ;K0;#I"$new(filename, mode="r" [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" File;T; @f;[;I"@return [File];T;0; @f;@F;Mi;N0;[[I" filename;T0[I" mode;TI""r"[, opt];T; @fo;H ;II" overload;F;J0;; ;K0;#I",new(filename [, mode [, perm]] [, opt]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" File;T; @f;[;I"@return [File];T;0; @f;@F;Mi;N0;[[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;Ao;B;CT;Dia ;Eiy ;!@V;"I"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; ; F; ;;;;I"File.fnmatch;F;[[@0;[[I" dir.c;Ti ;T;: fnmatch;0;[;{;IC;"GReturns true if +path+ matches against +pattern+. The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. It may contain the following metacharacters: *:: Matches any file. Can be restricted by other values in the glob. Equivalent to / .* /x in regexp. *:: Matches all files regular files c*:: Matches all files beginning with c *c:: Matches all files ending with c \*c*:: Matches all files that have c in them (including at the beginning or end). To match hidden files (that start with a . set the File::FNM_DOTMATCH flag. **:: Matches directories recursively or files expansively. ?:: Matches any one character. Equivalent to /.{1}/ in regexp. [set]:: Matches any one character in +set+. Behaves exactly like character sets in Regexp, including set negation ([^a-z]). \ :: Escapes the next metacharacter. {a,b}:: Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled. Behaves like a Regexp union ((?:a|b)). +flags+ is a bitwise OR of the FNM_XXX constants. The same glob pattern and flags are used by Dir::glob. Examples: File.fnmatch('cat', 'cat') #=> true # match entire string File.fnmatch('cat', 'category') #=> false # only match partial string File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character File.fnmatch('c??t', 'cat') #=> false # ditto File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!') File.fnmatch('cat', 'CAT') #=> false # case sensitive File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default. File.fnmatch('.*', '.profile') #=> true rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string. File.fnmatch(rbfiles, 'main.rb') #=> false File.fnmatch(rbfiles, './main.rb') #=> false File.fnmatch(rbfiles, 'lib/song.rb') #=> true File.fnmatch('**.rb', 'main.rb') #=> true File.fnmatch('**.rb', './main.rb') #=> false File.fnmatch('**.rb', 'lib/song.rb') #=> true File.fnmatch('*', 'dave/.profile') #=> true pattern = '*' '/' '*' File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true pattern = '**' '/' 'foo' File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true ;T;[o;H ;II" overload;F;J0;;L;K0;#I"&fnmatch( pattern, path, [flags] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" pattern;T0[I" path;T0[I" [flags];T0; @o;H ;II" overload;F;J0;: fnmatch?;K0;#I"'fnmatch?( pattern, path, [flags] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" pattern;T0[I" path;T0[I" [flags];T0; @;[;I"Returns true if +path+ matches against +pattern+. The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. It may contain the following metacharacters: *:: Matches any file. Can be restricted by other values in the glob. Equivalent to / .* /x in regexp. *:: Matches all files regular files c*:: Matches all files beginning with c *c:: Matches all files ending with c \*c*:: Matches all files that have c in them (including at the beginning or end). To match hidden files (that start with a . set the File::FNM_DOTMATCH flag. **:: Matches directories recursively or files expansively. ?:: Matches any one character. Equivalent to /.{1}/ in regexp. [set]:: Matches any one character in +set+. Behaves exactly like character sets in Regexp, including set negation ([^a-z]). \ :: Escapes the next metacharacter. {a,b}:: Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled. Behaves like a Regexp union ((?:a|b)). +flags+ is a bitwise OR of the FNM_XXX constants. The same glob pattern and flags are used by Dir::glob. Examples: File.fnmatch('cat', 'cat') #=> true # match entire string File.fnmatch('cat', 'category') #=> false # only match partial string File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character File.fnmatch('c??t', 'cat') #=> false # ditto File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!') File.fnmatch('cat', 'CAT') #=> false # case sensitive File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default. File.fnmatch('.*', '.profile') #=> true rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string. File.fnmatch(rbfiles, 'main.rb') #=> false File.fnmatch(rbfiles, './main.rb') #=> false File.fnmatch(rbfiles, 'lib/song.rb') #=> true File.fnmatch('**.rb', 'main.rb') #=> true File.fnmatch('**.rb', './main.rb') #=> false File.fnmatch('**.rb', 'lib/song.rb') #=> true File.fnmatch('*', 'dave/.profile') #=> true pattern = '*' '/' '*' File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true pattern = '**' '/' 'foo' File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true @overload fnmatch( pattern, path, [flags] ) @return [Boolean] @overload fnmatch?( pattern, path, [flags] ) @return [Boolean];T;0; @;@F;Ao;B;CT;Di8 ;Ei ;!@V;"I"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; ; F; ;;;;I"File.fnmatch?;F;[[@0;[[@i ;T;;M;0;[;{;IC;"GReturns true if +path+ matches against +pattern+. The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. It may contain the following metacharacters: *:: Matches any file. Can be restricted by other values in the glob. Equivalent to / .* /x in regexp. *:: Matches all files regular files c*:: Matches all files beginning with c *c:: Matches all files ending with c \*c*:: Matches all files that have c in them (including at the beginning or end). To match hidden files (that start with a . set the File::FNM_DOTMATCH flag. **:: Matches directories recursively or files expansively. ?:: Matches any one character. Equivalent to /.{1}/ in regexp. [set]:: Matches any one character in +set+. Behaves exactly like character sets in Regexp, including set negation ([^a-z]). \ :: Escapes the next metacharacter. {a,b}:: Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled. Behaves like a Regexp union ((?:a|b)). +flags+ is a bitwise OR of the FNM_XXX constants. The same glob pattern and flags are used by Dir::glob. Examples: File.fnmatch('cat', 'cat') #=> true # match entire string File.fnmatch('cat', 'category') #=> false # only match partial string File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character File.fnmatch('c??t', 'cat') #=> false # ditto File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!') File.fnmatch('cat', 'CAT') #=> false # case sensitive File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default. File.fnmatch('.*', '.profile') #=> true rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string. File.fnmatch(rbfiles, 'main.rb') #=> false File.fnmatch(rbfiles, './main.rb') #=> false File.fnmatch(rbfiles, 'lib/song.rb') #=> true File.fnmatch('**.rb', 'main.rb') #=> true File.fnmatch('**.rb', './main.rb') #=> false File.fnmatch('**.rb', 'lib/song.rb') #=> true File.fnmatch('*', 'dave/.profile') #=> true pattern = '*' '/' '*' File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true pattern = '**' '/' 'foo' File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true;T;[o;H ;II" overload;F;J0;;L;K0;#I"&fnmatch( pattern, path, [flags] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @̭;[;I"@return [Boolean];T;0; @̭;@F;Mi;N0;[[I" pattern;T0[I" path;T0[I" [flags];T0; @̭o;H ;II" overload;F;J0;;M;K0;#I"'fnmatch?( pattern, path, [flags] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @̭;[;I"@return [Boolean];T;0; @̭;@F;Mi;N0;[[I" pattern;T0[I" path;T0[I" [flags];T0; @̭;[;@ȭ;0; @̭;@F;Ao;B;CT;Di8 ;Ei ;Mi;!@V;"I"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; ; F; ;,;;;I"File::Stat#initialize;T;[[I" fname;T0;[[@ki<;T;;;0;[;{;IC;"iCreate a File::Stat object for the given file name (raising an exception if the file doesn't exist). ;T;[o;H ;II" overload;F;J0;:File::Stat.new;K0;#I"File::Stat.new(file_name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Di3;Ei7;!@;"I"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; ; F; ;,;;;I"File::Stat#initialize_copy;T;[[I" orig;T0;[[@kiR;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;DiQ;EiQ;!@;"I"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; ; F; ;,;;;I"File::Stat#<=>;T;[[I" other;T0;[[@ki;T;;V;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;H ;II" overload;F;J0;;V;K0;#I"<=>(other_stat);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"1;TI"nil;T; @,;[;I"@return [-1, 0, 1, nil];T;0; @,;@F;Mi;N0;[[I"other_stat;T0; @,;[;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; @,;@F;Ao;B;CT;Di;Ei;!@;"I"$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; ; F; ;,;;;I"File::Stat#dev;T;[;[[@ki*;T;:dev;0;[;{;IC;"uReturns an integer representing the device on which stat resides. File.stat("testfile").dev #=> 774 ;T;[o;H ;II" overload;F;J0;;O;K0;#I"dev;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @N;[;I"@return [Integer];T;0; @N;@F;Mi;N0;[; @N;[;I"Returns an integer representing the device on which stat resides. File.stat("testfile").dev #=> 774 @overload dev @return [Integer];T;0; @N;@F;Ao;B;CT;Di ;Ei';!@;"I"Zstatic VALUE rb_stat_dev(VALUE self) { return DEVT2NUM(get_stat(self)->st_dev); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#dev_major;T;[;[[@ki;;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;H ;II" overload;F;J0;;P;K0;#I"dev_major;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @i;[;I"@return [Integer];T;0; @i;@F;Mi;N0;[; @i;[;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; @i;@F;Ao;B;CT;Di0;Ei8;!@;"I"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; ; F; ;,;;;I"File::Stat#dev_minor;T;[;[[@kiP;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;H ;II" overload;F;J0;;Q;K0;#I"dev_minor;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiE;EiM;!@;"I"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; ; F; ;,;;;I"File::Stat#ino;T;[;[[@kid;T;:ino;0;[;{;IC;"ZReturns the inode number for stat. File.stat("testfile").ino #=> 1083669 ;T;[o;H ;II" overload;F;J0;;R;K0;#I"ino;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns the inode number for stat. File.stat("testfile").ino #=> 1083669 @overload ino @return [Integer];T;0; @;@F;Ao;B;CT;DiZ;Eia;!@;"I"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; ; F; ;,;;;I"File::Stat#mode;T;[;[[@ki;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;H ;II" overload;F;J0;;S;K0;#I" mode;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Dit;Ei~;!@;"I"estatic VALUE rb_stat_mode(VALUE self) { return UINT2NUM(ST2UINT(get_stat(self)->st_mode)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#nlink;T;[;[[@ki;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;H ;II" overload;F;J0;;T;K0;#I" nlink;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ծ;[;I"@return [Integer];T;0; @ծ;@F;Mi;N0;[; @ծ;[;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; @ծ;@F;Ao;B;CT;Di;Ei;!@;"I"^static VALUE rb_stat_nlink(VALUE self) { return UINT2NUM(get_stat(self)->st_nlink); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#uid;T;[;[[@ki;T;;c;0;[;{;IC;"eReturns the numeric user id of the owner of stat. File.stat("testfile").uid #=> 501 ;T;[o;H ;II" overload;F;J0;;c;K0;#I"uid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns the numeric user id of the owner of stat. File.stat("testfile").uid #=> 501 @overload uid @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Zstatic VALUE rb_stat_uid(VALUE self) { return UIDT2NUM(get_stat(self)->st_uid); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#gid;T;[;[[@ki;T;;g;0;[;{;IC;"fReturns the numeric group id of the owner of stat. File.stat("testfile").gid #=> 500 ;T;[o;H ;II" overload;F;J0;;g;K0;#I"gid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Returns the numeric group id of the owner of stat. File.stat("testfile").gid #=> 500 @overload gid @return [Integer];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"Zstatic VALUE rb_stat_gid(VALUE self) { return GIDT2NUM(get_stat(self)->st_gid); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#rdev;T;[;[[@ki;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;H ;II" overload;F;J0;;U;K0;#I" rdev;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @&;[;I"@return [Integer, nil];T;0; @&;@F;Mi;N0;[; @&;[;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; @&;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_stat_rdev(VALUE self) { #ifdef HAVE_STRUCT_STAT_ST_RDEV return DEVT2NUM(get_stat(self)->st_rdev); #else return Qnil; #endif };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#rdev_major;T;[;[[@ki;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;H ;II" overload;F;J0;;V;K0;#I"rdev_major;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @B;[;I"@return [Integer];T;0; @B;@F;Mi;N0;[; @B;[;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; @B;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"File::Stat#rdev_minor;T;[;[[@ki;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;H ;II" overload;F;J0;;W;K0;#I"rdev_minor;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @];[;I"@return [Integer];T;0; @];@F;Mi;N0;[; @];[;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; @];@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"File::Stat#size;T;[;[[@ki;T;;;0;[;{;IC;"VReturns the size of stat in bytes. File.stat("testfile").size #=> 66 ;T;[o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @x;[;I"@return [Integer];T;0; @x;@F;Mi;N0;[; @x;[;I"{Returns the size of stat in bytes. File.stat("testfile").size #=> 66 @overload size @return [Integer];T;0; @x;@F;Ao;B;CT;Di;Ei;!@;"I"\static VALUE rb_stat_size(VALUE self) { return OFFT2NUM(get_stat(self)->st_size); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#blksize;T;[;[[@ki;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;H ;II" overload;F;J0;;X;K0;#I" blksize;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"File::Stat#blocks;T;[;[[@ki(;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;H ;II" overload;F;J0;;Y;K0;#I" blocks;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei%;!@;"I" 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; ; F; ;,;;;I"File::Stat#atime;T;[;[[@ki;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;H ;II" overload;F;J0;;Z;K0;#I" atime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @˯;[;I"@return [Time];T;0; @˯;@F;Mi;N0;[; @˯;[;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; @˯;@F;Ao;B;CT;Di;Ei;!@;"I"Vstatic VALUE rb_stat_atime(VALUE self) { return stat_atime(get_stat(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#mtime;T;[;[[@ki;T;: mtime;0;[;{;IC;"uReturns the modification time of stat. File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 ;T;[o;H ;II" overload;F;J0;;[;K0;#I" mtime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aTime;T; @;[;I"@return [ aTime];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"Vstatic VALUE rb_stat_mtime(VALUE self) { return stat_mtime(get_stat(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#ctime;T;[;[[@ki;T;;C;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;H ;II" overload;F;J0;;C;K0;#I" ctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aTime;T; @;[;I"@return [ aTime];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"Vstatic VALUE rb_stat_ctime(VALUE self) { return stat_ctime(get_stat(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#birthtime;T;[;[[@ki;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;H ;II" overload;F;J0;;\;K0;#I"birthtime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aTime;T; @;[;I"@return [ aTime];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"^static VALUE rb_stat_birthtime(VALUE self) { return stat_birthtime(get_stat(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#inspect;T;[;[[@ki;T;;i;0;[;{;IC;"Produce a nicely formatted description of stat. File.stat("/etc/passwd").inspect #=> "#" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @7;[;I"@return [String];T;0; @7;@F;Mi;N0;[; @7;[;I"Produce a nicely formatted description of stat. File.stat("/etc/passwd").inspect #=> "#" @overload inspect @return [String];T;0; @7;@F;Ao;B;CT;Di;Ei;!@;"I"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, ">"); OBJ_INFECT(str, self); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#ftype;T;[;[[@kis;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;H ;II" overload;F;J0;;];K0;#I" ftype;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @R;[;I"@return [String];T;0; @R;@F;Mi;N0;[; @R;[;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; @R;@F;Ao;B;CT;Die;Eip;!@;"I"Wstatic VALUE rb_stat_ftype(VALUE obj) { return rb_file_ftype(get_stat(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#directory?;T;[;[[@ki;T;:directory?;0;[;{;IC;"Returns true if stat is a directory, false otherwise. File.stat("testfile").directory? #=> false File.stat(".").directory? #=> true;T;[o;H ;II" overload;F;J0;;^;K0;#I"directory?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @m;[;I"@return [Boolean];T;0; @m;@F;Mi;N0;[; @m;[;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; @m;@F;Ao;B;CT;Diy;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#readable?;T;[;[[@ki2;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;H ;II" overload;F;J0;;_;K0;#I"readable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di';Ei/;Mi;!@;"I"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 st->st_mode & S_IRUSR ? Qtrue : Qfalse; #endif #ifdef S_IRGRP if (rb_stat_grpowned(obj)) return st->st_mode & S_IRGRP ? Qtrue : Qfalse; #endif #ifdef S_IROTH if (!(st->st_mode & S_IROTH)) return Qfalse; #endif return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#readable_real?;T;[;[[@kiS;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;H ;II" overload;F;J0;;`;K0;#I"readable_real?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiH;EiP;Mi;!@;"I"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 st->st_mode & S_IRUSR ? Qtrue : Qfalse; #endif #ifdef S_IRGRP if (rb_group_member(get_stat(obj)->st_gid)) return st->st_mode & S_IRGRP ? Qtrue : Qfalse; #endif #ifdef S_IROTH if (!(st->st_mode & S_IROTH)) return Qfalse; #endif return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#world_readable?;T;[;[[@kiv;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;H ;II" overload;F;J0;;a;K0;#I"world_readable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Dii;Eis;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#writable?;T;[;[[@ki;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;H ;II" overload;F;J0;;b;K0;#I"writable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ڰ;[;I"@return [Boolean];T;0; @ڰ;@F;Mi;N0;[; @ڰ;[;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; @ڰ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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 st->st_mode & S_IWUSR ? Qtrue : Qfalse; #endif #ifdef S_IWGRP if (rb_stat_grpowned(obj)) return st->st_mode & S_IWGRP ? Qtrue : Qfalse; #endif #ifdef S_IWOTH if (!(st->st_mode & S_IWOTH)) return Qfalse; #endif return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#writable_real?;T;[;[[@ki;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;H ;II" overload;F;J0;;c;K0;#I"writable_real?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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 st->st_mode & S_IWUSR ? Qtrue : Qfalse; #endif #ifdef S_IWGRP if (rb_group_member(get_stat(obj)->st_gid)) return st->st_mode & S_IWGRP ? Qtrue : Qfalse; #endif #ifdef S_IWOTH if (!(st->st_mode & S_IWOTH)) return Qfalse; #endif return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#world_writable?;T;[;[[@ki;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;H ;II" overload;F;J0;;d;K0;#I"world_writable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#executable?;T;[;[[@ki;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;H ;II" overload;F;J0;;e;K0;#I"executable?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @,;[;I"@return [Boolean];T;0; @,;@F;Mi;N0;[; @,;[;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; @,;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE rb_stat_x(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (geteuid() == 0) { return st->st_mode & S_IXUGO ? Qtrue : Qfalse; } #endif #ifdef S_IXUSR if (rb_stat_owned(obj)) return st->st_mode & S_IXUSR ? Qtrue : Qfalse; #endif #ifdef S_IXGRP if (rb_stat_grpowned(obj)) return st->st_mode & S_IXGRP ? Qtrue : Qfalse; #endif #ifdef S_IXOTH if (!(st->st_mode & S_IXOTH)) return Qfalse; #endif return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" File::Stat#executable_real?;T;[;[[@ki;T;:executable_real?;0;[;{;IC;"USame as executable?, but tests using the real owner of the process.;T;[o;H ;II" overload;F;J0;;f;K0;#I"executable_real?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @G;[;I"@return [Boolean];T;0; @G;@F;Mi;N0;[; @G;[;I"Same as executable?, but tests using the real owner of the process. @overload executable_real? @return [Boolean];T;0; @G;@F;Ao;B;CT;Di;Ei ;Mi;!@;"I"static VALUE rb_stat_X(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (getuid() == 0) { return st->st_mode & S_IXUGO ? Qtrue : Qfalse; } #endif #ifdef S_IXUSR if (rb_stat_rowned(obj)) return st->st_mode & S_IXUSR ? Qtrue : Qfalse; #endif #ifdef S_IXGRP if (rb_group_member(get_stat(obj)->st_gid)) return st->st_mode & S_IXGRP ? Qtrue : Qfalse; #endif #ifdef S_IXOTH if (!(st->st_mode & S_IXOTH)) return Qfalse; #endif return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#file?;T;[;[[@ki1;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;H ;II" overload;F;J0;;g;K0;#I" file?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @b;[;I"@return [Boolean];T;0; @b;@F;Mi;N0;[; @b;[;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; @b;@F;Ao;B;CT;Di&;Ei.;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#zero?;T;[;[[@kiC;T;;;0;[;{;IC;"Returns true if stat is a zero-length file; false otherwise. File.stat("testfile").zero? #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I" zero?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @};[;I"@return [Boolean];T;0; @};@F;Mi;N0;[; @};[;I"Returns true if stat is a zero-length file; false otherwise. File.stat("testfile").zero? #=> false @overload zero? @return [Boolean];T;0; @};@F;Ao;B;CT;Di8;Ei@;Mi;!@;"I"pstatic VALUE rb_stat_z(VALUE obj) { if (get_stat(obj)->st_size == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#size?;T;[;[[@kiT;T;: size?;0;[;{;IC;"VReturns the size of stat in bytes. File.stat("testfile").size #=> 66;T;[o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"|Returns the size of stat in bytes. File.stat("testfile").size #=> 66 @overload size @return [Integer];T;0; @;@F;Ao;B;CT;DiJ;EiQ;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#owned?;T;[;[[@ki;T;: owned?;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;H ;II" overload;F;J0;;i;K0;#I" owned?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"{static VALUE rb_stat_owned(VALUE obj) { if (get_stat(obj)->st_uid == geteuid()) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File::Stat#grpowned?;T;[;[[@ki;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;H ;II" overload;F;J0;;j;K0;#I"grpowned?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @α;[;I"@return [Boolean];T;0; @α;@F;Mi;N0;[; @α;[;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; @α;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#pipe?;T;[;[[@ki;T;: pipe?;0;[;{;IC;"~Returns true if the operating system supports pipes and stat is a pipe; false otherwise.;T;[o;H ;II" overload;F;J0;;k;K0;#I" pipe?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"Returns true if the operating system supports pipes and stat is a pipe; false otherwise. @overload pipe? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#symlink?;T;[;[[@ki;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;H ;II" overload;F;J0;;l;K0;#I" symlink?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#socket?;T;[;[[@ki;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;H ;II" overload;F;J0;;m;K0;#I" socket?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#blockdev?;T;[;[[@ki;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;H ;II" overload;F;J0;;n;K0;#I"blockdev?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @:;[;I"@return [Boolean];T;0; @:;@F;Mi;N0;[; @:;[;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; @:;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#chardev?;T;[;[[@ki;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;H ;II" overload;F;J0;;o;K0;#I" chardev?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @U;[;I"@return [Boolean];T;0; @U;@F;Mi;N0;[; @U;[;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; @U;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#setuid?;T;[;[[@kih;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;H ;II" overload;F;J0;;p;K0;#I" setuid?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @p;[;I"@return [Boolean];T;0; @p;@F;Mi;N0;[; @p;[;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; @p;@F;Ao;B;CT;Di];Eie;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#setgid?;T;[;[[@ki};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;H ;II" overload;F;J0;;q;K0;#I" setgid?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Diq;Eiz;Mi;!@;"I"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; ; F; ;,;;;I"File::Stat#sticky?;T;[;[[@ki;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;H ;II" overload;F;J0;;r;K0;#I" sticky?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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;&@;'IC;[;&@;(IC;[@;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ki[@ki ;T;;;;0;;;[;{;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; @;@F;Ao;B;CT;Di;Ei);Mi;!o;2 ;30;40;50;;m;!@;7@V;F0;I"File::Stat;T;1@true if the named file is a directory, false otherwise.;T;[o;H ;II" overload;F;J0;: exist?;K0;#I"exist?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Բ;[;I"@return [Boolean];T;0; @Բ;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;Mi;!@V;"I"(VALUE rb_file_directory_p(void) { };T;#I" VALUE;T;$To; ; F; ;;;;I"File.exist?;F;[[I" fname;T0;[[@kiY;T;;s;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;H ;II" overload;F;J0;;s;K0;#I"exist?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;DiN;EiV;Mi;!@V;"I"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; ; F; ;;;;I"File.exists?;F;[[I" fname;T0;[[@kih;T;: exists?;0;[;{;IC;""Deprecated method. Don't use.;T;[o;H ;II" overload;F;J0;;t;K0;#I"exists?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;I"UDeprecated method. Don't use. @overload exists?(file_name) @return [Boolean];T;0; @;@F;Ao;B;CT;Dib;Eif;Mi;!@V;"I"static VALUE rb_file_exists_p(VALUE obj, VALUE fname) { const char *s = "FileTest#"; if (obj == rb_mFileTest) { s = "FileTest."; } else if (obj == rb_cFile || (RB_TYPE_P(obj, T_CLASS) && RTEST(rb_class_inherited_p(obj, rb_cFile)))) { s = "File."; } rb_warning("%sexists? is a deprecated name, use %sexist? instead", s, s); return rb_file_exist_p(obj, fname); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.readable?;F;[[I" fname;T0;[[@ki;T;;_;0;[;{;IC;"{Returns true if the named file is readable by the effective user and group id of this process. See eaccess(3).;T;[o;H ;II" overload;F;J0;;_;K0;#I"readable?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @/;[;I"@return [Boolean];T;0; @/;@F;Mi;N0;[[I"file_name;T0; @/;[;I"Returns true if the named file is readable by the effective user and group id of this process. See eaccess(3). @overload readable?(file_name) @return [Boolean];T;0; @/;@F;Ao;B;CT;Dix;Ei};Mi;!@V;"I"static VALUE rb_file_readable_p(VALUE obj, VALUE fname) { if (rb_eaccess(fname, R_OK) < 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.readable_real?;F;[[I" fname;T0;[[@ki;T;;`;0;[;{;IC;"zReturns true if the named file is readable by the real user and group id of this process. See access(3).;T;[o;H ;II" overload;F;J0;;`;K0;#I"readable_real?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @N;[;I"@return [Boolean];T;0; @N;@F;Mi;N0;[[I"file_name;T0; @N;[;I"Returns true if the named file is readable by the real user and group id of this process. See access(3). @overload readable_real?(file_name) @return [Boolean];T;0; @N;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"static VALUE rb_file_readable_real_p(VALUE obj, VALUE fname) { if (rb_access(fname, R_OK) < 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.world_readable?;F;[[I" fname;T0;[[@ki;T;;a;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;H ;II" overload;F;J0;;a;K0;#I"world_readable?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @m;[;I"@return [Integer, nil];T;0; @m;@F;Mi;N0;[[I"file_name;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.writable?;F;[[I" fname;T0;[[@ki;T;;b;0;[;{;IC;"{Returns true if the named file is writable by the effective user and group id of this process. See eaccess(3).;T;[o;H ;II" overload;F;J0;;b;K0;#I"writable?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;I"Returns true if the named file is writable by the effective user and group id of this process. See eaccess(3). @overload writable?(file_name) @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"static VALUE rb_file_writable_p(VALUE obj, VALUE fname) { if (rb_eaccess(fname, W_OK) < 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.writable_real?;F;[[I" fname;T0;[[@ki;T;;c;0;[;{;IC;"yReturns true if the named file is writable by the real user and group id of this process. See access(3);T;[o;H ;II" overload;F;J0;;c;K0;#I"writable_real?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;I"Returns true if the named file is writable by the real user and group id of this process. See access(3) @overload writable_real?(file_name) @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"static VALUE rb_file_writable_real_p(VALUE obj, VALUE fname) { if (rb_access(fname, W_OK) < 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.world_writable?;F;[[I" fname;T0;[[@ki;T;;d;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;H ;II" overload;F;J0;;d;K0;#I"world_writable?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @˳;[;I"@return [Integer, nil];T;0; @˳;@F;Mi;N0;[[I"file_name;T0; @˳;[;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; @˳;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.executable?;F;[[I" fname;T0;[[@ki;T;;e;0;[;{;IC;"}Returns true if the named file is executable by the effective user and group id of this process. See eaccess(3).;T;[o;H ;II" overload;F;J0;;e;K0;#I"executable?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;I"Returns true if the named file is executable by the effective user and group id of this process. See eaccess(3). @overload executable?(file_name) @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"static VALUE rb_file_executable_p(VALUE obj, VALUE fname) { if (rb_eaccess(fname, X_OK) < 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.executable_real?;F;[[I" fname;T0;[[@ki;T;;f;0;[;{;IC;"|Returns true if the named file is executable by the real user and group id of this process. See access(3).;T;[o;H ;II" overload;F;J0;;f;K0;#I" executable_real?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"file_name;T0; @ ;[;I"Returns true if the named file is executable by the real user and group id of this process. See access(3). @overload executable_real?(file_name) @return [Boolean];T;0; @ ;@F;Ao;B;CT;Di;Ei ;Mi;!@V;"I"static VALUE rb_file_executable_real_p(VALUE obj, VALUE fname) { if (rb_access(fname, X_OK) < 0) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.file?;F;[[I" fname;T0;[[@ki&;T;;g;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;H ;II" overload;F;J0;;g;K0;#I"file?(file);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @);[;I"@return [Boolean];T;0; @);@F;Mi;N0;[[I" file;T0; @);[;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; @);@F;Ao;B;CT;Di;Ei#;Mi;!@V;"I"static VALUE rb_file_file_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (S_ISREG(st.st_mode)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.zero?;F;[[I" fname;T0;[[@ki:;T;;;0;[;{;IC;"nReturns true if the named file exists and has a zero size. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;;K0;#I"zero?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @H;[;I"@return [Boolean];T;0; @H;@F;Mi;N0;[[I"file_name;T0; @H;[;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; @H;@F;Ao;B;CT;Di0;Ei7;Mi;!@V;"I"static VALUE rb_file_zero_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (st.st_size == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.empty?;F;[[I" fname;T0;[[@ki:;T;;;0;[;{;IC;"nReturns true if the named file exists and has a zero size. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;;K0;#I"zero?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @g;[;I"@return [Boolean];T;0; @g;@F;Mi;N0;[[I"file_name;T0; @g;[;@c;0; @g;@F;Ao;B;CT;Di0;Ei7;Mi;!@V;"I"static VALUE rb_file_zero_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (st.st_size == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.size?;F;[[I" fname;T0;[[@kiN;T;;h;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;H ;II" overload;F;J0;;h;K0;#I"size?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;DiD;EiK;Mi;!@V;"I"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; ; F; ;;;;I"File.size;F;[[I" fname;T0;[[@ki;T;;;0;[;{;IC;"RReturns the size of file_name. _file_name_ can be an IO object. ;T;[o;H ;II" overload;F;J0;;;K0;#I"size(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;I"}Returns the size of file_name. _file_name_ can be an IO object. @overload size(file_name) @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;;;;I"File.owned?;F;[[I" fname;T0;[[@kic;T;;i;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;H ;II" overload;F;J0;;i;K0;#I"owned?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Ĵ;[;I"@return [Boolean];T;0; @Ĵ;@F;Mi;N0;[[I"file_name;T0; @Ĵ;[;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; @Ĵ;@F;Ao;B;CT;DiX;Ei`;Mi;!@V;"I"static VALUE rb_file_owned_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (st.st_uid == geteuid()) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.grpowned?;F;[[I" fname;T0;[[@ki;T;;j;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;H ;II" overload;F;J0;;j;K0;#I"grpowned?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Diw;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.pipe?;F;[[I" fname;T0;[[@ki;T;;k;0;[;{;IC;"]Returns true if the named file is a pipe. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;k;K0;#I"pipe?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"#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; ; F; ;;;;I"File.symlink?;F;[[I" fname;T0;[[@ki;T;;l;0;[;{;IC;"DReturns true if the named file is a symbolic link.;T;[o;H ;II" overload;F;J0;;l;K0;#I"symlink?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @!;[;I"@return [Boolean];T;0; @!;@F;Mi;N0;[[I"file_name;T0; @!;[;I"xReturns true if the named file is a symbolic link. @overload symlink?(file_name) @return [Boolean];T;0; @!;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.socket?;F;[[I" fname;T0;[[@ki;T;;m;0;[;{;IC;"_Returns true if the named file is a socket. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;m;K0;#I"socket?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @@;[;I"@return [Boolean];T;0; @@;@F;Mi;N0;[[I"file_name;T0; @@;[;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; @@;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.blockdev?;F;[[I" fname;T0;[[@ki";T;;n;0;[;{;IC;"eReturns true if the named file is a block device. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;n;K0;#I"blockdev?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @_;[;I"@return [Boolean];T;0; @_;@F;Mi;N0;[[I"file_name;T0; @_;[;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; @_;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.chardev?;F;[[I" fname;T0;[[@ki?;T;;o;0;[;{;IC;"iReturns true if the named file is a character device. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;o;K0;#I"chardev?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @~;[;I"@return [Boolean];T;0; @~;@F;Mi;N0;[[I"file_name;T0; @~;[;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; @~;@F;Ao;B;CT;Di7;Ei=;Mi;!@V;"I"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; ; F; ;;;;I"File.setuid?;F;[[I" fname;T0;[[@ki;T;;p;0;[;{;IC;"jReturns true if the named file has the setuid bit set. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;p;K0;#I"setuid?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.setgid?;F;[[I" fname;T0;[[@ki;T;;q;0;[;{;IC;"jReturns true if the named file has the setgid bit set. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;q;K0;#I"setgid?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.sticky?;F;[[I" fname;T0;[[@ki;T;;r;0;[;{;IC;"jReturns true if the named file has the sticky bit set. _file_name_ can be an IO object.;T;[o;H ;II" overload;F;J0;;r;K0;#I"sticky?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @۵;[;I"@return [Boolean];T;0; @۵;@F;Mi;N0;[[I"file_name;T0; @۵;[;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; @۵;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.identical?;F;[[I" fname1;T0[I" fname2;T0;[[@ki;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;H ;II" overload;F;J0;;u;K0;#I"identical?(file_1, file_2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" file_1;T0[I" file_2;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@V;"I"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; ; F; ;;;;I"File.stat;F;[[I" fname;T0;[[@ki};T;;3;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;H ;II" overload;F;J0;;3;K0;#I"stat(file_name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Dir;Eiy;!@V;"I"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; ; F; ;;;;I"File.lstat;F;[[I" fname;T0;[[@ki;T;: lstat;0;[;{;IC;"8Same 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;H ;II" overload;F;J0;;v;K0;#I"lstat(file_name);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I"file_name;T0; @7;[;I"VSame 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; @7;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;;;;I"File.ftype;F;[[I" fname;T0;[[@kiE;T;;];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;H ;II" overload;F;J0;;];K0;#I"ftype(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Q;[;I"@return [String];T;0; @Q;@F;Mi;N0;[[I"file_name;T0; @Q;[;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; @Q;@F;Ao;B;CT;Di6;EiB;!@V;"I"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; ; F; ;;;;I"File.atime;F;[[I" fname;T0;[[@ki_;T;;Z;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;H ;II" overload;F;J0;;Z;K0;#I"atime(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @p;[;I"@return [Time];T;0; @p;@F;Mi;N0;[[I"file_name;T0; @p;[;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; @p;@F;Ao;B;CT;DiS;Ei\;!@V;"I"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; ; F; ;;;;I"File.mtime;F;[[I" fname;T0;[[@ki;T;;[;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;H ;II" overload;F;J0;;[;K0;#I"mtime(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @;[;I"@return [Time];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;;;;I"File.ctime;F;[[I" fname;T0;[[@ki;T;;C;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;H ;II" overload;F;J0;;C;K0;#I"ctime(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @;[;I"@return [Time];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;;;;I"File.birthtime;F;[[I" fname;T0;[[@ki;T;;\;0;[;{;IC;"Returns the birth time for the named file. _file_name_ can be an IO object. File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003 If the platform doesn't have birthtime, raises NotImplementedError. ;T;[o;H ;II" overload;F;J0;;\;K0;#I"birthtime(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Ͷ;[;I"@return [Time];T;0; @Ͷ;@F;Mi;N0;[[I"file_name;T0; @Ͷ;[;I"Returns the birth time for the named file. _file_name_ can be an IO object. File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003 If the platform doesn't have birthtime, raises NotImplementedError. @overload birthtime(file_name) @return [Time];T;0; @Ͷ;@F;Ao;B;CT;Di;Ei;!@V;"I"static VALUE rb_file_s_birthtime(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_birthtime(&st); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.utime;F;[[@0;[[@ki ;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;H ;II" overload;F;J0;;w;K0;#I"(utime(atime, mtime, file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[ [I" atime;T0[I" mtime;T0[I"file_name;T0[I"...;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@V;"I"lstatic VALUE rb_file_s_utime(int argc, VALUE *argv) { return utime_internal_i(argc, argv, FALSE); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.chmod;F;[[@0;[[@kiT ;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;H ;II" overload;F;J0;;x;K0;#I"%chmod(mode_int, file_name, ... );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" mode_int;T0[I"file_name;T0[I"...;T0; @;[;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; @;@F;Ao;B;CT;DiG ;EiQ ;!@V;"I"static VALUE rb_file_s_chmod(int argc, VALUE *argv) { mode_t mode; apply2args(1); mode = NUM2MODET(*argv++); return apply2files(chmod_internal, argc, argv, &mode); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.chown;F;[[@0;[[@ki ;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;H ;II" overload;F;J0;;y;K0;#I"0chown(owner_int, group_int, file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @2;[;I"@return [Integer];T;0; @2;@F;Mi;N0;[ [I"owner_int;T0[I"group_int;T0[I"file_name;T0[I"...;T0; @2;[;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; @2;@F;Ao;B;CT;Di ;Ei ;!@V;"I"static VALUE rb_file_s_chown(int argc, VALUE *argv) { 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; ; F; ;;;;I"File.lchmod;F;[[@0;[[@ki ;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;H ;II" overload;F;J0;;z;K0;#I"%lchmod(mode_int, file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @V;[;I"@return [Integer];T;0; @V;@F;Mi;N0;[[I" mode_int;T0[I"file_name;T0[I"...;T0; @V;[;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; @V;@F;Ao;B;CT;Di ;Ei ;!@V;"I"static VALUE rb_file_s_lchmod(int argc, VALUE *argv) { mode_t mode; apply2args(1); mode = NUM2MODET(*argv++); return apply2files(lchmod_internal, argc, argv, &mode); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.lchown;F;[[@0;[[@ki ;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;H ;II" overload;F;J0;;{;K0;#I"/lchown(owner_int, group_int, file_name,..);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @x;[;I"@return [Integer];T;0; @x;@F;Mi;N0;[ [I"owner_int;T0[I"group_int;T0[I"file_name;T0[I"..;T0; @x;[;I"6Equivalent 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; @x;@F;Ao;B;CT;Di ;Ei ;!@V;"I"static VALUE rb_file_s_lchown(int argc, VALUE *argv) { 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; ; F; ;;;;I"File.lutime;F;[[@0;[[@ki ;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;H ;II" overload;F;J0;;|;K0;#I")lutime(atime, mtime, file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[ [I" atime;T0[I" mtime;T0[I"file_name;T0[I"...;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@V;"I"lstatic VALUE rb_file_s_lutime(int argc, VALUE *argv) { return utime_internal_i(argc, argv, TRUE); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.link;F;[[I" from;T0[I"to;T0;[[@ki ;T;: link;0;[;{;IC;"8Creates 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;H ;II" overload;F;J0;;};K0;#I"link(old_name, new_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" old_name;T0[I" new_name;T0; @;[;I"kCreates 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; @;@F;Ao;B;CT;Di ;Ei ;!@V;"I"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; ; F; ;;;;I"File.symlink;F;[[I" from;T0[I"to;T0;[[@ki8 ;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;H ;II" overload;F;J0;;~;K0;#I" symlink(old_name, new_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" old_name;T0[I" new_name;T0; @;[;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; @;@F;Ao;B;CT;Di, ;Ei5 ;!@V;"I"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; ; F; ;;;;I"File.readlink;F;[[I" path;T0;[[@kiU ;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;H ;II" overload;F;J0;;;K0;#I"readlink(link_name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"link_name;T0; @;[;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; @;@F;Ao;B;CT;DiJ ;EiQ ;!@V;"I"ystatic VALUE rb_file_s_readlink(VALUE klass, VALUE path) { return rb_readlink(path, rb_filesystem_encoding()); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.unlink;F;[[@0;[[@ki ;T;: unlink;0;[;{;IC;"{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. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete(file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[[I"file_name;T0[I"...;T0; @ o;H ;II" overload;F;J0;;;K0;#I"unlink(file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[[I"file_name;T0[I"...;T0; @ ;[;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; @ ;@F;Ao;B;CT;Di ;Ei ;!@V;"I"}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; ; F; ;;;;I"File.delete;F;[[@0;[[@ki ;T;;p;0;[;{;IC;"{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. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete(file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Q;[;I"@return [Integer];T;0; @Q;@F;Mi;N0;[[I"file_name;T0[I"...;T0; @Qo;H ;II" overload;F;J0;;;K0;#I"unlink(file_name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Q;[;I"@return [Integer];T;0; @Q;@F;Mi;N0;[[I"file_name;T0[I"...;T0; @Q;[;@M;0; @Q;@F;Ao;B;CT;Di ;Ei ;!@V;"I"}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; ; F; ;;;;I"File.rename;F;[[I" from;T0[I"to;T0;[[@ki ;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;H ;II" overload;F;J0;;;K0;#I"rename(old_name, new_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" old_name;T0[I" new_name;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@V;"I"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; ; F; ;;;;I"File.umask;F;[[@0;[[@ki ;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;H ;II" overload;F;J0;;;K0;#I" umask();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"umask(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" integer;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@V;"I"static VALUE rb_file_s_umask(int argc, VALUE *argv) { mode_t omask = 0; if (argc == 0) { omask = umask(0); umask(omask); } else if (argc == 1) { omask = umask(NUM2MODET(argv[0])); } else { rb_check_arity(argc, 0, 1); } return MODET2NUM(omask); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.truncate;F;[[I" path;T0[I"len;T0;[[@kix;T;;;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;H ;II" overload;F;J0;;;K0;#I"!truncate(file_name, integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @ϸ;[;I"@return [0];T;0; @ϸ;@F;Mi;N0;[[I"file_name;T0[I" integer;T0; @ϸ;[;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; @ϸ;@F;Ao;B;CT;Dii;Eiu;!@V;"I"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; ; F; ;;;;I"File.mkfifo;F;[[@0;[[@ki;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;H ;II" overload;F;J0;;;K0;#I"!mkfifo(file_name, mode=0666);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I"file_name;T0[I" mode;TI" 0666;T; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@V;"I"static VALUE rb_file_s_mkfifo(int argc, VALUE *argv) { 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; ; F; ;;;;I"File.expand_path;F;[[@0;[[@kiF;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;H ;II" overload;F;J0;;;K0;#I"+expand_path(file_name [, dir_string] );T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"file_name[, dir_string];T0; @;[;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; @;@F;Ao;B;CT;Di*;EiB;!@V;"I"VALUE rb_file_s_expand_path(int argc, const VALUE *argv) { rb_check_arity(argc, 1, 2); return rb_file_expand_path(argv[0], argc > 1 ? argv[1] : Qnil); };T;#I" VALUE;T;$To; ; F; ;;;;I"File.absolute_path;F;[[@0;[[@kia;T;;;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;H ;II" overload;F;J0;;;K0;#I"-absolute_path(file_name [, dir_string] );T;IC;";T;[;[;I";T;0; @,;@F;Mi;N0;[[I"file_name[, dir_string];T0; @,;[;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; @,;@F;Ao;B;CT;DiT;Ei];!@V;"I"VALUE rb_file_s_absolute_path(int argc, const VALUE *argv) { rb_check_arity(argc, 1, 2); return rb_file_absolute_path(argv[0], argc > 1 ? argv[1] : Qnil); };T;#I" VALUE;T;$To; ; F; ;;;;I"File.realpath;F;[[@0;[[@ki\;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;H ;II" overload;F;J0;;;K0;#I"&realpath(pathname [, dir_string]);T;IC;";T;[;[;I";T;0; @E;@F;Mi;N0;[[I"pathname[, dir_string];T0; @E;[;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; @E;@F;Ao;B;CT;DiO;EiY;!@V;"I"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; ; F; ;;;;I"File.realdirpath;F;[[@0;[[@kiq;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;H ;II" overload;F;J0;;;K0;#I")realdirpath(pathname [, dir_string]);T;IC;";T;[;[;I";T;0; @^;@F;Mi;N0;[[I"pathname[, dir_string];T0; @^;[;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; @^;@F;Ao;B;CT;Die;Ein;!@V;"I"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; ; F; ;;;;I"File.basename;F;[[@0;[[@ki;T;: basename;0;[;{;IC;"wReturns 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;H ;II" overload;F;J0;;;K0;#I"$basename(file_name [, suffix] );T;IC;";T;[;[;I";T;0; @w;@F;Mi;N0;[[I"file_name[, suffix];T0; @w;[;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; @w;@F;Ao;B;CT;Di;Ei;!@V;"I"static VALUE rb_file_s_basename(int argc, VALUE *argv) { 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); OBJ_INFECT(basename, fname); return basename; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.dirname;F;[[I" fname;T0;[[@ki);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" ;T;[o;H ;II" overload;F;J0;;;K0;#I"dirname(file_name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;I"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" @overload dirname(file_name);T;0; @;@F;Ao;B;CT;Di;Ei%;!@V;"I"dstatic VALUE rb_file_s_dirname(VALUE klass, VALUE fname) { return rb_file_dirname(fname); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.extname;F;[[I" fname;T0;[[@ki;T;: extname;0;[;{;IC;"ZReturns 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+. File.extname("test.rb") #=> ".rb" File.extname("a/b/d/test.rb") #=> ".rb" File.extname(".a/b/d/test.rb") #=> ".rb" File.extname("foo.") #=> "" File.extname("test") #=> "" File.extname(".profile") #=> "" File.extname(".profile.sh") #=> ".sh" ;T;[o;H ;II" overload;F;J0;;;K0;#I"extname(path);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" path;T0; @;[;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+. File.extname("test.rb") #=> ".rb" File.extname("a/b/d/test.rb") #=> ".rb" File.extname(".a/b/d/test.rb") #=> ".rb" File.extname("foo.") #=> "" File.extname("test") #=> "" File.extname(".profile") #=> "" File.extname(".profile.sh") #=> ".sh" @overload extname(path) @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@V;"I"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! */ OBJ_INFECT(extname, fname); return extname; };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.path;F;[[I" fname;T0;[[@ki;T;;;0;[;{;IC;"Returns the string representation of the path File.path("/dev/null") #=> "/dev/null" File.path(Pathname.new("/tmp")) #=> "/tmp" ;T;[o;H ;II" overload;F;J0;;;K0;#I"path(path);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ɹ;[;I"@return [String];T;0; @ɹ;@F;Mi;N0;[[I" path;T0; @ɹ;[;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; @ɹ;@F;Ao;B;CT;Di;Ei;!@V;"I"]static VALUE rb_file_s_path(VALUE klass, VALUE fname) { return rb_get_path(fname); };T;#I"static VALUE;T;$To;9;[[@ki;F;:Separator;;;;;;[;{;IC;"&separates directory parts in path ;T;[;[;I"&separates directory parts in path;T;0; @;@F;Ao;B;CT;Di;Ei;!@V;I"File::Separator;F;File::dirname and File::basename. File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"] ;T;[o;H ;II" overload;F;J0;;H;K0;#I"split(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"file_name;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@V;"I"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)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"File.join;F;[[I" args;T0;[[@ki>;T;;.;0;[;{;IC;"Returns a new string formed by joining the strings using "/". File.join("usr", "mail", "gumby") #=> "usr/mail/gumby" ;T;[o;H ;II" overload;F;J0;;.;K0;#I"join(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @;[;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; @;@F;Ao;B;CT;Di3;Ei;;!@V;"I"\static VALUE rb_file_s_join(VALUE klass, VALUE args) { return rb_file_join(args); };T;#I"static VALUE;T;$To;9;[[@ki[@ki;F;:ALT_SEPARATOR;;;;;;[;{;IC;",platform specific alternative separator ;T;[;[;I",platform specific alternative separator;T;0; @@;@F;Ao;B;CT;Di;Ei;!@V;I"File::ALT_SEPARATOR;F;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;H ;II" overload;F;J0;;v;K0;#I" lstat;T;IC;";T;[;[;I";T;0; @Y;@F;Mi;N0;[; @Y;[;I"dSame 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; @Y;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;,;;;I"File#atime;F;[;[[@kiw;T;;Z;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;H ;II" overload;F;J0;;Z;K0;#I" atime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @o;[;I"@return [Time];T;0; @o;@F;Mi;N0;[; @o;[;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; @o;@F;Ao;B;CT;Dil;Eit;!@V;"I"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; ; F; ;,;;;I"File#mtime;F;[;[[@ki;T;;[;0;[;{;IC;"uReturns the modification time for file. File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 ;T;[o;H ;II" overload;F;J0;;[;K0;#I" mtime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @;[;I"@return [Time];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;,;;;I"File#ctime;F;[;[[@ki;T;;C;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;H ;II" overload;F;J0;;C;K0;#I" ctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @;[;I"@return [Time];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;,;;;I"File#birthtime;F;[;[[@ki ;T;;\;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;H ;II" overload;F;J0;;\;K0;#I"birthtime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @;[;I"@return [Time];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@V;"I"static VALUE rb_file_birthtime(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_birthtime(&st); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File#size;F;[;[[@ki1 ;T;;;0;[;{;IC;"UReturns the size of file in bytes. File.new("testfile").size #=> 66 ;T;[o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ۺ;[;I"@return [Integer];T;0; @ۺ;@F;Mi;N0;[; @ۺ;[;I"{Returns the size of file in bytes. File.new("testfile").size #=> 66 @overload size @return [Integer];T;0; @ۺ;@F;Ao;B;CT;Di' ;Ei. ;!@V;"I" static VALUE rb_file_size(VALUE obj) { rb_io_t *fptr; struct stat st; GetOpenFile(obj, fptr); if (fptr->mode & FMODE_WRITABLE) { rb_io_flush_raw(obj, 0); } if (fstat(fptr->fd, &st) == -1) { rb_sys_fail_path(fptr->pathv); } return OFFT2NUM(st.st_size); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File#chmod;F;[[I" vmode;T0;[[@kil ;T;;x;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;H ;II" overload;F;J0;;x;K0;#I"chmod(mode_int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" mode_int;T0; @;[;I"TChanges 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; @;@F;Ao;B;CT;Di_ ;Eii ;!@V;"I"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; ; F; ;,;;;I"File#chown;F;[[I" owner;T0[I" group;T0;[[@ki ;T;;y;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;H ;II" overload;F;J0;;y;K0;#I"!chown(owner_int, group_int );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I"owner_int;T0[I"group_int;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@V;"I"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; ; F; ;,;;;I"File#truncate;F;[[I"len;T0;[[@ki;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;H ;II" overload;F;J0;;;K0;#I"truncate(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @8;[;I"@return [0];T;0; @8;@F;Mi;N0;[[I" integer;T0; @8;[;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; @8;@F;Ao;B;CT;Di;Ei;!@V;"I"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; ; F; ;,;;;I"File#flock;F;[[I"operation;T0;[[@ki;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;H ;II" overload;F;J0;;;K0;#I"flock(locking_constant);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;TI" false;T; @W;[;I"@return [0, false];T;0; @W;@F;Mi;N0;[[I"locking_constant;T0; @W;[;I"RLocks 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; @W;@F;Ao;B;CT;Di;Ei;!@V;"I"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@/o; ; F; ;,;;;I"File#path;F;[;[[@ki;T;;;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;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[;[;I";T;0; @w;@F;Mi;N0;[; @wo;H ;II" overload;F;J0;: to_path;K0;#I" to_path;T;IC;";T;[;[;I";T;0; @w;@F;Mi;N0;[; @w;[;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; @w;@F;Ao;B;CT;Di;Ei;!@V;"I"$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_obj_taint(rb_str_dup(fptr->pathv)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"File#to_path;F;[;[[@ki;T;;;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;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" to_path;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@V;"I"$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_obj_taint(rb_str_dup(fptr->pathv)); };T;#I"static VALUE;T;$T;&@V;'IC;[;&@V;(IC;[;&@V;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@kiH;F;;m;;0;;;[;{;IC;"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.;T;[;[;I"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. ;T;0; @V;@F;Ao;B;CT;Di ;Ei?;Mi;!@;I" File;F;1@;I"File::Constants;F;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@;;.[;[[@i2;F;:IO;;0;;;[;{;IC;" The 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";T;[;[;I" The 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" ;T;0; @;@F;Ao;B;CT;Di~2;Ei2;Mi;!@;I"IO;F;1@<@5@seed = rand_init(&rnd->mt, vseed); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#rand;F;[[@0;[[@\ij;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 +max+ 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;H ;II" overload;F;J0;;;K0;#I" rand;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"rand(max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I"max;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 +max+ 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];T;0; @;@F;Ao;B;CT;DiM;Eii;!@ӻ;"I"static VALUE random_rand(int argc, VALUE *argv, VALUE obj) { VALUE v = rand_random(argc, argv, obj, get_rnd(obj)); check_random_number(v, argv); return v; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#bytes;F;[[I"len;T0;[[@\ir;T;;J;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;H ;II" overload;F;J0;;J;K0;#I"bytes(size);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dij;Eiq;!@ӻ;"I"zstatic VALUE random_bytes(VALUE obj, VALUE len) { return genrand_bytes(get_rnd(obj), NUM2LONG(rb_to_int(len))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#seed;F;[;[[@\i;T;: seed;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;H ;II" overload;F;J0;;;K0;#I" seed;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @9;[;I"@return [Integer];T;0; @9;@F;Mi;N0;[; @9;[;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; @9;@F;Ao;B;CT;Di;Ei;!@ӻ;"I"Ostatic VALUE random_get_seed(VALUE obj) { return get_rnd(obj)->seed; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#initialize_copy;F;[[I" orig;T0;[[@\i;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @T;@F;Ao;B;CT;Di;Ei;!@ӻ;"I"?static VALUE random_copy(VALUE obj, VALUE orig) { rb_random_t *rnd1, *rnd2; struct MT *mt; if (!OBJ_INIT_COPY(obj, orig)) return obj; rnd1 = get_rnd(obj); rnd2 = get_rnd(orig); mt = &rnd1->mt; *rnd1 = *rnd2; mt->next = mt->state + numberof(mt->state) - mt->left + 1; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#marshal_dump;F;[;[[@\i;T;;e;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @d;@F;Ao;B;CT;Di;Ei;!@ӻ;"I"static VALUE random_dump(VALUE obj) { rb_random_t *rnd = get_rnd(obj); 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->seed); return dump; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#marshal_load;F;[[I" dump;T0;[[@\i ;T;;f;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @r;@F;Ao;B;CT;Di ;Ei ;!@ӻ;"I"static VALUE random_load(VALUE obj, VALUE dump) { rb_random_t *rnd = get_rnd(obj); 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->seed = rb_to_int(seed); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#state;F;[;[[@\i;T;: state;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@ӻ;"I"qstatic VALUE random_state(VALUE obj) { rb_random_t *rnd = get_rnd(obj); return mt_state(&rnd->mt); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#left;F;[;[[@\i;T;: left;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@ӻ;"I"sstatic VALUE random_left(VALUE obj) { rb_random_t *rnd = get_rnd(obj); return INT2FIX(rnd->mt.left); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Random#==;F;[[I" other;T0;[[@\i;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"==(prng2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@ӻ;"I"static VALUE random_equal(VALUE self, VALUE other) { rb_random_t *r1, *r2; if (rb_obj_class(self) != rb_obj_class(other)) return Qfalse; r1 = get_rnd(self); r2 = get_rnd(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->seed, r2->seed); };T;#I"static VALUE;T;$To;9;[[@\i;F;: DEFAULT;;;;;;[;{;IC;"QThe default Pseudorandom number generator. Used by class methods of Random. ;T;[;[;I"QThe default Pseudorandom number generator. Used by class methods of Random.;T;0; @;@F;Ao;B;CT;Di;Ei;!@ӻ;I"Random::DEFAULT;F; 268519324636777531569100071560086917274 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] [ rand(10), rand(1000) ] # => [4, 664] srand 1234 # => 1234 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] ;T;[o;H ;II" overload;F;J0;;;K0;#I"$srand(number = Random.new_seed);T;IC;";T;[;[;I";T;0; @ɼ;@F;Mi;N0;[[I" number;TI"Random.new_seed;T; @ɼ;[;@m;0; @ɼ;@F;Ao;B;CT;Di/;EiB;!@ӻ;"I"7static VALUE rb_f_srand(int argc, VALUE *argv, VALUE obj) { VALUE seed, old; rb_random_t *r = &default_rand; if (rb_check_arity(argc, 0, 1) == 0) { seed = random_seed(); } else { seed = rb_to_int(argv[0]); } old = r->seed; r->seed = rand_init(&r->mt, seed); return old; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Random.rand;F;[[@0;[[@\i;T;;;0;[;{;IC;"#Alias of Random::DEFAULT.rand. ;T;[o;H ;II" overload;F;J0;;;K0;#I" rand;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"rand(max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I"max;T0; @;[;I"nAlias of Random::DEFAULT.rand. @overload rand @return [Float] @overload rand(max) @return [Numeric];T;0; @;@F;Ao;B;CT;Di;Ei;!@ӻ;"I"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; ; F; ;;;;I"Random.bytes;F;[[I"len;T0;[[@\i;T;;J;0;[;{;IC;"eReturns a random binary string. The argument +size+ specifies the length of the returned string. ;T;[o;H ;II" overload;F;J0;;J;K0;#I"bytes(size);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@ӻ;"I"static VALUE random_s_bytes(VALUE obj, VALUE len) { rb_random_t *rnd = rand_start(&default_rand); return genrand_bytes(rnd, NUM2LONG(rb_to_int(len))); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Random.new_seed;F;[;[[@\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;H ;II" overload;F;J0;;;K0;#I" new_seed;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @,;[;I"@return [Integer];T;0; @,;@F;Mi;N0;[; @,;[;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;Ao;B;CT;Di;Ei;!@ӻ;"I"static VALUE random_seed(void) { VALUE v; uint32_t buf[DEFAULT_SEED_CNT+1]; fill_random_seed(buf, DEFAULT_SEED_CNT); v = make_seed_value(buf, DEFAULT_SEED_CNT); explicit_bzero(buf, DEFAULT_SEED_LEN); return v; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Random.urandom;F;[[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;H ;II" overload;F;J0;;;K0;#I"urandom(size);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @G;[;I"@return [String];T;0; @G;@F;Mi;N0;[[I" size;T0; @G;[;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; @G;@F;Ao;B;CT;Di;Ei;!@ӻ;"I"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; ; F; ;,;;;I"$Random::Formatter#random_number;F;[[@0;[[@\i;T;:random_number;0;[;{;IC;"NGenerates formatted random number from raw random bytes. See Random#rand. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"random_number;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @h;[;I"@return [Float];T;0; @h;@F;Mi;N0;[; @ho;H ;II" overload;F;J0;;;K0;#I"random_number(max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @h;[;I"@return [Numeric];T;0; @h;@F;Mi;N0;[[I"max;T0; @ho;H ;II" overload;F;J0;;;K0;#I" rand;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @h;[;I"@return [Float];T;0; @h;@F;Mi;N0;[; @ho;H ;II" overload;F;J0;;;K0;#I"rand(max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @h;[;I"@return [Numeric];T;0; @h;@F;Mi;N0;[[I"max;T0; @h;[;I"Generates formatted random number from raw random bytes. See Random#rand. @overload random_number @return [Float] @overload random_number(max) @return [Numeric] @overload rand @return [Float] @overload rand(max) @return [Numeric];T;0; @h;@F;Ao;B;CT;Di;Ei;!@f;"I" 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; ; F; ;,;;;I"Random::Formatter#rand;F;[[@0;[[@\i;T;;;0;[;{;IC;"NGenerates formatted random number from raw random bytes. See Random#rand. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"random_number;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"random_number(max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I"max;T0; @o;H ;II" overload;F;J0;;;K0;#I" rand;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"rand(max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I"max;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@f;"I" 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; ; F; ;,;;;I""Random::Formatter#test_select;F;[;[[I"-ext/-test-/win32/fd_setsize/fd_setsize.c;Ti ;T;:test_select;0;[;{;IC;" ;T;[;[;I";F;0; @;@F;N0;!@f;"I"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; ; T; ;;;;I""Random::Formatter.test_select;F;@;@;T;;;0;@;{;IC;" ;T;[;[;@;0; @;Mi;!@f;"@;#@;$To; ; F; ;,;;;I"!Random::Formatter#test_fdset;F;[;[[@i$;T;:test_fdset;0;[;{;IC;" ;T;[;[;I";F;0; @ ;@F;N0;!@f;"I"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; ; T; ;;;;I"!Random::Formatter.test_fdset;F;@ ;@ ;T;;;0;@;{;IC;" ;T;[;[;@;0; @;Mi;!@f;"@;#@;$To;9;[[@7i:;F;:FOREGROUND_MASK;;;;;;[;{;IC;" ;T;[;[;@;0; @;!@f;I"'Random::Formatter::FOREGROUND_MASK;F;;F;:FOREGROUND_INTENSITY;;;;;;[;{;IC;" ;T;[;[;@;0; @D;!@f;I",Random::Formatter::FOREGROUND_INTENSITY;F; (1+2i) ;T;[o;H ;II" overload;F;J0;;;K0;#I"rect(real[, imag]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"real[, imag];T0; @o;H ;II" overload;F;J0;;;K0;#I"rectangular(real[, imag]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Complex.rect;F;[[@0;[[@i;T;;;0;[;{;IC;"qReturns a complex object which denotes the given rectangular form. Complex.rectangular(1, 2) #=> (1+2i) ;T;[o;H ;II" overload;F;J0;;;K0;#I"rect(real[, imag]);T;IC;";T;[;[;I";T;0; @о;@F;Mi;N0;[[I"real[, imag];T0; @оo;H ;II" overload;F;J0;;;K0;#I"rectangular(real[, imag]);T;IC;";T;[;[;I";T;0; @о;@F;Mi;N0;[[I"real[, imag];T0; @о;[;@̾;0; @о;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Complex.polar;F;[[@0;[[@if;T;;;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;H ;II" overload;F;J0;;;K0;#I"polar(abs[, arg]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di[;Eic;!@;"I"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); if (canonicalization) return abs; return nucomp_s_new_internal(klass, abs, ZERO); default: nucomp_real_check(abs); nucomp_real_check(arg); break; } return f_complex_polar(klass, abs, arg); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#real;F;[;[[@i;T;;;0;[;{;IC;"XReturns the real part. Complex(7).real #=> 7 Complex(9, -4).real #=> 9 ;T;[o;H ;II" overload;F;J0;;;K0;#I" real;T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[; @ ;[;I"iReturns the real part. Complex(7).real #=> 7 Complex(9, -4).real #=> 9 @overload real;T;0; @ ;@F;Ao;B;CT;Dix;Ei~;!@;"I"TVALUE rb_complex_real(VALUE self) { get_dat1(self); return dat->real; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Complex#imaginary;F;[;[[@i;T;;;0;[;{;IC;"hReturns the imaginary part. Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4 ;T;[o;H ;II" overload;F;J0;;;K0;#I" imag;T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[; @!o;H ;II" overload;F;J0;;;K0;#I"imaginary;T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[; @!;[;I"Returns the imaginary part. Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4 @overload imag @overload imaginary;T;0; @!;@F;Ao;B;CT;Di;Ei;!@;"I"TVALUE rb_complex_imag(VALUE self) { get_dat1(self); return dat->imag; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Complex#imag;F;[;[[@i;T;;;0;[;{;IC;"hReturns the imaginary part. Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4 ;T;[o;H ;II" overload;F;J0;;;K0;#I" imag;T;IC;";T;[;[;I";T;0; @?;@F;Mi;N0;[; @?o;H ;II" overload;F;J0;;;K0;#I"imaginary;T;IC;";T;[;[;I";T;0; @?;@F;Mi;N0;[; @?;[;@;;0; @?;@F;Ao;B;CT;Di;Ei;!@;"I"TVALUE rb_complex_imag(VALUE self) { get_dat1(self); return dat->imag; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Complex#-@;F;[;[[@i;T;;;;0;[;{;IC;"CReturns negation of the value. -Complex(1, 2) #=> (-1-2i) ;T;[o;H ;II" overload;F;J0;;<;K0;#I" -cmp;T;IC;";T;[;[;I";T;0; @\;@F;Mi;N0;[; @\;[;I"TReturns negation of the value. -Complex(1, 2) #=> (-1-2i) @overload -cmp;T;0; @\;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#+;F;[[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;H ;II" overload;F;J0;;(;K0;#I"+(numeric);T;IC;";T;[;[;I";T;0; @r;@F;Mi;N0;[[I" numeric;T0; @r;[;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; @r;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#-;F;[[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;H ;II" overload;F;J0;;<;K0;#I"-(numeric);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" numeric;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#*;F;[[I" other;T0;[[@i;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;H ;II" overload;F;J0;;);K0;#I"*(numeric);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#/;F;[[I" other;T0;[[@ie;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;H ;II" overload;F;J0;;;K0;#I"/(numeric);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" numeric;T0; @o;H ;II" overload;F;J0;;;K0;#I"quo(numeric);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiX;Eib;!@;"I"gVALUE rb_complex_div(VALUE self, VALUE other) { return f_divide(self, other, f_quo, id_quo); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Complex#quo;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;$To; ; F; ;,;;;I"Complex#fdiv;F;[[I" other;T0;[[@iu;T;;;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;H ;II" overload;F;J0;;;K0;#I"fdiv(numeric);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dim;Eir;!@;"I"mstatic VALUE nucomp_fdiv(VALUE self, VALUE other) { return f_divide(self, other, f_fdiv, id_fdiv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#**;F;[[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;H ;II" overload;F;J0;;;K0;#I"**(numeric);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"H 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_TYPE_P(other, T_BIGNUM)) 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; ; F; ;,;;;I"Complex#==;F;[[I" other;T0;[[@i;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"==(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @!;[;I"@return [Boolean];T;0; @!;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"static VALUE nucomp_eqeq_p(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) { get_dat2(self, other); return f_boolcast(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 f_boolcast(f_eqeq_p(dat->real, other) && f_zero_p(dat->imag)); } return f_boolcast(f_eqeq_p(other, self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#coerce;F;[[I" other;T0;[[@i;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @@;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE nucomp_coerce(VALUE self, VALUE other) { if (k_numeric_p(other) && f_real_p(other)) return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self); if (RB_TYPE_P(other, T_COMPLEX)) return rb_assoc_new(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; ; F; ;,;;;I"Complex#abs;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @Po;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @P;[;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; @P;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"Complex#magnitude;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[;[;I";T;0; @n;@F;Mi;N0;[; @no;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[;[;I";T;0; @n;@F;Mi;N0;[; @n;[;@j;0; @n;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"Complex#abs2;F;[;[[@i2;T;;;0;[;{;IC;"rReturns square of the absolute value. Complex(-1).abs2 #=> 1 Complex(3.0, -4.0).abs2 #=> 25.0 ;T;[o;H ;II" overload;F;J0;;;K0;#I" abs2;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"~Returns square of the absolute value. Complex(-1).abs2 #=> 1 Complex(3.0, -4.0).abs2 #=> 25.0 @overload abs2;T;0; @;@F;Ao;B;CT;Di);Ei/;!@;"I"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; ; F; ;,;;;I"Complex#arg;F;[;[[@iD;T;;;0;[;{;IC;"kReturns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966 ;T;[o;H ;II" overload;F;J0;;;K0;#I"arg;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" angle;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" phase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di:;EiD;!@;"I"mVALUE rb_complex_arg(VALUE self) { get_dat1(self); return rb_math_atan2(dat->imag, dat->real); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Complex#angle;F;[;[[@iD;T;;;0;[;{;IC;"kReturns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966 ;T;[o;H ;II" overload;F;J0;;;K0;#I"arg;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" angle;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" phase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di:;EiD;!@;"I"mVALUE rb_complex_arg(VALUE self) { get_dat1(self); return rb_math_atan2(dat->imag, dat->real); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Complex#phase;F;[;[[@iD;T;;;0;[;{;IC;"kReturns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966 ;T;[o;H ;II" overload;F;J0;;;K0;#I"arg;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @ ;[;I"@return [Float];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" angle;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @ ;[;I"@return [Float];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" phase;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @ ;[;I"@return [Float];T;0; @ ;@F;Mi;N0;[; @ ;[;@;0; @ ;@F;Ao;B;CT;Di:;EiD;!@;"I"mVALUE rb_complex_arg(VALUE self) { get_dat1(self); return rb_math_atan2(dat->imag, dat->real); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Complex#rectangular;F;[;[[@iT;T;;;0;[;{;IC;"VReturns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2] ;T;[o;H ;II" overload;F;J0;;;K0;#I" rect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @>;[;I"@return [Array];T;0; @>;@F;Mi;N0;[; @>o;H ;II" overload;F;J0;;;K0;#I"rectangular;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @>;[;I"@return [Array];T;0; @>;@F;Mi;N0;[; @>;[;I"Returns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2] @overload rect @return [Array] @overload rectangular @return [Array];T;0; @>;@F;Ao;B;CT;DiK;EiS;!@;"I"pstatic VALUE nucomp_rect(VALUE self) { get_dat1(self); return rb_assoc_new(dat->real, dat->imag); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#rect;F;[;[[@iT;T;;;0;[;{;IC;"VReturns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2] ;T;[o;H ;II" overload;F;J0;;;K0;#I" rect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @f;[;I"@return [Array];T;0; @f;@F;Mi;N0;[; @fo;H ;II" overload;F;J0;;;K0;#I"rectangular;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @f;[;I"@return [Array];T;0; @f;@F;Mi;N0;[; @f;[;@b;0; @f;@F;Ao;B;CT;DiK;EiS;!@;"I"pstatic VALUE nucomp_rect(VALUE self) { get_dat1(self); return rb_assoc_new(dat->real, dat->imag); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#polar;F;[;[[@ic;T;;;0;[;{;IC;"nReturns an array; [cmp.abs, cmp.arg]. Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904] ;T;[o;H ;II" overload;F;J0;;;K0;#I" polar;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Returns an array; [cmp.abs, cmp.arg]. Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904] @overload polar @return [Array];T;0; @;@F;Ao;B;CT;Di[;Eia;!@;"I"astatic VALUE nucomp_polar(VALUE self) { return rb_assoc_new(f_abs(self), f_arg(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#conjugate;F;[;[[@ir;T;;;0;[;{;IC;"KReturns the complex conjugate. Complex(1, 2).conjugate #=> (1-2i) ;T;[o;H ;II" overload;F;J0;;;K0;#I" conj;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"conjugate;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"pReturns the complex conjugate. Complex(1, 2).conjugate #=> (1-2i) @overload conj @overload conjugate;T;0; @;@F;Ao;B;CT;Dii;Eio;!@;"I"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; ; F; ;,;;;I"Complex#conj;F;[;[[@ir;T;;;0;[;{;IC;"KReturns the complex conjugate. Complex(1, 2).conjugate #=> (1-2i) ;T;[o;H ;II" overload;F;J0;;;K0;#I" conj;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"conjugate;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Dii;Eio;!@;"I"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; ; F; ;,;;;I"Complex#real?;F;[;[[@i;T;;;0;[;{;IC;"Returns false.;T;[o;H ;II" overload;F;J0;;;K0;#I" real?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" false;T; @;[;I"@return [false];T;0; @;@F;Mi;N0;[; @;[;I"7Returns false. @overload real? @return [false];T;0; @;@F;Ao;B;CT;Diy;Ei};Mi;!@;"I"Astatic VALUE nucomp_false(VALUE self) { return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#numerator;F;[;[[@i;T;;;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;H ;II" overload;F;J0;;;K0;#I"numerator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"4static VALUE nucomp_numerator(VALUE self) { VALUE cd; get_dat1(self); cd = f_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; ; F; ;,;;;I"Complex#denominator;F;[;[[@i;T;;;0;[;{;IC;"WReturns the denominator (lcm of both denominator - real and imag). See numerator. ;T;[o;H ;II" overload;F;J0;;;K0;#I"denominator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"~Returns the denominator (lcm of both denominator - real and imag). See numerator. @overload denominator @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#hash;F;[;[[@i;T;;U;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @4;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE nucomp_hash(VALUE self) { st_index_t v, h[2]; VALUE n; get_dat1(self); n = rb_hash(dat->real); h[0] = NUM2LONG(n); n = rb_hash(dat->imag); h[1] = NUM2LONG(n); v = rb_memhash(h, sizeof(h)); return ST2FIX(v); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#eql?;F;[[I" other;T0;[[@i;T;;R;0;[;{;IC;" :nodoc:;T;[o;L ;II" return;F;J@;0;K[@; @B;[;I" :nodoc:;T;0; @B;@F;Ao;B;CT;Di;Ei;Mi;!@;"I")static VALUE nucomp_eql_p(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) { get_dat2(self, other); return f_boolcast((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; ; F; ;,;;;I"Complex#to_s;F;[;[[@i;T;;h;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;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @U;[;I"@return [String];T;0; @U;@F;Mi;N0;[; @U;[;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; @U;@F;Ao;B;CT;Di;Ei;!@;"I"Sstatic VALUE nucomp_to_s(VALUE self) { return f_format(self, rb_String); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#inspect;F;[;[[@i;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @p;[;I"@return [String];T;0; @p;@F;Mi;N0;[; @p;[;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; @p;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"Complex#finite?;F;[;[[@i,;T;;;0;[;{;IC;"kReturns +true+ if +cmp+'s real and imaginary parts are both finite numbers, otherwise returns +false+.;T;[o;H ;II" overload;F;J0;;;K0;#I" finite?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"Returns +true+ if +cmp+'s real and imaginary parts are both finite numbers, otherwise returns +false+. @overload finite? @return [Boolean];T;0; @;@F;Ao;B;CT;Di%;Ei*;Mi;!@;"I"static VALUE rb_complex_finite_p(VALUE self) { get_dat1(self); if (f_finite_p(dat->real) && f_finite_p(dat->imag)) { return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#infinite?;F;[;[[@iC;T;;;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;H ;II" overload;F;J0;;;K0;#I"infinite?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;TI"1;T; @;[;I"@return [nil, 1];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di7;EiA;Mi;!@;"I"static VALUE rb_complex_infinite_p(VALUE self) { get_dat1(self); if (NIL_P(f_infinite_p(dat->real)) && NIL_P(f_infinite_p(dat->imag))) { return Qnil; } return ONE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Complex#marshal_dump;F;[;[[@ic;T;;e;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Dib;Eib;!@;"I"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; ; F; ;,;;;I"%Complex::compatible#marshal_load;F;[[I"a;T0;[[@io;T;;f;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Din;Ein;!@;"I"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;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"Complex::compatible;F;1@ 1 Complex(1, 0.0).to_i # RangeError Complex(1, 2).to_i # RangeError ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#to_f;F;[;[[@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;H ;II" overload;F;J0;;>;K0;#I" to_f;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @ ;[;I"@return [Float];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#to_r;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" to_r;T;IC;";T;[;[;I";T;0; @';@F;Mi;N0;[; @';[;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; @';@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#rationalize;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"rationalize([eps]);T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[[I" [eps];T0; @=;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Complex#to_c;F;[;[[@i;T;;&;0;[;{;IC;"ZReturns self. Complex(2).to_c #=> (2+0i) Complex(-8, 6).to_c #=> (-8+6i) ;T;[o;H ;II" overload;F;J0;;&;K0;#I" to_c;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @V;[;I"@return [self];T;0; @V;@F;Mi;N0;[; @V;[;I"|Returns self. Complex(2).to_c #=> (2+0i) Complex(-8, 6).to_c #=> (-8+6i) @overload to_c @return [self];T;0; @V;@F;Ao;B;CT;Di ;Ei;!@;"I">static VALUE nucomp_to_c(VALUE self) { return self; };T;#I"static VALUE;T;$To;9;[[@i ;F;:I;;;;;;[;{;IC;"The imaginary unit. ;T;[;[;I"The imaginary unit. ;T;0; @q;@F;Ao;B;CT;Di ;Ei ;!@;I"Complex::I;F; (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"nA 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. 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;Ao;B;CT;Dio;Ei;!@;I" Complex;F;1@mo; ;IC;[o; ; F; ;,;;;I"NilClass#to_c;F;[;[[@i!;T;;&;0;[;{;IC;"Returns zero as a complex. ;T;[o;H ;II" overload;F;J0;;&;K0;#I" to_c;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"0Returns zero as a complex. @overload to_c;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Wstatic VALUE nilclass_to_c(VALUE self) { return rb_complex_new1(INT2FIX(0)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#to_r;F;[;[[@ i=;T;;;0;[;{;IC;" Returns zero as a rational. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_r;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"1Returns zero as a rational. @overload to_r;T;0; @;@F;Ao;B;CT;Di7;Ei:;!@;"I"Xstatic VALUE nilclass_to_r(VALUE self) { return rb_rational_new1(INT2FIX(0)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#rationalize;F;[[@0;[[@ iJ;T;;;0;[;{;IC;"PReturns zero as a rational. The optional argument +eps+ is always ignored. ;T;[o;H ;II" overload;F;J0;;;K0;#I"rationalize([eps]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" [eps];T0; @;[;I"oReturns zero as a rational. The optional argument +eps+ is always ignored. @overload rationalize([eps]);T;0; @;@F;Ao;B;CT;DiC;EiG;!@;"I"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;$To; ; F; ;,;;;I"NilClass#to_i;F;[;[[@iy;T;;=;0;[;{;IC;".Always returns zero. nil.to_i #=> 0 ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[; @;[;I"MAlways returns zero. nil.to_i #=> 0 @overload to_i @return [0];T;0; @;@F;Ao;B;CT;Dio;Eiu;!@;"I"@static VALUE nil_to_i(VALUE obj) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#to_f;F;[;[[@i;T;;>;0;[;{;IC;"0Always returns zero. nil.to_f #=> 0.0 ;T;[o;H ;II" overload;F;J0;;>;K0;#I" to_f;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0.0;T; @;[;I"@return [0.0];T;0; @;@F;Mi;N0;[; @;[;I"QAlways returns zero. nil.to_f #=> 0.0 @overload to_f @return [0.0];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Bstatic VALUE nil_to_f(VALUE obj) { return DBL2NUM(0.0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#to_s;F;[;[[@i;T;;h;0;[;{;IC;"%Always returns the empty string. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[; @ ;[;I"6Always returns the empty string. @overload to_s;T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"Nstatic VALUE nil_to_s(VALUE obj) { return rb_usascii_str_new(0, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#to_a;F;[;[[@i;T;;;0;[;{;IC;"\call-seq: nil.to_a -> [] 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; @!;@F;Ao;B;CT;Di;Ei;!@;"I"Dstatic VALUE nil_to_a(VALUE obj) { return rb_ary_new2(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#to_h;F;[;[[@i;T;;;0;[;{;IC;"[call-seq: nil.to_h -> {} 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; @/;@F;Ao;B;CT;Di;Ei;!@;"I"Cstatic VALUE nil_to_h(VALUE obj) { return rb_hash_new(); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#inspect;F;[;[[@i;T;;i;0;[;{;IC;"%Always returns the string "nil". ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[; @=;[;I"9Always returns the string "nil". @overload inspect;T;0; @=;@F;Ao;B;CT;Di;Ei;!@;"I"Sstatic VALUE nil_inspect(VALUE obj) { return rb_usascii_str_new2("nil"); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#=~;F;[[I" obj2;T0;[[@i;T;;P;0;[;{;IC;"2Dummy pattern matching -- always returns nil. ;T;[o;H ;II" overload;F;J0;;P;K0;#I"=~(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @S;[;I"@return [nil];T;0; @S;@F;Mi;N0;[[I" other;T0; @S;[;I"XDummy pattern matching -- always returns nil. @overload =~(other) @return [nil];T;0; @S;@F;Ao;B;CT;Di;Ei;!@;"I"Hstatic VALUE nil_match(VALUE obj1, VALUE obj2) { return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#&;F;[[I" obj2;T0;[[@iE;T;;;0;[;{;IC;"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. ;T;[o;H ;II" overload;F;J0;;;K0;#I" &(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" false;T; @r;[;I"@return [false];T;0; @r;@F;Mi;N0;[[I"obj;T0; @ro;H ;II" overload;F;J0;;;K0;#I" &(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" false;T; @r;[;I"@return [false];T;0; @r;@F;Mi;N0;[[I"obj;T0; @r;[;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; @r;@F;Ao;B;CT;Di;;EiC;!@;"I"Istatic VALUE false_and(VALUE obj, VALUE obj2) { return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#|;F;[[I" obj2;T0;[[@iU;T;;;0;[;{;IC;"zOr---Returns false if obj is nil or false; true otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I" |(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;;K0;#I" |(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"Or---Returns false if obj is nil or false; true otherwise. @overload |(obj) @return [Boolean] @overload |(obj) @return [Boolean];T;0; @;@F;Ao;B;CT;DiL;EiS;!@;"I"Zstatic VALUE false_or(VALUE obj, VALUE obj2) { return RTEST(obj2)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#^;F;[[I" obj2;T0;[[@ih;T;;;0;[;{;IC;"Exclusive Or---If obj is nil or false, returns false; otherwise, returns true. ;T;[o;H ;II" overload;F;J0;;;K0;#I" ^(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;;K0;#I" ^(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"Exclusive Or---If obj is nil or false, returns false; otherwise, returns true. @overload ^(obj) @return [Boolean] @overload ^(obj) @return [Boolean];T;0; @;@F;Ao;B;CT;Di];Eif;!@;"I"[static VALUE false_xor(VALUE obj, VALUE obj2) { return RTEST(obj2)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NilClass#===;F;[[I" obj2;T0;[[@i;T;;O;0;[;{;IC;"Case Equality -- For class Object, effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in +case+ statements. ;T;[o;H ;II" overload;F;J0;;O;K0;#I"===(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;@;0; @;@F;Ao;B;CT;Dix;Ei;!@;"I"VALUE rb_equal(VALUE obj1, VALUE obj2) { VALUE result; if (obj1 == obj2) return Qtrue; result = rb_equal_opt(obj1, obj2); if (result == Qundef) { result = rb_funcall(obj1, id_eq, 1, obj2); } if (RTEST(result)) return Qtrue; return Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"NilClass#nil?;F;[;[[@iu;T;;G;0;[;{;IC;"POnly the object nil responds true to nil?.;T;[o;H ;II" overload;F;J0;;G;K0;#I" nil?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @;[;I"@return [true];T;0; @;@F;Mi;N0;[; @;[;I"rOnly the object nil responds true to nil?. @overload nil? @return [true];T;0; @;@F;Ao;B;CT;Din;Eir;Mi;!@;"I":static VALUE rb_true(VALUE obj) { return Qtrue; };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ii[@ie;T;: NilClass;;0;;;[;{;IC;"8The class of the singleton object nil.;T;[;[;I"; The class of the singleton object nil. ;T;0; @;@F;Ao;B;CT;Dii;Eik;Mi;!@;I" NilClass;F;1@<@@to; ;IC;[o; ; F; ;,;;;I"Encoding#to_s;F;[;[[@li;T;;h;0;[;{;IC;"OReturns the name of the encoding. Encoding::UTF_8.name #=> "UTF-8" ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[; @I;[;I"Returns the name of the encoding. Encoding::UTF_8.name #=> "UTF-8" @overload name @return [String] @overload to_s @return [String];T;0; @I;@F;Ao;B;CT;Di;Ei;!@G;"I"qstatic VALUE enc_name(VALUE self) { return rb_fstring_cstr(rb_enc_name((rb_encoding*)DATA_PTR(self))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Encoding#inspect;F;[;[[@lim;T;;i;0;[;{;IC;"Returns a string which represents the encoding for programmers. Encoding::UTF_8.inspect #=> "#" Encoding::ISO_2022_JP.inspect #=> "#" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @q;[;I"@return [String];T;0; @q;@F;Mi;N0;[; @q;[;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; @q;@F;Ao;B;CT;Did;Eik;!@G;"I"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)" : ""), enc_autoload_p(enc) ? " (autoload)" : ""); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Encoding#name;F;[;[[@li;T;;>;0;[;{;IC;"OReturns the name of the encoding. Encoding::UTF_8.name #=> "UTF-8" ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;@m;0; @;@F;Ao;B;CT;Di;Ei;!@G;"I"qstatic VALUE enc_name(VALUE self) { return rb_fstring_cstr(rb_enc_name((rb_encoding*)DATA_PTR(self))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Encoding#names;F;[;[[@li;T;;;0;[;{;IC;"Returns the list of name and aliases of the encoding. Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" names;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Returns the list of name and aliases of the encoding. Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J"] @overload names @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@G;"I"static VALUE enc_names(VALUE self) { VALUE args[2]; args[0] = (VALUE)rb_to_encoding_index(self); args[1] = rb_ary_new2(0); st_foreach(enc_table.names, enc_names_i, (st_data_t)args); return args[1]; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Encoding#dummy?;F;[;[[@li;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;H ;II" overload;F;J0;;;K0;#I" dummy?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@G;"I"istatic VALUE enc_dummy_p(VALUE enc) { return ENC_DUMMY_P(must_encoding(enc)) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Encoding#ascii_compatible?;F;[;[[@li;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;H ;II" overload;F;J0;;;K0;#I"ascii_compatible?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@G;"I"{static VALUE enc_ascii_compatible_p(VALUE enc) { return rb_enc_asciicompat(must_encoding(enc)) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Encoding#replicate;F;[[I" name;T0;[[@li;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;H ;II" overload;F;J0;;;K0;#I"replicate(name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @;[;I"@return [Encoding];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@G;"I"static VALUE enc_replicate(VALUE encoding, VALUE name) { return rb_enc_from_encoding_index( rb_enc_replicate(StringValueCStr(name), rb_to_encoding(encoding))); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Encoding.list;F;[;[[@li;T;;%;0;[;{;IC;"KReturns the list of loaded encodings. Encoding.list #=> [#, #, #] Encoding.find("US-ASCII") #=> # Encoding.list #=> [#, #, #, #] ;T;[o;H ;II" overload;F;J0;;%;K0;#I" list;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @#;[;I"@return [Array];T;0; @#;@F;Mi;N0;[; @#;[;I"oReturns the list of loaded encodings. Encoding.list #=> [#, #, #] Encoding.find("US-ASCII") #=> # Encoding.list #=> [#, #, #, #] @overload list @return [Array];T;0; @#;@F;Ao;B;CT;Di;Ei;!@G;"I"static VALUE enc_list(VALUE klass) { VALUE ary = rb_ary_new2(0); rb_ary_replace(ary, rb_encoding_list); return ary; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Encoding.name_list;F;[;[[@li;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;H ;II" overload;F;J0;;;K0;#I"name_list;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @>;[;I"@return [Array];T;0; @>;@F;Mi;N0;[; @>;[;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;Ao;B;CT;Di;Ei;!@G;"I"static VALUE rb_enc_name_list(VALUE klass) { VALUE ary = rb_ary_new2(enc_table.names->num_entries); st_foreach(enc_table.names, rb_enc_name_list_i, (st_data_t)ary); return ary; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Encoding.aliases;F;[;[[@li;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-1986"=>"US-ASCII", "SJIS"=>"Shift_JIS", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"} ;T;[o;H ;II" overload;F;J0;;;K0;#I" aliases;T;IC;";T;[;[;I";T;0; @Y;@F;Mi;N0;[; @Y;[;I" Returns the hash of available encoding alias and original encoding name. Encoding.aliases #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1986"=>"US-ASCII", "SJIS"=>"Shift_JIS", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"} @overload aliases;T;0; @Y;@F;Ao;B;CT;Di;Ei;!@G;"I"static VALUE rb_enc_aliases(VALUE klass) { VALUE aliases[2]; aliases[0] = rb_hash_new(); aliases[1] = rb_ary_new(); st_foreach(enc_table.names, rb_enc_aliases_enc_i, (st_data_t)aliases); return aliases[0]; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Encoding.find;F;[[I"enc;T0;[[@li;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;H ;II" overload;F;J0;;;K0;#I"find(string);T;IC;";T;[;[;I";T;0; @o;@F;Mi;N0;[[I" string;T0; @o;[;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; @o;@F;Ao;B;CT;Di;Ei;!@G;"I"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; ; F; ;;;;I"Encoding.compatible?;F;[[I" str1;T0[I" str2;T0;[[@li;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;H ;II" overload;F;J0;;;K0;#I"compatible?(obj1, obj2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@G;"I"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; ; F; ;,;;;I"Encoding#_dump;F;[[@0;[[@li;T;;d;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@G;"I"|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; ; F; ;;;;I"Encoding._load;F;[[I"str;T0;[[@li;T;: _load;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@G;"I"Fstatic VALUE enc_load(VALUE klass, VALUE str) { return str; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Encoding.default_external;F;[;[[@li;T;:default_external;0;[;{;IC;"7Returns 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. The default external encoding is initialized by the locale or -E option. ;T;[o;H ;II" overload;F;J0;;;K0;#I"default_external;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"TReturns 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. The default external encoding is initialized by the locale or -E option. @overload default_external;T;0; @;@F;Ao;B;CT;Di;Ei;!@G;"I"]static VALUE get_default_external(VALUE klass) { return rb_enc_default_external(); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Encoding.default_external=;F;[[I" encoding;T0;[[@li;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;H ;II" overload;F;J0;;;K0;#I"default_external=(enc);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"enc;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@G;"I"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; ; F; ;;;;I"Encoding.default_internal;F;[;[[@li$;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 locale encoding (__ENCODING__), not default_internal, is used as the encoding of created strings. Encoding::default_internal is initialized by the source file's internal_encoding or -E option. ;T;[o;H ;II" overload;F;J0;;;K0;#I"default_internal;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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 locale encoding (__ENCODING__), not default_internal, is used as the encoding of created strings. Encoding::default_internal is initialized by the source file's internal_encoding or -E option. @overload default_internal;T;0; @;@F;Ao;B;CT;Di;Ei!;!@G;"I"]static VALUE get_default_internal(VALUE klass) { return rb_enc_default_internal(); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Encoding.default_internal=;F;[[I" encoding;T0;[[@li>;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;H ;II" overload;F;J0;;;K0;#I"default_internal=(enc);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di1;Ei;;!@G;"I"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; ; F; ;;;;I"Encoding.locale_charmap;F;[;[[I"localeinit.c;Ti_[I"miniinit.c;Ti;T;:locale_charmap;0;[;{;IC;"localeinit.c ;T;[;[;I"localeinit.c;T;0; @+;@F;Ao;B;CT;Di;Ei;!@G;"I"VALUE rb_locale_charmap(VALUE klass) { #if NO_LOCALE_CHARMAP return rb_usascii_str_new_cstr("US-ASCII"); #else return locale_charmap(rb_usascii_str_new_cstr); #endif };T;#I" VALUE;T;$To; ;IC;[#o; ; F; ;;;;I"-Encoding::Converter.asciicompat_encoding;F;[[I"arg;T0;[[@3i ;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;H ;II" overload;F;J0;:-Encoding::Converter.asciicompat_encoding;K0;#I"5Encoding::Converter.asciicompat_encoding(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;TI"nil;T; @>;[;I"@return [Encoding, nil];T;0; @>;@F;Mi;N0;[[I" string;T0; @>o;H ;II" overload;F;J0;;;K0;#I"7Encoding::Converter.asciicompat_encoding(encoding);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;TI"nil;T; @>;[;I"@return [Encoding, nil];T;0; @>;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@<;"I"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; ; F; ;;;;I"(Encoding::Converter.search_convpath;F;[[@0;[[@3iG ;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;H ;II" overload;F;J0;:(Encoding::Converter.search_convpath;K0;#I"OEncoding::Converter.search_convpath(source_encoding, destination_encoding);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @n;[;I"@return [Array];T;0; @n;@F;Mi;N0;[[I"source_encoding;T0[I"destination_encoding;T0; @no;H ;II" overload;F;J0;;;K0;#I"TEncoding::Converter.search_convpath(source_encoding, destination_encoding, opt);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @n;[;I"@return [Array];T;0; @n;@F;Mi;N0;[[I"source_encoding;T0[I"destination_encoding;T0[I"opt;T0; @n;[;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; @n;@F;Ao;B;CT;Di. ;EiF ;!@<;"I"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; ; F; ;,;;;I"#Encoding::Converter#initialize;F;[[@0;[[@3i@ ;T;;;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;H ;II" overload;F;J0;:Encoding::Converter.new;K0;#I"CEncoding::Converter.new(source_encoding, destination_encoding);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"source_encoding;T0[I"destination_encoding;T0; @o;H ;II" overload;F;J0;;;K0;#I"HEncoding::Converter.new(source_encoding, destination_encoding, opt);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"source_encoding;T0[I"destination_encoding;T0[I"opt;T0; @o;H ;II" overload;F;J0;;;K0;#I"&Encoding::Converter.new(convpath);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei= ;!@<;"I"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; ; F; ;,;;;I" Encoding::Converter#inspect;F;[;[[@3i{ ;T;;i;0;[;{;IC;"Returns a printable version of ec ec = Encoding::Converter.new("iso-8859-1", "utf-8") puts ec.inspect #=> # ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Diq ;Eiy ;!@<;"I"$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; ; F; ;,;;;I"!Encoding::Converter#convpath;F;[;[[@3i ;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;H ;II" overload;F;J0;;;K0;#I" convpath;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei ;!@<;"I"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; ; F; ;,;;;I"(Encoding::Converter#source_encoding;F;[;[[@3i ;T;:source_encoding;0;[;{;IC;"7Returns the source encoding as an Encoding object. ;T;[o;H ;II" overload;F;J0;;;K0;#I"source_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @ ;[;I"@return [Encoding];T;0; @ ;@F;Mi;N0;[; @ ;[;I"hReturns the source encoding as an Encoding object. @overload source_encoding @return [Encoding];T;0; @ ;@F;Ao;B;CT;Di ;Ei ;!@<;"I"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; ; F; ;,;;;I"-Encoding::Converter#destination_encoding;F;[;[[@3i ;T;:destination_encoding;0;[;{;IC;"destination_encoding) return Qnil; return rb_enc_from_encoding(ec->destination_encoding); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"*Encoding::Converter#primitive_convert;F;[[@0;[[@3iw;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;H ;II" overload;F;J0;;;K0;#I"9primitive_convert(source_buffer, destination_buffer);T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[[I"source_buffer;T0[I"destination_buffer;T0; @@o;H ;II" overload;F;J0;;;K0;#I"Qprimitive_convert(source_buffer, destination_buffer, destination_byteoffset);T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[[I"source_buffer;T0[I"destination_buffer;T0[I"destination_byteoffset;T0; @@o;H ;II" overload;F;J0;;;K0;#I"gprimitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize);T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[ [I"source_buffer;T0[I"destination_buffer;T0[I"destination_byteoffset;T0[I"destination_bytesize;T0; @@o;H ;II" overload;F;J0;;;K0;#I"lprimitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, opt);T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[ [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;Ao;B;CT;Di;Eit;!@<;"I" 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)) { output_bytesize = RSTRING_EMBED_LEN_MAX; 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)) { OBJ_INFECT_RAW(output, 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; ; F; ;,;;;I" Encoding::Converter#convert;F;[[I"source_string;T0;[[@3i ;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;H ;II" overload;F;J0;;;K0;#I"convert(source_string);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@<;"I"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; ; F; ;,;;;I"Encoding::Converter#finish;F;[;[[@3i;;T;: finish;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;H ;II" overload;F;J0;;;K0;#I" finish;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di0;Ei9;!@<;"I"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; ; F; ;,;;;I"*Encoding::Converter#primitive_errinfo;F;[;[[@3i;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", "UTF-8", "\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;H ;II" overload;F;J0;;;K0;#I"primitive_errinfo;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"A 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", "UTF-8", "\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;Ao;B;CT;Di\;Ei;!@<;"I":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; ; F; ;,;;;I"&Encoding::Converter#insert_output;F;[[I" string;T0;[[@3i;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;H ;II" overload;F;J0;;;K0;#I"insert_output(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@<;"I" 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; ; F; ;,;;;I" Encoding::Converter#putback;F;[[@0;[[@3i;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;H ;II" overload;F;J0;;;K0;#I" putback;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"putback(max_numbytes);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei ;!@<;"I"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; ; F; ;,;;;I"#Encoding::Converter#last_error;F;[;[[@3i>;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;H ;II" overload;F;J0;;;K0;#I"last_error;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Exception;TI"nil;T; @%;[;I"@return [Exception, nil];T;0; @%;@F;Mi;N0;[; @%;[;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;Ao;B;CT;Di*;Ei<;!@<;"I"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; ; F; ;,;;;I"$Encoding::Converter#replacement;F;[;[[@3iV;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;H ;II" overload;F;J0;;;K0;#I"replacement;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @A;[;I"@return [String];T;0; @A;@F;Mi;N0;[; @A;[;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; @A;@F;Ao;B;CT;DiJ;EiT;!@<;"I"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; ; F; ;,;;;I"%Encoding::Converter#replacement=;F;[[I"arg;T0;[[@3ip;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;H ;II" overload;F;J0;;;K0;#I"replacement=(string);T;IC;";T;[;[;I";T;0; @\;@F;Mi;N0;[[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;Ao;B;CT;Dif;Eim;!@<;"I",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; ; F; ;,;;;I"Encoding::Converter#==;F;[[I" other;T0;[[@3i ;T;;S;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @v;[;I"@return [Boolean];T;0; @v;@F;Mi;N0;[[I" other;T0; @v;[;I"- @overload ==(other) @return [Boolean];T;0; @v;@F;Ao;B;CT;Di ;Ei ;!@<;"I"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;9;[[@3i;F;:INVALID_MASK;;;;;;[;{;IC;"$Mask for invalid byte sequences ;T;[;[;I"& Mask for invalid byte sequences ;T;0; @;@F;Ao;B;CT;Di;Ei;!@<;I"&Encoding::Converter::INVALID_MASK;F; 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;H ;II" overload;F;J0;;;K0;#I"source_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @|;[;I"@return [Encoding];T;0; @|;@F;Mi;N0;[; @|;[;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;Ao;B;CT;Di;Ei;!@D;"I"sstatic VALUE ecerr_source_encoding(VALUE self) { return rb_attr_get(self, rb_intern("source_encoding")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" "\xC2\xA0" p $!.error_char.encoding #=> # end ;T;[o;H ;II" overload;F;J0;;;K0;#I"error_char;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@D;"I"istatic VALUE ecerr_error_char(VALUE self) { return rb_attr_get(self, rb_intern("error_char")); };T;#I"static VALUE;T;$T;&@D;'IC;[;&@D;(IC;[;&@D;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@3i+[@3ij;T;:UndefinedConversionError;;0;;;[;{;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; @D;@F;Ao;B;CT;Di+;Ei.;Mi;!o;2 ;30;40;50;;;!@;7@G;F0;I"'Encoding::UndefinedConversionError;F;1o;2 ;30;40;50;:EncodingError;!@;7o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@i ;T;;;;0;;;[;{;IC;"9EncodingError is the base class for encoding errors. ;T;[;[;I"; EncodingError is the base class for encoding errors. ;T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;I"EncodingError;F;1@7;F;o; ;IC;[ o; ; F; ;,;;;I" 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;H ;II" overload;F;J0;;;K0;#I"source_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @+;[;I"@return [Encoding];T;0; @+;@F;Mi;N0;[; @+;[;@;0; @+;@F;Ao;B;CT;Di;Ei;!@;"I"sstatic VALUE ecerr_source_encoding(VALUE self) { return rb_attr_get(self, rb_intern("source_encoding")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" # puts $!.error_bytes.dump #=> "\xA1" puts $!.readagain_bytes.dump #=> "\xFF" end ;T;[o;H ;II" overload;F;J0;;;K0;#I"error_bytes;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @_;[;I"@return [String];T;0; @_;@F;Mi;N0;[; @_;[;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;Ao;B;CT;Di;Ei;!@;"I"kstatic VALUE ecerr_error_bytes(VALUE self) { return rb_attr_get(self, rb_intern("error_bytes")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"7Encoding::InvalidByteSequenceError#readagain_bytes;F;[;[[@3i;T;:readagain_bytes;0;[;{;IC;"WReturns the bytes to be read again when Encoding::InvalidByteSequenceError occurs. ;T;[o;H ;II" overload;F;J0;;;K0;#I"readagain_bytes;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @z;[;I"@return [String];T;0; @z;@F;Mi;N0;[; @z;[;I"Returns the bytes to be read again when Encoding::InvalidByteSequenceError occurs. @overload readagain_bytes @return [String];T;0; @z;@F;Ao;B;CT;Di;Ei;!@;"I"sstatic VALUE ecerr_readagain_bytes(VALUE self) { return rb_attr_get(self, rb_intern("readagain_bytes")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"9Encoding::InvalidByteSequenceError#incomplete_input?;F;[;[[@3i%;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;H ;II" overload;F;J0;;;K0;#I"incomplete_input?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei#;Mi;!@;"I"ustatic VALUE ecerr_incomplete_input(VALUE self) { return rb_attr_get(self, rb_intern("incomplete_input")); };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@3i2[@3ik;T;:InvalidByteSequenceError;;0;;;[;{;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;Ao;B;CT;Di2;Ei6;Mi;!o;2 ;30;40;50;;;!@;7@G;F0;I"'Encoding::InvalidByteSequenceError;F;1o;2 ;30;40;50;;;!@;7@;F;o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@3i:[@3il;T;:ConverterNotFoundError;;0;;;[;{;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; @;@F;Ao;B;CT;Di:;Ei=;!o;2 ;30;40;50;;;!@;7@G;F0;I"%Encoding::ConverterNotFoundError;F;1o;2 ;30;40;50;;;!@;7@;F;o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@i ;T;:CompatibilityError;;0;;;[;{;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;Ao;B;CT;Di ;Ei ;!o;2 ;30;40;50;;;!@;7@G;F0;I"!Encoding::CompatibilityError;F;1@;&@G;'IC;[;&@G;(IC;[;&@G;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@li;F;;;;0;;;[;{;IC;"An 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"An 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; @G;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Encoding;F;1@ "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;H ;II" overload;F;J0;;@;K0;#I"$dump( obj [, anIO] , limit=-1 );T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;N0;!@;"I"static VALUE marshal_dump(int argc, VALUE *argv) { 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; ; T; ;;;;I"Marshal.dump;F;@;@;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;H ;II" overload;F;J0;;@;K0;#I"$dump( obj [, anIO] , limit=-1 );T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@-;#@.;$To; ; F; ;,;;;I"Marshal#load;F;[[@0;[[@i;T;;;0;[;{;IC;"Returns the result of converting the serialized data in source into a Ruby object (possibly with associated subordinate objects). source may be either an instance of IO or an object that responds to to_str. If proc is specified, each object will be passed to the proc, as the object is being deserialized. Never pass untrusted data (including user supplied input) to this method. Please see the overview for further details. ;T;[o;H ;II" overload;F;J0;;;K0;#I"load( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @D;[;I"@return [Object];T;0; @D;@F;Mi;N0;[[I"source[, proc];T0; @Do;H ;II" overload;F;J0;: restore;K0;#I"restore( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @D;[;I"@return [Object];T;0; @D;@F;Mi;N0;[[I"source[, proc];T0; @D;[;I"Returns the result of converting the serialized data in source into a Ruby object (possibly with associated subordinate objects). source may be either an instance of IO or an object that responds to to_str. If proc is specified, each object will be passed to the proc, as the object is being deserialized. Never pass untrusted data (including user supplied input) to this method. Please see the overview for further details. @overload load( source [, proc] ) @return [Object] @overload restore( source [, proc] ) @return [Object];T;0; @D;@F;N0;!@;"I"static VALUE marshal_load(int argc, VALUE *argv) { VALUE port, proc; rb_check_arity(argc, 1, 2); port = argv[0]; proc = argc > 1 ? argv[1] : Qnil; return rb_marshal_load_with_proc(port, proc); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Marshal.load;F;@F;@H;T;;;0;@J;{;IC;"Returns the result of converting the serialized data in source into a Ruby object (possibly with associated subordinate objects). source may be either an instance of IO or an object that responds to to_str. If proc is specified, each object will be passed to the proc, as the object is being deserialized. Never pass untrusted data (including user supplied input) to this method. Please see the overview for further details.;T;[o;H ;II" overload;F;J0;;;K0;#I"load( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @p;[;I"@return [Object];T;0; @p;@F;Mi;N0;[[I"source[, proc];T0; @po;H ;II" overload;F;J0;;;K0;#I"restore( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @p;[;I"@return [Object];T;0; @p;@F;Mi;N0;[[I"source[, proc];T0; @p;[;I"Returns the result of converting the serialized data in source into a Ruby object (possibly with associated subordinate objects). source may be either an instance of IO or an object that responds to to_str. If proc is specified, each object will be passed to the proc, as the object is being deserialized. Never pass untrusted data (including user supplied input) to this method. Please see the overview for further details. @overload load( source [, proc] ) @return [Object] @overload restore( source [, proc] ) @return [Object];T;0; @p;@F;Ao;B;CT;Di ;Ei;Mi;!@;"@n;#@o;$To; ; F; ;,;;;I"Marshal#restore;F;[[@0;[[@i;T;;;0;[;{;IC;"Returns the result of converting the serialized data in source into a Ruby object (possibly with associated subordinate objects). source may be either an instance of IO or an object that responds to to_str. If proc is specified, each object will be passed to the proc, as the object is being deserialized. Never pass untrusted data (including user supplied input) to this method. Please see the overview for further details. ;T;[o;H ;II" overload;F;J0;;;K0;#I"load( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"source[, proc];T0; @o;H ;II" overload;F;J0;;;K0;#I"restore( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"source[, proc];T0; @;[;I"Returns the result of converting the serialized data in source into a Ruby object (possibly with associated subordinate objects). source may be either an instance of IO or an object that responds to to_str. If proc is specified, each object will be passed to the proc, as the object is being deserialized. Never pass untrusted data (including user supplied input) to this method. Please see the overview for further details. @overload load( source [, proc] ) @return [Object] @overload restore( source [, proc] ) @return [Object];T;0; @;@F;N0;!@;"I"static VALUE marshal_load(int argc, VALUE *argv) { VALUE port, proc; rb_check_arity(argc, 1, 2); port = argv[0]; proc = argc > 1 ? argv[1] : Qnil; return rb_marshal_load_with_proc(port, proc); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Marshal.restore;F;@;@;T;;;0;@;{;IC;"Returns the result of converting the serialized data in source into a Ruby object (possibly with associated subordinate objects). source may be either an instance of IO or an object that responds to to_str. If proc is specified, each object will be passed to the proc, as the object is being deserialized. Never pass untrusted data (including user supplied input) to this method. Please see the overview for further details.;T;[o;H ;II" overload;F;J0;;;K0;#I"load( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"source[, proc];T0; @o;H ;II" overload;F;J0;;;K0;#I"restore( source [, proc] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"source[, proc];T0; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei;Mi;!@;"@;#@;$To;9;[[@i;F;:MAJOR_VERSION;;;;;;[;{;IC;"major version ;T;[;[;I"major version;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Marshal::MAJOR_VERSION;F;th ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Mutex#try_lock;F;[;[[@i;T;: try_lock;0;[;{;IC;"aAttempts to obtain the lock and returns immediately. Returns +true+ if the lock was granted. ;T;[o;H ;II" overload;F;J0;;;K0;#I" try_lock;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"Attempts to obtain the lock and returns immediately. Returns +true+ if the lock was granted. @overload try_lock @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_mutex_trylock(VALUE self) { rb_mutex_t *mutex = mutex_ptr(self); VALUE locked = Qfalse; if (mutex->th == 0) { rb_thread_t *th = GET_THREAD(); mutex->th = th; locked = Qtrue; mutex_locked(th, self); } return locked; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Mutex#lock;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" lock;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di5;Ei:;!@;"I"KVALUE rb_mutex_lock(VALUE self) { return do_mutex_lock(self, 1); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Mutex#unlock;F;[;[[@i;T;: unlock;0;[;{;IC;"\Releases the lock. Raises +ThreadError+ if +mutex+ wasn't locked by the current thread. ;T;[o;H ;II" overload;F;J0;;;K0;#I" unlock;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @;[;I"{Releases the lock. Raises +ThreadError+ if +mutex+ wasn't locked by the current thread. @overload unlock @return [self];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_mutex_unlock(VALUE self) { const char *err; rb_mutex_t *mutex = mutex_ptr(self); err = rb_mutex_unlock_th(mutex, GET_THREAD()); if (err) rb_raise(rb_eThreadError, "%s", err); return self; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Mutex#sleep;F;[[@0;[[@i;T;;;0;[;{;IC;"UReleases 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. ;T;[o;H ;II" overload;F;J0;;;K0;#I"sleep(timeout = nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @3;[;I"@return [Numeric];T;0; @3;@F;Mi;N0;[[I" timeout;TI"nil;T; @3;[;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. @overload sleep(timeout = nil) @return [Numeric];T;0; @3;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Mutex#synchronize;F;[[I" args;T0;[[@i ;T;:synchronize;0;[;{;IC;"tObtains a lock, runs the block, and releases the lock when the block completes. See the example under +Mutex+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"synchronize;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @R;[;I"@yield [];T;0; @R;@F;Mi;N0;[; @R;[;I"Obtains a lock, runs the block, and releases the lock when the block completes. See the example under +Mutex+. @overload synchronize @yield [];T;0; @R;@F;Ao;B;CT;Di;Ei ;!@;"I"static VALUE rb_mutex_synchronize_m(VALUE self, VALUE args) { 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; ; F; ;,;;;I"Mutex#owned?;F;[;[[@iH;T;;i;0;[;{;IC;"EReturns +true+ if this lock is currently held by current thread.;T;[o;H ;II" overload;F;J0;;i;K0;#I" owned?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @m;[;I"@return [Boolean];T;0; @m;@F;Mi;N0;[; @m;[;I"lReturns +true+ if this lock is currently held by current thread. @overload owned? @return [Boolean];T;0; @m;@F;Ao;B;CT;DiB;EiF;Mi;!@;"I"VALUE rb_mutex_owned_p(VALUE self) { VALUE owned = Qfalse; rb_thread_t *th = GET_THREAD(); rb_mutex_t *mutex = mutex_ptr(self); if (mutex->th == th) owned = Qtrue; return owned; };T;#I" VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i>[@i;T;: Mutex;;0;;;[;{;IC;"OMutex implements a simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads. Example: semaphore = Mutex.new a = Thread.new { semaphore.synchronize { # access shared resource } } b = Thread.new { semaphore.synchronize { # access shared resource } };T;[;[;I"R Mutex implements a simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads. Example: semaphore = Mutex.new a = Thread.new { semaphore.synchronize { # access shared resource } } b = Thread.new { semaphore.synchronize { # access shared resource } } ;T;0; @;@F;Ao;B;CT;Di>;EiR;Mi;!@;I" Mutex;F;1@ 1 puts e.next #=> 2 puts e.next #=> 3 begin e.next rescue StopIteration => ex puts ex.result #=> 100 end ;T;[o;H ;II" overload;F;J0;;;K0;#I" result;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiQ ;Eii ;!@;"I"Vstatic VALUE stop_result(VALUE self) { return rb_attr_get(self, id_result); };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i> [@i& ;T;;;;0;;;[;{;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; @;@F;Ao;B;CT;Di> ;EiM ;Mi;!@;I"StopIteration;F;1o;2 ;30;40;50;:IndexError;!@;7o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i][@i ;T;;;;0;;;[;{;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; @;@F;Ao;B;CT;Di];Eie;!@;I"IndexError;F;1@7;F;;F;o; ;IC;[o; ; F; ;,;;;I"Queue#initialize;F;[;[[@i;T;;;0;[;{;IC;""Creates a new queue instance. ;T;[;[;I"$ Creates a new queue instance. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_queue_initialize(VALUE self) { struct rb_queue *q = queue_ptr(self); RB_OBJ_WRITE(self, &q->que, ary_buf_new()); list_head_init(queue_waitq(q)); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Queue#marshal_dump;F;[;[[@i;T;;e;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Queue#close;F;[;[[@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 = Queue.new Thread.new{ while e = q.deq # wait for nil to break loop # ... end } q.close ;T;[o;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[; @ ;[;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 = Queue.new Thread.new{ while e = q.deq # wait for nil to break loop # ... end } q.close @overload close;T;0; @ ;@F;Ao;B;CT;Di ;Ei%;!@;"I"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; ; F; ;,;;;I"Queue#closed?;F;[;[[@i?;T;;;0;[;{;IC;"+Returns +true+ if the queue is closed.;T;[o;H ;II" overload;F;J0;;;K0;#I" closed?;T;IC;";T;[;[;I";T;0; @";@F;Mi;N0;[; @"o;L ;II" return;F;J@;0;K[@; @";[;I"?Returns +true+ if the queue is closed. @overload closed?;T;0; @";@F;Ao;B;CT;Di8;Ei;;Mi;!@;"I"estatic VALUE rb_queue_closed_p(VALUE self) { return queue_closed_p(self) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Queue#push;F;[[I"obj;T0;[[@iO;T;: push;0;[;{;IC;",Pushes the given +object+ to the queue. ;T;[o;H ;II" overload;F;J0;;;K0;#I"push(object);T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[[I" object;T0; @;o;H ;II" overload;F;J0;:enq;K0;#I"enq(object);T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[[I" object;T0; @;o;H ;II" overload;F;J0;;Q;K0;#I"<<(object);T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[[I" object;T0; @;;[;I"pPushes the given +object+ to the queue. @overload push(object) @overload enq(object) @overload <<(object);T;0; o; ; F; ;,;;;I" Queue#<<;F;[;[[@i;F;;Q;;0;[;{;@D;!@;"I"pstatic VALUE rb_queue_push(VALUE self, VALUE obj) { return queue_do_push(self, queue_ptr(self), obj); };T;#I"static VALUE;T;@F;Ao;B;CT;DiE;EiJ;!@;"I"pstatic VALUE rb_queue_push(VALUE self, VALUE obj) { return queue_do_push(self, queue_ptr(self), obj); };T;#@n;$To; ; F; ;,;;;I"Queue#pop;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"pop(non_block=false);T;IC;";T;[;[;I";T;0; @q;@F;Mi;N0;[[I"non_block;TI" false;T; @qo;H ;II" overload;F;J0;:deq;K0;#I"deq(non_block=false);T;IC;";T;[;[;I";T;0; @q;@F;Mi;N0;[[I"non_block;TI" false;T; @qo;H ;II" overload;F;J0;;;K0;#I"shift(non_block=false);T;IC;";T;[;[;I";T;0; @q;@F;Mi;N0;[[I"non_block;TI" false;T; @q;[;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; ; F; ;,;;;I"Queue#shift;F;[;[[@i;F;;;;0;[;{;@y;!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Queue#empty?;F;[;[[@i;T;;;0;[;{;IC;"*Returns +true+ if the queue is empty.;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;I"=Returns +true+ if the queue is empty. @overload empty?;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"xstatic VALUE rb_queue_empty_p(VALUE self) { return queue_length(self, queue_ptr(self)) == 0 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Queue#clear;F;[;[[@i;T;;3;0;[;{;IC;"(Removes all objects from the queue. ;T;[;[;I"* Removes all objects from the queue. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Queue#length;F;[;[[@i;T;;;0;[;{;IC;"%Returns the length of the queue. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"GReturns the length of the queue. @overload length @overload size;T;0; o; ; F; ;,;;;I"Queue#size;F;[;[[@i;F;;;;0;[;{;@;!@;"I"kstatic VALUE rb_queue_length(VALUE self) { return LONG2NUM(queue_length(self, queue_ptr(self))); };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei;!@;"I"kstatic VALUE rb_queue_length(VALUE self) { return LONG2NUM(queue_length(self, queue_ptr(self))); };T;#@;$To; ; F; ;,;;;I"Queue#num_waiting;F;[;[[@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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Queue#enq;F;[;[[@i;F;;;;0;[;{;@D;!@;"I"pstatic VALUE rb_queue_push(VALUE self, VALUE obj) { return queue_do_push(self, queue_ptr(self), obj); };T;#@n@fo; ; F; ;,;;;I"Queue#deq;F;[;[[@i;F;;;;0;[;{;@y;!@;"I"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;#@@@;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{ @;@f;@ ;@;@;;.[;[[@i[@i;T;: Queue;;0;;;[;{;IC;"The 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 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 = 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 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 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 = 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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Queue;F;1@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; ; F; ;,;;;I"SizedQueue#close;F;[;[[@i ;T;;;0;[;{;IC;"Similar to 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;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[; @B;[;I"Similar to 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; @B;@F;Ao;B;CT;Di;Ei;!@&;"I"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; ; F; ;,;;;I"SizedQueue#max;F;[;[[@i3;T;;;0;[;{;IC;"+Returns the maximum size of the queue. ;T;[;[;I"- Returns the maximum size of the queue. ;T;0; @X;@F;Ao;B;CT;Di-;Ei/;!@&;"I"astatic VALUE rb_szqueue_max_get(VALUE self) { return LONG2NUM(szqueue_ptr(self)->max); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SizedQueue#max=;F;[[I" vmax;T0;[[@i@;T;: max=;0;[;{;IC;">Sets the maximum size of the queue to the given +number+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"max=(number);T;IC;";T;[;[;I";T;0; @f;@F;Mi;N0;[[I" number;T0; @f;[;I"WSets the maximum size of the queue to the given +number+. @overload max=(number);T;0; @f;@F;Ao;B;CT;Di9;Ei<;!@&;"I"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; ; F; ;,;;;I"SizedQueue#push;F;[[@0;[[@ik;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;H ;II" overload;F;J0;;;K0;#I""push(object, non_block=false);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" object;T0[I"non_block;TI" false;T; @o;H ;II" overload;F;J0;;;K0;#I"!enq(object, non_block=false);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" object;T0[I"non_block;TI" false;T; @o;H ;II" overload;F;J0;;Q;K0;#I"<<(object);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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; ; F; ;,;;;I"SizedQueue#<<;F;[;[[@i;F;;Q;;0;[;{;@;!@&;"I"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)) { goto closed; } else { struct queue_waiter qw; struct list_head *pushq = szqueue_pushq(sq); qw.w.th = GET_THREAD(); qw.as.sq = sq; list_add_tail(pushq, &qw.w.node); sq->num_waiting_push++; rb_ensure(queue_sleep, self, szqueue_sleep_done, (VALUE)&qw); } } if (queue_closed_p(self)) { closed: raise_closed_queue_error(self); } return queue_do_push(self, &sq->q, argv[0]); };T;#I"static VALUE;T;@F;Ao;B;CT;Di];Eif;!@&;"I"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)) { goto closed; } else { struct queue_waiter qw; struct list_head *pushq = szqueue_pushq(sq); qw.w.th = GET_THREAD(); qw.as.sq = sq; list_add_tail(pushq, &qw.w.node); sq->num_waiting_push++; rb_ensure(queue_sleep, self, szqueue_sleep_done, (VALUE)&qw); } } if (queue_closed_p(self)) { closed: raise_closed_queue_error(self); } return queue_do_push(self, &sq->q, argv[0]); };T;#@;$To; ; F; ;,;;;I"SizedQueue#pop;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"pop(non_block=false);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"non_block;TI" false;T; @o;H ;II" overload;F;J0;;;K0;#I"deq(non_block=false);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"non_block;TI" false;T; @o;H ;II" overload;F;J0;;;K0;#I"shift(non_block=false);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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; ; F; ;,;;;I"SizedQueue#shift;F;[;[[@i;F;;;;0;[;{;@;!@&;"I"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;Ao;B;CT;Di;Ei;!@&;"I"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;#@;$To; ; F; ;,;;;I"SizedQueue#empty?;F;[;[[@i;T;;;0;[;{;IC;"*Returns +true+ if the queue is empty.;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;I"=Returns +true+ if the queue is empty. @overload empty?;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@&;"I"static VALUE rb_szqueue_empty_p(VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); return queue_length(self, &sq->q) == 0 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SizedQueue#clear;F;[;[[@i;T;;3;0;[;{;IC;"(Removes all objects from the queue. ;T;[;[;I"* Removes all objects from the queue. ;T;0; @ ;@F;Ao;B;CT;Di;Ei;!@&;"I"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; ; F; ;,;;;I"SizedQueue#length;F;[;[[@i;T;;;0;[;{;IC;"%Returns the length of the queue. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"GReturns the length of the queue. @overload length @overload size;T;0; o; ; F; ;,;;;I"SizedQueue#size;F;[;[[@i;F;;;;0;[;{;@!;!@&;"I"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;Ao;B;CT;Di;Ei;!@&;"I"static VALUE rb_szqueue_length(VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); return LONG2NUM(queue_length(self, &sq->q)); };T;#@=;$To; ; F; ;,;;;I"SizedQueue#num_waiting;F;[;[[@i;T;;;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;Ao;B;CT;Di;Ei;!@&;"I"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; ; F; ;,;;;I"SizedQueue#enq;F;[;[[@i;F;;;;0;[;{;@;!@&;"I"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)) { goto closed; } else { struct queue_waiter qw; struct list_head *pushq = szqueue_pushq(sq); qw.w.th = GET_THREAD(); qw.as.sq = sq; list_add_tail(pushq, &qw.w.node); sq->num_waiting_push++; rb_ensure(queue_sleep, self, szqueue_sleep_done, (VALUE)&qw); } } if (queue_closed_p(self)) { closed: raise_closed_queue_error(self); } return queue_do_push(self, &sq->q, argv[0]); };T;#@@o; ; F; ;,;;;I"SizedQueue#deq;F;[;[[@i;F;;;;0;[;{;@;!@&;"I"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;#@@@5;&@&;'IC;[;&@&;(IC;[;&@&;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{ @N;@;@V;@;@5;;.[;[[@i[@i;T;:SizedQueue;;0;;;[;{;IC;"This class represents queues of specified size capacity. The push operation may be blocked if the capacity is full. See Queue for an example of how a SizedQueue works.;T;[;[;I" This class represents queues of specified size capacity. The push operation may be blocked if the capacity is full. See Queue for an example of how a SizedQueue works. ;T;0; @&;@F;Ao;B;CT;Di;Ei;Mi;!@;I"SizedQueue;F;1@waitq); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"#ConditionVariable#marshal_dump;F;[;[[@i;T;;e;0;[;{;IC;" :nodoc: ;T;[;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"ConditionVariable#wait;F;[[@0;[[@ig;T;;;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. ;T;[o;H ;II" overload;F;J0;;;K0;#I"wait(mutex, timeout=nil);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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. @overload wait(mutex, timeout=nil);T;0; @;@F;Ao;B;CT;Di];Eic;!@p;"I"static VALUE rb_condvar_wait(int argc, VALUE *argv, VALUE self) { struct rb_condvar *cv = condvar_ptr(self); struct sleep_call args; struct sync_waiter w; rb_scan_args(argc, argv, "11", &args.mutex, &args.timeout); w.th = GET_THREAD(); list_add_tail(&cv->waitq, &w.node); rb_ensure(do_sleep, (VALUE)&args, delete_from_waitq, (VALUE)&w); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ConditionVariable#signal;F;[;[[@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;Ao;B;CT;Diw;Eiy;!@p;"I"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; ; F; ;,;;;I" ConditionVariable#broadcast;F;[;[[@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;Ao;B;CT;Di;Ei;!@p;"I"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;&@p;'IC;[;&@p;(IC;[;&@p;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;:ConditionVariable;;0;;;[;{;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 = Mutex.new resource = 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 = Mutex.new resource = 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; @p;@F;Ao;B;CT;Di;Ei ;Mi;!@;I"ConditionVariable;F;1@ {"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;H ;II" overload;F;J0;;%;K0;#I" list;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @8;[;I"@return [Hash];T;0; @8;@F;Mi;N0;[; @8;[;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; @8;@F;N0;!@;"I"static VALUE sig_list(void) { 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; ; T; ;;;;I"Signal.list;F;@:;@;;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;H ;II" overload;F;J0;;%;K0;#I" list;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @R;[;I"@return [Hash];T;0; @R;@F;Mi;N0;[; @R;[;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; @R;@F;Ao;B;CT;Di;Ei;Mi;!@;"@P;#@Q;$To; ; F; ;,;;;I"Signal#signame;F;[[I" signo;T0;[[@i-;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;H ;II" overload;F;J0;;;K0;#I"signame(signo);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @g;[;I"@return [String, nil];T;0; @g;@F;Mi;N0;[[I" signo;T0; @g;[;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; @g;@F;N0;!@;"I"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; ; T; ;;;;I"Signal.signame;F;@i;@l;T;;;0;@n;{;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;H ;II" overload;F;J0;;;K0;#I"signame(signo);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei+;Mi;!@;"@;#@;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;: Signal;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I" Signal;F@Io; ;IC;[o; ; F; ;;;;I"TracePoint.new;F;[[@0;[[@i@;T;; ;0;[;{;IC;"GTracePoint.new(*events) { |obj| block } -> obj Returns a new TracePoint object, not enabled by default. Next, in order to activate the trace, you must use TracePoint#enable trace = TracePoint.new(:call) do |tp| p [tp.lineno, tp.defined_class, tp.method_id, tp.event] end #=> # trace.enable #=> false puts "Hello, TracePoint!" # ... # [48, IRB::Notifier::AbstractNotifier, :printf, :call] # ... When you want to deactivate the trace, you must use TracePoint#disable trace.disable See TracePoint@Events for possible events and more information. A block must be given, otherwise an ArgumentError is raised. If the trace method isn't included in the given events filter, a RuntimeError is raised. TracePoint.trace(:line) do |tp| p tp.raised_exception end #=> RuntimeError: 'raised_exception' not supported by this event If the trace method is called outside block, a RuntimeError is raised. TracePoint.trace(:line) do |tp| $tp = tp end $tp.lineno #=> access from outside (RuntimeError) Access from other threads is also forbidden. ;T;[;[;I"JTracePoint.new(*events) { |obj| block } -> obj Returns a new TracePoint object, not enabled by default. Next, in order to activate the trace, you must use TracePoint#enable trace = TracePoint.new(:call) do |tp| p [tp.lineno, tp.defined_class, tp.method_id, tp.event] end #=> # trace.enable #=> false puts "Hello, TracePoint!" # ... # [48, IRB::Notifier::AbstractNotifier, :printf, :call] # ... When you want to deactivate the trace, you must use TracePoint#disable trace.disable See TracePoint@Events for possible events and more information. A block must be given, otherwise an ArgumentError is raised. If the trace method isn't included in the given events filter, a RuntimeError is raised. TracePoint.trace(:line) do |tp| p tp.raised_exception end #=> RuntimeError: 'raised_exception' not supported by this event If the trace method is called outside block, a RuntimeError is raised. TracePoint.trace(:line) do |tp| $tp = tp end $tp.lineno #=> access from outside (RuntimeError) Access from other threads is also forbidden. ;T;0; @;@F;Ao;B;CT;Di;Ei>;!@;"I"static VALUE tracepoint_new_s(int argc, VALUE *argv, VALUE self) { rb_event_flag_t events = 0; int i; if (argc > 0) { for (i=0; i obj A convenience method for TracePoint.new, that activates the trace automatically. trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] } #=> # trace.enabled? #=> true ;T;[;[;I" call-seq: TracePoint.trace(*events) { |obj| block } -> obj A convenience method for TracePoint.new, that activates the trace automatically. trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] } #=> # trace.enabled? #=> true ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE tracepoint_trace_s(int argc, VALUE *argv, VALUE self) { VALUE trace = tracepoint_new_s(argc, argv, self); rb_tracepoint_enable(trace); return trace; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#__enable;F;[[I" target;T0[I"target_line;T0;[[@iu;T;: __enable;0;[;{;IC;"trace.enable -> true or false trace.enable { block } -> obj Activates the trace Return true if trace was enabled. Return false if trace was disabled. trace.enabled? #=> false trace.enable #=> false (previous state) # trace is enabled trace.enabled? #=> true trace.enable #=> true (previous state) # trace is still enabled If a block is given, the trace will only be enabled within the scope of the block. trace.enabled? #=> false trace.enable do trace.enabled? # only enabled for this block end trace.enabled? #=> false Note: You cannot access event hooks within the block. trace.enable { p tp.lineno } #=> RuntimeError: access from outside ;T;[;[;I"trace.enable -> true or false trace.enable { block } -> obj Activates the trace Return true if trace was enabled. Return false if trace was disabled. trace.enabled? #=> false trace.enable #=> false (previous state) # trace is enabled trace.enabled? #=> true trace.enable #=> true (previous state) # trace is still enabled If a block is given, the trace will only be enabled within the scope of the block. trace.enabled? #=> false trace.enable do trace.enabled? # only enabled for this block end trace.enabled? #=> false Note: You cannot access event hooks within the block. trace.enable { p tp.lineno } #=> RuntimeError: access from outside ;T;0; @;@F;Ao;B;CT;DiP;Eis;!@;"I"}static VALUE tracepoint_enable_m(VALUE tpval, VALUE target, VALUE target_line) { rb_tp_t *tp = tpptr(tpval); int previous_tracing = tp->tracing; if (NIL_P(target)) { if (!NIL_P(target_line)) { rb_raise(rb_eArgError, "only target_line is specified"); } rb_tracepoint_enable(tpval); } else { rb_tracepoint_enable_for_target(tpval, target, target_line); } if (rb_block_given_p()) { return rb_ensure(rb_yield, Qundef, previous_tracing ? rb_tracepoint_enable : rb_tracepoint_disable, tpval); } else { return previous_tracing ? Qtrue : Qfalse; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#disable;F;[;[[@i;T;: disable;0;[;{;IC;"]trace.disable -> true or false trace.disable { block } -> obj Deactivates the trace Return true if trace was enabled. Return false if trace was disabled. trace.enabled? #=> true trace.disable #=> true (previous status) trace.enabled? #=> false trace.disable #=> false If a block is given, the trace will only be disable within the scope of the block. trace.enabled? #=> true trace.disable do trace.enabled? # only disabled for this block end trace.enabled? #=> true Note: You cannot access event hooks within the block. trace.disable { p tp.lineno } #=> RuntimeError: access from outside ;T;[;[;I"_trace.disable -> true or false trace.disable { block } -> obj Deactivates the trace Return true if trace was enabled. Return false if trace was disabled. trace.enabled? #=> true trace.disable #=> true (previous status) trace.enabled? #=> false trace.disable #=> false If a block is given, the trace will only be disable within the scope of the block. trace.enabled? #=> true trace.disable do trace.enabled? # only disabled for this block end trace.enabled? #=> true Note: You cannot access event hooks within the block. trace.disable { p tp.lineno } #=> RuntimeError: access from outside ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"4static VALUE tracepoint_disable_m(VALUE tpval) { rb_tp_t *tp = tpptr(tpval); int previous_tracing = tp->tracing; if (rb_block_given_p()) { if (tp->local_target_set != Qfalse) { rb_raise(rb_eArgError, "can't disable a targetting TracePoint in a block"); } rb_tracepoint_disable(tpval); return rb_ensure(rb_yield, Qundef, previous_tracing ? rb_tracepoint_enable : rb_tracepoint_disable, tpval); } else { rb_tracepoint_disable(tpval); return previous_tracing ? Qtrue : Qfalse; } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#enabled?;F;[;[[@i;T;: enabled?;0;[;{;IC;"Itrace.enabled? -> true or false The current status of the trace;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"Ktrace.enabled? -> true or false The current status of the trace ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"|VALUE rb_tracepoint_enabled_p(VALUE tpval) { rb_tp_t *tp = tpptr(tpval); return tp->tracing ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"TracePoint#inspect;F;[;[[@if;T;;i;0;[;{;IC;"CReturn a string containing a human-readable TracePoint status. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"jReturn a string containing a human-readable TracePoint status. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di^;Eic;!@;"I"static VALUE tracepoint_inspect(VALUE self) { rb_tp_t *tp = tpptr(self); rb_trace_arg_t *trace_arg = GET_EC()->trace_arg; if (trace_arg) { switch (trace_arg->event) { case RUBY_EVENT_LINE: { VALUE sym = rb_tracearg_method_id(trace_arg); if (NIL_P(sym)) goto default_inspect; return rb_sprintf("#", rb_tracearg_event(trace_arg), rb_tracearg_path(trace_arg), FIX2INT(rb_tracearg_lineno(trace_arg)), sym); } case RUBY_EVENT_CALL: case RUBY_EVENT_C_CALL: case RUBY_EVENT_RETURN: case RUBY_EVENT_C_RETURN: return rb_sprintf("#", rb_tracearg_event(trace_arg), rb_tracearg_method_id(trace_arg), rb_tracearg_path(trace_arg), FIX2INT(rb_tracearg_lineno(trace_arg))); case RUBY_EVENT_THREAD_BEGIN: case RUBY_EVENT_THREAD_END: return rb_sprintf("#", rb_tracearg_event(trace_arg), rb_tracearg_self(trace_arg)); default: default_inspect: return rb_sprintf("#", rb_tracearg_event(trace_arg), rb_tracearg_path(trace_arg), FIX2INT(rb_tracearg_lineno(trace_arg))); } } else { return rb_sprintf("#", tp->tracing ? "enabled" : "disabled"); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#event;F;[;[[@i ;T;: event;0;[;{;IC;"?Type of event See TracePoint@Events for more information. ;T;[;[;I"@Type of event See TracePoint@Events for more information. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"gstatic VALUE tracepoint_attr_event(VALUE tpval) { return rb_tracearg_event(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#lineno;F;[;[[@i;T;;;0;[;{;IC;"Line number of the event ;T;[;[;I"Line number of the event ;T;0; @';@F;Ao;B;CT;Di;Ei;!@;"I"istatic VALUE tracepoint_attr_lineno(VALUE tpval) { return rb_tracearg_lineno(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#path;F;[;[[@i;T;;;0;[;{;IC;"Path of the file being run ;T;[;[;I" Path of the file being run ;T;0; @5;@F;Ao;B;CT;Di;Ei;!@;"I"estatic VALUE tracepoint_attr_path(VALUE tpval) { return rb_tracearg_path(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#parameters;F;[;[[@i$;T;:parameters;0;[;{;IC;"RReturn the parameters of the method or block that the current hook belongs to ;T;[;[;I"SReturn the parameters of the method or block that the current hook belongs to ;T;0; @C;@F;Ao;B;CT;Di!;Ei";!@;"I"qstatic VALUE tracepoint_attr_parameters(VALUE tpval) { return rb_tracearg_parameters(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#method_id;F;[;[[@i-;T;:method_id;0;[;{;IC;"AReturn the name at the definition of the method being called ;T;[;[;I"BReturn the name at the definition of the method being called ;T;0; @Q;@F;Ao;B;CT;Di*;Ei+;!@;"I"ostatic VALUE tracepoint_attr_method_id(VALUE tpval) { return rb_tracearg_method_id(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#callee_id;F;[;[[@i6;T;:callee_id;0;[;{;IC;"6Return the called name of the method being called ;T;[;[;I"7Return the called name of the method being called ;T;0; @_;@F;Ao;B;CT;Di3;Ei4;!@;"I"ostatic VALUE tracepoint_attr_callee_id(VALUE tpval) { return rb_tracearg_callee_id(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#defined_class;F;[;[[@i^;T;:defined_class;0;[;{;IC;"Return class or module of the method being called. class C; def foo; end; end trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> C end.enable do C.new.foo end If method is defined by a module, then that module is returned. module M; def foo; end; end class C; include M; end; trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> M end.enable do C.new.foo end Note: #defined_class returns singleton class. 6th block parameter of Kernel#set_trace_func passes original class of attached by singleton class. This is a difference between Kernel#set_trace_func and TracePoint. class C; def self.foo; end; end trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> # end.enable do C.foo end ;T;[;[;I"Return class or module of the method being called. class C; def foo; end; end trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> C end.enable do C.new.foo end If method is defined by a module, then that module is returned. module M; def foo; end; end class C; include M; end; trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> M end.enable do C.new.foo end Note: #defined_class returns singleton class. 6th block parameter of Kernel#set_trace_func passes original class of attached by singleton class. This is a difference between Kernel#set_trace_func and TracePoint. class C; def self.foo; end; end trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> # end.enable do C.foo end ;T;0; @m;@F;Ao;B;CT;Di<;Ei\;!@;"I"wstatic VALUE tracepoint_attr_defined_class(VALUE tpval) { return rb_tracearg_defined_class(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#binding;F;[;[[@ig;T;;;0;[;{;IC;"3Return the generated binding object from event ;T;[;[;I"4Return the generated binding object from event ;T;0; @{;@F;Ao;B;CT;Did;Eie;!@;"I"kstatic VALUE tracepoint_attr_binding(VALUE tpval) { return rb_tracearg_binding(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#self;F;[;[[@is;T;: self;0;[;{;IC;"aReturn the trace object during event Same as TracePoint#binding: trace.binding.eval('self') ;T;[;[;I"bReturn the trace object during event Same as TracePoint#binding: trace.binding.eval('self') ;T;0; @;@F;Ao;B;CT;Dim;Eiq;!@;"I"estatic VALUE tracepoint_attr_self(VALUE tpval) { return rb_tracearg_self(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#return_value;F;[;[[@i|;T;:return_value;0;[;{;IC;"BReturn value from +:return+, +c_return+, and +b_return+ event ;T;[;[;I"CReturn value from +:return+, +c_return+, and +b_return+ event ;T;0; @;@F;Ao;B;CT;Diy;Eiz;!@;"I"ustatic VALUE tracepoint_attr_return_value(VALUE tpval) { return rb_tracearg_return_value(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" TracePoint#raised_exception;F;[;[[@i;T;:raised_exception;0;[;{;IC;"6Value from exception raised on the +:raise+ event ;T;[;[;I"7Value from exception raised on the +:raise+ event ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"}static VALUE tracepoint_attr_raised_exception(VALUE tpval) { return rb_tracearg_raised_exception(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TracePoint#eval_script;F;[;[[@i;T;:eval_script;0;[;{;IC;"Compiled source code (String) on *eval methods on the +:script_compiled+ event. If loaded from a file, it will return nil. ;T;[;[;I"{Compiled source code (String) on *eval methods on the +:script_compiled+ event. If loaded from a file, it will return nil. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"sstatic VALUE tracepoint_attr_eval_script(VALUE tpval) { return rb_tracearg_eval_script(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"$TracePoint#instruction_sequence;F;[;[[@i;T;:instruction_sequence;0;[;{;IC;"Compiled instruction sequence represented by a RubyVM::InstructionSequence instance on the +:script_compiled+ event. Note that this method is MRI specific. ;T;[;[;I"Compiled instruction sequence represented by a RubyVM::InstructionSequence instance on the +:script_compiled+ event. Note that this method is MRI specific. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE tracepoint_attr_instruction_sequence(VALUE tpval) { return rb_tracearg_instruction_sequence(get_trace_arg()); };T;#I"static VALUE;T;$To; ; F; ;;;;I"TracePoint.stat;F;[;[[@i;T;;3;0;[;{;IC;"TracePoint.stat -> obj Returns internal information of TracePoint. The contents of the returned value are implementation specific. It may be changed in future. This method is only for debugging TracePoint itself. ;T;[;[;I"TracePoint.stat -> obj Returns internal information of TracePoint. The contents of the returned value are implementation specific. It may be changed in future. This method is only for debugging TracePoint itself. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE tracepoint_stat_s(VALUE self) { rb_vm_t *vm = GET_VM(); VALUE stat = rb_hash_new(); tracepoint_stat_event_hooks(stat, vm->self, vm->global_hooks.hooks); /* TODO: thread local hooks */ return stat; };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;:TracePoint;;0;;;[;{;IC;"A class that provides the functionality of Kernel#set_trace_func in a nice Object-Oriented API. == Example We can use TracePoint to gather information specifically for exceptions: trace = TracePoint.new(:raise) do |tp| p [tp.lineno, tp.event, tp.raised_exception] end #=> # trace.enable #=> false 0 / 0 #=> [5, :raise, #] == Events If you don't specify the type of events you want to listen for, TracePoint will include all available events. *Note* do not depend on current event set, as this list is subject to change. Instead, it is recommended you specify the type of events you want to use. To filter what is traced, you can pass any of the following as +events+: +:line+:: execute code on a new line +:class+:: start a class or module definition +:end+:: finish a class or module definition +:call+:: call a Ruby method +:return+:: return from a Ruby method +:c_call+:: call a C-language routine +:c_return+:: return from a C-language routine +:raise+:: raise an exception +:b_call+:: event hook at block entry +:b_return+:: event hook at block ending +:thread_begin+:: event hook at thread beginning +:thread_end+:: event hook at thread ending +:fiber_switch+:: event hook at fiber switch ;T;[;[;I"  A class that provides the functionality of Kernel#set_trace_func in a nice Object-Oriented API. == Example We can use TracePoint to gather information specifically for exceptions: trace = TracePoint.new(:raise) do |tp| p [tp.lineno, tp.event, tp.raised_exception] end #=> # trace.enable #=> false 0 / 0 #=> [5, :raise, #] == Events If you don't specify the type of events you want to listen for, TracePoint will include all available events. *Note* do not depend on current event set, as this list is subject to change. Instead, it is recommended you specify the type of events you want to use. To filter what is traced, you can pass any of the following as +events+: +:line+:: execute code on a new line +:class+:: start a class or module definition +:end+:: finish a class or module definition +:call+:: call a Ruby method +:return+:: return from a Ruby method +:c_call+:: call a C-language routine +:c_return+:: return from a C-language routine +:raise+:: raise an exception +:b_call+:: event hook at block entry +:b_return+:: event hook at block ending +:thread_begin+:: event hook at thread beginning +:thread_end+:: event hook at thread ending +:fiber_switch+:: event hook at fiber switch ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"TracePoint;F;1@ 7 Rational(7, 1).numerator #=> 7 Rational(9, -4).numerator #=> -9 Rational(-2, -10).numerator #=> 1 ;T;[o;H ;II" overload;F;J0;;;K0;#I"numerator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiL;EiU;!@;"I"Zstatic VALUE nurat_numerator(VALUE self) { get_dat1(self); return dat->num; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#denominator;F;[;[[@ ii;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;H ;II" overload;F;J0;;;K0;#I"denominator;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[; @ ;[;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; @ ;@F;Ao;B;CT;Di^;Eig;!@;"I"\static VALUE nurat_denominator(VALUE self) { get_dat1(self); return dat->den; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#-@;F;[;[[@ iv;T;;;;0;[;{;IC;"Negates +rat+. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" -rat;T;IC;";T;[;[;I";T;0; @';@F;Mi;N0;[; @';[;I"$Negates +rat+. @overload -rat;T;0; @';@F;Ao;B;CT;Dip;Eis;!@;"I"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; ; F; ;,;;;I"Rational#+;F;[[I" other;T0;[[@ i;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;H ;II" overload;F;J0;;(;K0;#I"+(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @=;[;I"@return [Numeric];T;0; @=;@F;Mi;N0;[[I" numeric;T0; @=;[;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; @=;@F;Ao;B;CT;Di;Ei;!@;"I"\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; ; F; ;,;;;I"Rational#-;F;[[I" other;T0;[[@ i;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;H ;II" overload;F;J0;;<;K0;#I"-(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @\;[;I"@return [Numeric];T;0; @\;@F;Mi;N0;[[I" numeric;T0; @\;[;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; @\;@F;Ao;B;CT;Di;Ei;!@;"I"]static VALUE nurat_sub(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"static VALUE;T;$To; ; F; ;,;;;I"Rational#*;F;[[I" other;T0;[[@ ip;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;H ;II" overload;F;J0;;);K0;#I"*(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @{;[;I"@return [Numeric];T;0; @{;@F;Mi;N0;[[I" numeric;T0; @{;[;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; @{;@F;Ao;B;CT;Did;Ein;!@;"I"!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; ; F; ;,;;;I"Rational#/;F;[[I" other;T0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"/(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I" numeric;T0; @o;H ;II" overload;F;J0;;;K0;#I"quo(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I" numeric;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE nurat_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"static VALUE;T;$To; ; F; ;,;;;I"Rational#quo;F;[[I" other;T0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"/(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I" numeric;T0; @o;H ;II" overload;F;J0;;;K0;#I"quo(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I" numeric;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE nurat_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"static VALUE;T;$To; ; F; ;,;;;I"Rational#fdiv;F;[[I" other;T0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"fdiv(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @;[;I"@return [Float];T;0; @;@F;Mi;N0;[[I" numeric;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE nurat_fdiv(VALUE self, VALUE other) { VALUE div; if (f_zero_p(other)) return nurat_div(self, rb_float_new(0.0)); if (FIXNUM_P(other) && other == LONG2FIX(1)) return nurat_to_f(self); div = nurat_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; ; F; ;,;;;I"Rational#**;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;$To; ; F; ;,;;;I"Rational#<=>;F;[[I" other;T0;[[@ iO;T;;V;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;H ;II" overload;F;J0;;V;K0;#I"<=>(numeric);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @;[;I" @return [ -1, 0, +1, nil];T;0; @;@F;Mi;N0;[[I" numeric;T0; @;[;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; @;@F;Ao;B;CT;Di>;EiM;!@;"I"VALUE rb_rational_cmp(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { { 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); goto other_is_rational; } } else if (RB_FLOAT_TYPE_P(other)) { return rb_dbl_cmp(nurat_to_double(self), RFLOAT_VALUE(other)); } else if (RB_TYPE_P(other, T_RATIONAL)) { other_is_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); } } else { return rb_num_coerce_cmp(self, other, rb_intern("<=>")); } };T;#I" VALUE;T;$To; ; F; ;,;;;I"Rational#==;F;[[I" other;T0;[[@ i;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"==(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @?;[;I"@return [Boolean];T;0; @?;@F;Mi;N0;[[I" object;T0; @?;[;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; @?;@F;Ao;B;CT;Diw;Ei;!@;"I" 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 f_boolcast(FIXNUM_ZERO_P(rb_dbl_cmp(d, NUM2DBL(other)))); } } else if (RB_FLOAT_TYPE_P(other)) { const double d = nurat_to_double(self); return f_boolcast(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 f_boolcast(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; ; F; ;,;;;I"Rational#coerce;F;[[I" other;T0;[[@ i;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @^;@F;Ao;B;CT;Di;Ei;!@;"I"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(f_rational_new_bang1 (CLASS_OF(self), RCOMPLEX(other)->real), self); else return rb_assoc_new(other, rb_Complex(self, INT2FIX(0))); } 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; ; F; ;,;;;I"Rational#positive?;F;[;[[@ i;T;;;0;[;{;IC;"/Returns +true+ if +rat+ is greater than 0.;T;[o;H ;II" overload;F;J0;;;K0;#I"positive?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n;[;I"@return [Boolean];T;0; @n;@F;Mi;N0;[; @n;[;I"YReturns +true+ if +rat+ is greater than 0. @overload positive? @return [Boolean];T;0; @n;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"wstatic VALUE nurat_positive_p(VALUE self) { get_dat1(self); return f_boolcast(INT_POSITIVE_P(dat->num)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#negative?;F;[;[[@ i;T;;;0;[;{;IC;",Returns +true+ if +rat+ is less than 0.;T;[o;H ;II" overload;F;J0;;;K0;#I"negative?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"VReturns +true+ if +rat+ is less than 0. @overload negative? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"wstatic VALUE nurat_negative_p(VALUE self) { get_dat1(self); return f_boolcast(INT_NEGATIVE_P(dat->num)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#abs;F;[;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Rational#magnitude;F;[;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"magnitude;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Rational#floor;F;[[@0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"floor([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"[ndigits];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"{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; ; F; ;,;;;I"Rational#ceil;F;[[@0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"ceil([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"[ndigits];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"~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; ; F; ;,;;;I"Rational#truncate;F;[[@0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"truncate([ndigits]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"[ndigits];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Rational#round;F;[[@0;[[@ i ;T;;E;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;H ;II" overload;F;J0;;E;K0;#I"$round([ndigits] [, half: mode]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @9;[;I"@return [Integer];T;0; @9;@F;Mi;N0;[[I"[ndigits][, half:;TI" mode];T; @9;[;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; @9;@F;Ao;B;CT;Di;Ei ;!@;"I"Istatic 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; ; F; ;,;;;I"Rational#to_i;F;[;[[@ i;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;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @X;[;I"@return [Integer];T;0; @X;@F;Mi;N0;[; @X;[;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; @X;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Rational#to_f;F;[;[[@ i,;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;H ;II" overload;F;J0;;>;K0;#I" to_f;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @s;[;I"@return [Float];T;0; @s;@F;Mi;N0;[; @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;Ao;B;CT;Di!;Ei*;!@;"I"Wstatic VALUE nurat_to_f(VALUE self) { return DBL2NUM(nurat_to_double(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#to_r;F;[;[[@ i;;T;;;0;[;{;IC;"ZReturns self. Rational(2).to_r #=> (2/1) Rational(-8, 6).to_r #=> (-4/3) ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_r;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @;[;I"|Returns self. Rational(2).to_r #=> (2/1) Rational(-8, 6).to_r #=> (-4/3) @overload to_r @return [self];T;0; @;@F;Ao;B;CT;Di2;Ei9;!@;"I"=static VALUE nurat_to_r(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#rationalize;F;[[@0;[[@ i;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;H ;II" overload;F;J0;;;K0;#I"rationalize;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"rationalize(eps);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"eps;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE nurat_rationalize(int argc, VALUE *argv, VALUE self) { VALUE e, a, b, p, q; if (rb_check_arity(argc, 0, 1) == 0) return self; if (nurat_negative_p(self)) return rb_rational_uminus(nurat_rationalize(argc, argv, rb_rational_uminus(self))); e = f_abs(argv[0]); a = f_sub(self, e); b = f_add(self, e); if (f_eqeq_p(a, b)) return self; nurat_rationalize_internal(a, b, &p, &q); return f_rational_new2(CLASS_OF(self), p, q); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#hash;F;[;[[@ i;T;;U;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE nurat_hash(VALUE self) { st_index_t v, h[2]; VALUE n; get_dat1(self); n = rb_hash(dat->num); h[0] = NUM2LONG(n); n = rb_hash(dat->den); h[1] = NUM2LONG(n); v = rb_memhash(h, sizeof(h)); return ST2FIX(v); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#to_s;F;[;[[@ i;T;;h;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;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"Ostatic VALUE nurat_to_s(VALUE self) { return f_format(self, f_to_s); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Rational#inspect;F;[;[[@ i;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Rational#marshal_dump;F;[;[[@ i#;T;;e;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di";Ei";!@;"I"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; ; F; ;,;;;I"&Rational::compatible#marshal_load;F;[[I"a;T0;[[@ i/;T;;f;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @#;@F;Ao;B;CT;Di.;Ei.;!@!;"I"static VALUE nurat_marshal_load(VALUE self, VALUE a) { VALUE num, den; rb_check_frozen(self); rb_check_trusted(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;&@!;'IC;[;&@!;(IC;[;&@!;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ i ;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @!;Mi;!@;I"Rational::compatible;F;1@<;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ i ;F;;;;0;;;[;{;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. In Ruby, you can create rational objects with the Kernel#Rational, to_r, or rationalize methods or by suffixing +r+ to a literal. The return values will be irreducible fractions. Rational(1) #=> (1/1) Rational(2, 3) #=> (2/3) Rational(4, -6) #=> (-2/3) 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. In Ruby, you can create rational objects with the Kernel#Rational, to_r, or rationalize methods or by suffixing +r+ to a literal. The return values will be irreducible fractions. Rational(1) #=> (1/1) Rational(2, 3) #=> (2/3) Rational(4, -6) #=> (-2/3) 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; @;@F;Ao;B;CT;Dim ;Ei ;!@;I" Rational;F;1@mo; ;IC;[o; ; F; ;,;;;I"MatchData#initialize_copy;F;[[I" orig;T0;[[@}i ;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @U;@F;Ao;B;CT;Di;Ei;!@S;"I"Vstatic 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_updated) { rm->char_offset_updated = 0; } else { 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); rm->char_offset_updated = 1; RB_GC_GUARD(orig); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"MatchData#regexp;F;[;[[@}iJ;T;: regexp;0;[;{;IC;"MReturns the regexp. m = /a.*b/.match("abc") m.regexp #=> /a.*b/ ;T;[o;H ;II" overload;F;J0;;;K0;#I" regexp;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Regexp;T; @e;[;I"@return [Regexp];T;0; @e;@F;Mi;N0;[; @e;[;I"sReturns the regexp. m = /a.*b/.match("abc") m.regexp #=> /a.*b/ @overload regexp @return [Regexp];T;0; @e;@F;Ao;B;CT;Di@;EiG;!@S;"I"!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; ; F; ;,;;;I"MatchData#names;F;[;[[@}if;T;;;0;[;{;IC;",Returns a list of names of captures as an array of strings. It is same as mtch.regexp.names. /(?.)(?.)(?.)/.match("hoge").names #=> ["foo", "bar", "baz"] m = /(?.)(?.)?/.match("a") #=> # m.names #=> ["x", "y"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" names;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"PReturns a list of names of captures as an array of strings. It is 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;Ao;B;CT;DiX;Eic;!@S;"I"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; ; F; ;,;;;I"MatchData#size;F;[;[[@}i{;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;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Dio;Eiy;!@S;"I"wstatic VALUE match_size(VALUE match) { match_check(match); return INT2FIX(RMATCH_REGS(match)->num_regs); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"MatchData#length;F;[;[[@}i{;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;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Dio;Eiy;!@S;"I"wstatic VALUE match_size(VALUE match) { match_check(match); return INT2FIX(RMATCH_REGS(match)->num_regs); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"MatchData#offset;F;[[I"n;T0;[[@}i;T;: offset;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;H ;II" overload;F;J0;;;K0;#I"offset(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"n;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@S;"I"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); if (i < 0 || regs->num_regs <= i) rb_raise(rb_eIndexError, "index %d out of matches", 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; ; F; ;,;;;I"MatchData#begin;F;[[I"n;T0;[[@}i;T;;D;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;H ;II" overload;F;J0;;D;K0;#I" begin(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[[I"n;T0; @ ;[;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; @ ;@F;Ao;B;CT;Di;Ei;!@S;"I"static VALUE match_begin(VALUE match, VALUE n) { int i = match_backref_number(match, n); struct re_registers *regs = RMATCH_REGS(match); match_check(match); if (i < 0 || regs->num_regs <= i) rb_raise(rb_eIndexError, "index %d out of matches", 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; ; F; ;,;;;I"MatchData#end;F;[[I"n;T0;[[@}i;T;;E;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;H ;II" overload;F;J0;;E;K0;#I" end(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @(;[;I"@return [Integer];T;0; @(;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@S;"I"static VALUE match_end(VALUE match, VALUE n) { int i = match_backref_number(match, n); struct re_registers *regs = RMATCH_REGS(match); match_check(match); if (i < 0 || regs->num_regs <= i) rb_raise(rb_eIndexError, "index %d out of matches", 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; ; F; ;,;;;I"MatchData#to_a;F;[;[[@}iw;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;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @G;[;I"@return [Array];T;0; @G;@F;Mi;N0;[; @G;[;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; @G;@F;Ao;B;CT;Dia;Eit;!@S;"I"Ostatic VALUE match_to_a(VALUE match) { return match_array(match, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"MatchData#[];F;[[@0;[[@}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;H ;II" overload;F;J0;;;K0;#I" [](i);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @b;[;I"@return [String, nil];T;0; @b;@F;Mi;N0;[[I"i;T0; @bo;H ;II" overload;F;J0;;;K0;#I"[](start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @b;[;I"@return [Array];T;0; @b;@F;Mi;N0;[[I" start;T0[I" length;T0; @bo;H ;II" overload;F;J0;;;K0;#I"[](range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @b;[;I"@return [Array];T;0; @b;@F;Mi;N0;[[I" range;T0; @bo;H ;II" overload;F;J0;;;K0;#I" [](name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @b;[;I"@return [String, nil];T;0; @b;@F;Mi;N0;[[I" name;T0; @b;[;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; @b;@F;Ao;B;CT;Di;Ei;!@S;"I"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; ; F; ;,;;;I"MatchData#captures;F;[;[[@}i;T;: captures;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;H ;II" overload;F;J0;;;K0;#I" captures;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di~;Ei;!@S;"I"Sstatic VALUE match_captures(VALUE match) { return match_array(match, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"MatchData#named_captures;F;[;[[@}i;T;;;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;H ;II" overload;F;J0;;;K0;#I"named_captures;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@S;"I"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; ; F; ;,;;;I"MatchData#values_at;F;[[@0;[[@}i3;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 = /(?\d+) *(?[+\-*\/]) *(?\d+)/.match("1 + 2") m.to_a #=> ["1 + 2", "1", "+", "2"] m.values_at(:a, :b, :op) #=> ["1", "2", "+"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"values_at(index, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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 = /(?\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;Ao;B;CT;Di";Ei/;!@S;"I"(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; ; F; ;,;;;I"MatchData#pre_match;F;[;[[@}i;T;:pre_match;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;H ;II" overload;F;J0;;;K0;#I"pre_match;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@S;"I"GVALUE 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)); if (OBJ_TAINTED(match)) OBJ_TAINT(str); return str; };T;#I" VALUE;T;$To; ; F; ;,;;;I"MatchData#post_match;F;[;[[@}i ;T;:post_match;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;H ;II" overload;F;J0;;;K0;#I"post_match;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @";[;I"@return [String];T;0; @";@F;Mi;N0;[; @";[;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;Ao;B;CT;Di;Ei;!@S;"I"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); if (OBJ_TAINTED(match)) OBJ_TAINT(str); return str; };T;#I" VALUE;T;$To; ; F; ;,;;;I"MatchData#to_s;F;[;[[@}iX;T;;h;0;[;{;IC;"lReturns the entire matched string. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_s #=> "HX1138" ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @=;[;I"@return [String];T;0; @=;@F;Mi;N0;[; @=;[;I"Returns the entire matched string. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_s #=> "HX1138" @overload to_s @return [String];T;0; @=;@F;Ao;B;CT;DiN;EiU;!@S;"I" 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); if (OBJ_TAINTED(match)) OBJ_TAINT(str); if (OBJ_TAINTED(RMATCH(match)->str)) OBJ_TAINT(str); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"MatchData#inspect;F;[;[[@}i;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @X;[;I"@return [String];T;0; @X;@F;Mi;N0;[; @X;[;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; @X;@F;Ao;B;CT;Di;Ei;!@S;"I"Tstatic 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 (v == Qnil) 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; ; F; ;,;;;I"MatchData#string;F;[;[[@}i;T;: string;0;[;{;IC;"Returns a frozen copy of the string passed in to match. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.string #=> "THX1138." ;T;[o;H ;II" overload;F;J0;;;K0;#I" string;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @s;[;I"@return [String];T;0; @s;@F;Mi;N0;[; @s;[;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; @s;@F;Ao;B;CT;Di;Ei;!@S;"I"zstatic VALUE match_string(VALUE match) { match_check(match); return RMATCH(match)->str; /* str is frozen */ };T;#I"static VALUE;T;$To; ; F; ;,;;;I"MatchData#hash;F;[;[[@}i ;T;;U;0;[;{;IC;"vProduce a hash based on the target string, regexp and matched positions of this matchdata. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@S;"I"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; ; F; ;,;;;I"MatchData#eql?;F;[[I" match2;T0;[[@}i& ;T;;R;0;[;{;IC;"pEquality---Two matchdata are equal if their target strings, patterns, and matched positions are identical.;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(mtch2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" mtch2;T0; @o;H ;II" overload;F;J0;;R;K0;#I"eql?(mtch2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" mtch2;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei$ ;Mi;!@S;"I"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; ; F; ;,;;;I"MatchData#==;F;[[I" match2;T0;[[@}i& ;T;;S;0;[;{;IC;"pEquality---Two matchdata are equal if their target strings, patterns, and matched positions are identical. ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(mtch2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" mtch2;T0; @o;H ;II" overload;F;J0;;R;K0;#I"eql?(mtch2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" mtch2;T0; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei$ ;!@S;"I"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;&@S;'IC;[;&@S;(IC;[;&@S;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@}it[@}i ;T;:MatchData;;0;;;[;{;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; @S;@F;Ao;B;CT;Dit;Ei;Mi;!@;I"MatchData;F;1@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;Ao;B;CT;Di;Ei;!@;I"RegexpError;F;1o;2 ;30;40;50;;;!@;7@7;F;@io; ;IC;[ o; ; F; ;,;;;I"TrueClass#to_s;F;[;[[@i;T;;h;0;[;{;IC;">The string representation of true is "true". ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[; @-;[;I"OThe string representation of true is "true". @overload to_s;T;0; o; ; F; ;,;;;I"TrueClass#inspect;F;[;[[@i;F;;i;;0;[;{;@4;!@+;"I"Rstatic VALUE true_to_s(VALUE obj) { return rb_usascii_str_new2("true"); };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei;!@+;"I"Rstatic VALUE true_to_s(VALUE obj) { return rb_usascii_str_new2("true"); };T;#@H;$T@@o; ; F; ;,;;;I"TrueClass#&;F;[[I" obj2;T0;[[@i;T;;;0;[;{;IC;"{And---Returns false if obj is nil or false, true otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I" &(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @K;[;I"@return [Boolean];T;0; @K;@F;Mi;N0;[[I"obj;T0; @K;[;I"And---Returns false if obj is nil or false, true otherwise. @overload &(obj) @return [Boolean];T;0; @K;@F;Ao;B;CT;Di;Ei;!@+;"I"Zstatic VALUE true_and(VALUE obj, VALUE obj2) { return RTEST(obj2)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TrueClass#|;F;[[I" obj2;T0;[[@i ;T;;;0;[;{;IC;"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 ;T;[o;H ;II" overload;F;J0;;;K0;#I" |(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @j;[;I"@return [true];T;0; @j;@F;Mi;N0;[[I"obj;T0; @j;[;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; @j;@F;Ao;B;CT;Di;Ei ;!@+;"I"Fstatic VALUE true_or(VALUE obj, VALUE obj2) { return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TrueClass#^;F;[[I" obj2;T0;[[@i;T;;;0;[;{;IC;"Exclusive Or---Returns true if obj is nil or false, false otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I" ^(obj);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"Exclusive Or---Returns true if obj is nil or false, false otherwise. @overload ^(obj);T;0; @;@F;Ao;B;CT;Di;Ei;!@+;"I"Zstatic VALUE true_xor(VALUE obj, VALUE obj2) { return RTEST(obj2)?Qfalse:Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TrueClass#===;F;[[I" obj2;T0;[[@i;T;;O;0;[;{;IC;"Case Equality -- For class Object, effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in +case+ statements. ;T;[o;H ;II" overload;F;J0;;O;K0;#I"===(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;@;0; @;@F;Ao;B;CT;Dix;Ei;!@+;"I"VALUE rb_equal(VALUE obj1, VALUE obj2) { VALUE result; if (obj1 == obj2) return Qtrue; result = rb_equal_opt(obj1, obj2); if (result == Qundef) { result = rb_funcall(obj1, id_eq, 1, obj2); } if (RTEST(result)) return Qtrue; return Qfalse; };T;#I" VALUE;T;$T;&@+;'IC;[;&@+;(IC;[;&@+;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@@;h;.[;[[@i[@i;T;:TrueClass;;0;;;[;{;IC;"?********************************************************************* 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;[;[;I"@********************************************************************* 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; @+;@F;Ao;B;CT;Di;Ei;Mi;!@;I"TrueClass;F;1@false is "false". ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"QThe string representation of false is "false". @overload to_s;T;0; o; ; F; ;,;;;I"FalseClass#inspect;F;[;[[@i;F;;i;;0;[;{;@;!@;"I"Tstatic VALUE false_to_s(VALUE obj) { return rb_usascii_str_new2("false"); };T;#I"static VALUE;T;@F;Ao;B;CT;Di.;Ei1;!@;"I"Tstatic VALUE false_to_s(VALUE obj) { return rb_usascii_str_new2("false"); };T;#@;$T@o; ; F; ;,;;;I"FalseClass#&;F;[[I" obj2;T0;[[@iE;T;;;0;[;{;IC;"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. ;T;[o;H ;II" overload;F;J0;;;K0;#I" &(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" false;T; @;[;I"@return [false];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;;K0;#I" &(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" false;T; @;[;I"@return [false];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;@;0; @;@F;Ao;B;CT;Di;;EiC;!@;"I"Istatic VALUE false_and(VALUE obj, VALUE obj2) { return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"FalseClass#|;F;[[I" obj2;T0;[[@iU;T;;;0;[;{;IC;"zOr---Returns false if obj is nil or false; true otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I" |(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ o;H ;II" overload;F;J0;;;K0;#I" |(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ ;[;@;0; @ ;@F;Ao;B;CT;DiL;EiS;!@;"I"Zstatic VALUE false_or(VALUE obj, VALUE obj2) { return RTEST(obj2)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"FalseClass#^;F;[[I" obj2;T0;[[@ih;T;;;0;[;{;IC;"Exclusive Or---If obj is nil or false, returns false; otherwise, returns true. ;T;[o;H ;II" overload;F;J0;;;K0;#I" ^(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @M;[;I"@return [Boolean];T;0; @M;@F;Mi;N0;[[I"obj;T0; @Mo;H ;II" overload;F;J0;;;K0;#I" ^(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @M;[;I"@return [Boolean];T;0; @M;@F;Mi;N0;[[I"obj;T0; @M;[;@;0; @M;@F;Ao;B;CT;Di];Eif;!@;"I"[static VALUE false_xor(VALUE obj, VALUE obj2) { return RTEST(obj2)?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"FalseClass#===;F;[[I" obj2;T0;[[@i;T;;O;0;[;{;IC;"Case Equality -- For class Object, effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in +case+ statements. ;T;[o;H ;II" overload;F;J0;;O;K0;#I"===(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @z;[;I"@return [Boolean];T;0; @z;@F;Mi;N0;[[I" other;T0; @z;[;@;0; @z;@F;Ao;B;CT;Dix;Ei;!@;"I"VALUE rb_equal(VALUE obj1, VALUE obj2) { VALUE result; if (obj1 == obj2) return Qtrue; result = rb_equal_opt(obj1, obj2); if (result == Qundef) { result = rb_funcall(obj1, id_eq, 1, obj2); } if (RTEST(result)) return Qtrue; return Qfalse; };T;#I" VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@;h;.[;[[@i$[@i;T;:FalseClass;;0;;;[;{;IC;"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;[;[;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;Ao;B;CT;Di$;Ei*;Mi;!@;I"FalseClass;F;1@mod. This method returns self. ;T;[o;H ;II" overload;F;J0;;f;K0;#I" freeze;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"`Prevents further modifications to mod. This method returns self. @overload freeze;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"estatic VALUE rb_mod_freeze(VALUE mod) { rb_class_name(mod); return rb_obj_freeze(mod); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#===;F;[[I"arg;T0;[[@i+;T;;O;0;[;{;IC;"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. ;T;[o;H ;II" overload;F;J0;;O;K0;#I" ===(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;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; @;@F;Ao;B;CT;Di!;Ei(;!@;"I"^static VALUE rb_mod_eqq(VALUE mod, VALUE arg) { return rb_obj_is_kind_of(arg, mod); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#==;F;[[I" obj2;T0;[[@i;T;;S;0;[;{;IC;"Equality --- At the Object level, == returns true only if +obj+ and +other+ are the same object. Typically, this method is overridden in descendant classes to provide class-specific meaning. Unlike ==, the equal? method should never be overridden by subclasses as it is used to determine object identity (that is, a.equal?(b) if and only if a is the same object as b): obj = "a" other = obj.dup obj == other #=> true obj.equal? other #=> false obj.equal? obj #=> true The eql? method returns true if +obj+ and +other+ refer to the same hash key. This is used by Hash to test members for equality. For 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;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @/;[;I"@return [Boolean];T;0; @/;@F;Mi;N0;[[I" other;T0; @/o;H ;II" overload;F;J0;;T;K0;#I"equal?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @/;[;I"@return [Boolean];T;0; @/;@F;Mi;N0;[[I" other;T0; @/o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @/;[;I"@return [Boolean];T;0; @/;@F;Mi;N0;[[I" other;T0; @/;[;@';0; @/;@F;Ao;B;CT;Di;Ei;!@;"I"}MJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { if (obj1 == obj2) return Qtrue; return Qfalse; };T;#I"MJIT_FUNC_EXPORTED VALUE;T;$To; ; F; ;,;;;I"Module#<=>;F;[[I"arg;T0;[[@i;T;;V;0;[;{;IC;"+Comparison---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. ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(other_module);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @k;[;I"@return [-1, 0, +1, nil];T;0; @k;@F;Mi;N0;[[I"other_module;T0; @k;[;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; @k;@F;Ao;B;CT;Di;Ei;!@;"I",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; ; F; ;,;;;I" Module#<;F;[[I"arg;T0;[[@ia;T;;;0;[;{;IC;"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".) ;T;[o;H ;II" overload;F;J0;;;K0;#I" <(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @;[;I"@return [true, false, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiV;Ei^;!@;"I"~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; ; F; ;,;;;I"Module#<=;F;[[I"arg;T0;[[@iE;T;;;0;[;{;IC;"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".) ;T;[o;H ;II" overload;F;J0;;;K0;#I"<=(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @;[;I"@return [true, false, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di1;Ei:;!@;"I"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; ; F; ;,;;;I" Module#>;F;[[I"arg;T0;[[@i;T;;;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;H ;II" overload;F;J0;;;K0;#I" >(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @;[;I"@return [true, false, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#>=;F;[[I"arg;T0;[[@iu;T;;;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;H ;II" overload;F;J0;;;K0;#I">=(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;TI" false;TI"nil;T; @;[;I"@return [true, false, nil];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;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; @;@F;Ao;B;CT;Dii;Eir;!@;"I"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; ; F; ;,;;;I"Module#initialize_copy;F;[[I" orig;T0;[[@i9;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di8;Ei8;!@;"I"VALUE rb_mod_init_copy(VALUE clone, VALUE orig) { if (RB_TYPE_P(clone, T_CLASS)) { class_init_copy_check(clone, orig); } if (!OBJ_INIT_COPY(clone, orig)) return clone; 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_SET_SUPER(clone, RCLASS_SUPER(orig)); RCLASS_EXT(clone)->allocator = RCLASS_EXT(orig)->allocator; if (RCLASS_IV_TBL(clone)) { st_free_table(RCLASS_IV_TBL(clone)); RCLASS_IV_TBL(clone) = 0; } if (RCLASS_CONST_TBL(clone)) { rb_free_const_table(RCLASS_CONST_TBL(clone)); RCLASS_CONST_TBL(clone) = 0; } RCLASS_M_TBL(clone) = 0; if (RCLASS_IV_TBL(orig)) { st_data_t id; RCLASS_IV_TBL(clone) = rb_st_copy(clone, RCLASS_IV_TBL(orig)); CONST_ID(id, "__tmp_classpath__"); st_delete(RCLASS_IV_TBL(clone), &id, 0); CONST_ID(id, "__classpath__"); st_delete(RCLASS_IV_TBL(clone), &id, 0); CONST_ID(id, "__classid__"); st_delete(RCLASS_IV_TBL(clone), &id, 0); } if (RCLASS_CONST_TBL(orig)) { struct clone_const_arg arg; arg.tbl = RCLASS_CONST_TBL(clone) = rb_id_table_create(0); arg.klass = clone; rb_id_table_foreach(RCLASS_CONST_TBL(orig), clone_const_i, &arg); } 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); } return clone; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#to_s;F;[;[[@i;T;;h;0;[;{;IC;"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. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @!;[;I"@return [String];T;0; @!;@F;Mi;N0;[; @!;[;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; ; F; ;,;;;I"Module#inspect;F;[;[[@i;F;;i;;0;[;{;@(;!@;"I"?static 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_str_dup(rb_class_name(klass)); };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei;!@;"I"?static 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_str_dup(rb_class_name(klass)); };T;#@A;$T@9o; ; F; ;,;;;I"Module#included_modules;F;[;[[@i;T;:included_modules;0;[;{;IC;"Returns the list of modules included in mod. module Mixin end module Outer include Mixin end Mixin.included_modules #=> [] Outer.included_modules #=> [Mixin] ;T;[o;H ;II" overload;F;J0;;!;K0;#I"included_modules;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @D;[;I"@return [Array];T;0; @D;@F;Mi;N0;[; @D;[;I"Returns the list of modules included in mod. module Mixin end module Outer include Mixin end Mixin.included_modules #=> [] Outer.included_modules #=> [Mixin] @overload included_modules @return [Array];T;0; @D;@F;Ao;B;CT;Di;Ei;!@;"I"^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 && 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; ; F; ;,;;;I"Module#include?;F;[[I" mod2;T0;[[@i;T;;U;0;[;{;IC;"Returns true if module is included 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;H ;II" overload;F;J0;;U;K0;#I"include?(module);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @_;[;I"@return [Boolean];T;0; @_;@F;Mi;N0;[; @_;[;I"7Returns true if module is included 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;Ao;B;CT;Di ;Ei;Mi;!@;"I" VALUE 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) { if (RBASIC(p)->klass == mod2) return Qtrue; } } return Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#name;F;[;[[@$i;T;;>;0;[;{;IC;"SReturns the name of the module mod. Returns nil for anonymous modules. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @|;[;I"@return [String];T;0; @|;@F;Mi;N0;[; @|;[;I"wReturns the name of the module mod. Returns nil for anonymous modules. @overload name @return [String];T;0; @|;@F;Ao;B;CT;Di;Ei;!@;"I"VALUE rb_mod_name(VALUE mod) { int permanent; VALUE path = classname(mod, &permanent); if (!NIL_P(path)) return rb_str_dup(path); return path; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#ancestors;F;[;[[@i<;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;H ;II" overload;F;J0;;";K0;#I"ancestors;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di*;Ei9;!@;"I"VALUE rb_mod_ancestors(VALUE mod) { VALUE p, ary = rb_ary_new(); for (p = mod; p; p = RCLASS_SUPER(p)) { if (BUILTIN_TYPE(p) == T_ICLASS) { rb_ary_push(ary, RBASIC(p)->klass); } else if (p == RCLASS_ORIGIN(p)) { rb_ary_push(ary, p); } } return ary; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#attr;F;[[@0;[[@i/ ;T;: attr;0;[;{;IC;"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. ;T;[o;H ;II" overload;F;J0;;#;K0;#I"attr(name, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" name;T0[I"...;T0; @o;H ;II" overload;F;J0;;#;K0;#I"attr(name, true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" name;T0[I" true;T0; @o;H ;II" overload;F;J0;;#;K0;#I"attr(name, false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[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. @overload attr(name, ...) @return [nil] @overload attr(name, true) @return [nil] @overload attr(name, false) @return [nil];T;0; @;@F;Ao;B;CT;Di! ;Ei, ;!@;"I"=VALUE rb_mod_attr(int argc, VALUE *argv, VALUE klass) { if (argc == 2 && (argv[1] == Qtrue || argv[1] == Qfalse)) { rb_warning("optional boolean argument is obsoleted"); rb_attr(klass, id_for_attr(klass, argv[0]), 1, RTEST(argv[1]), TRUE); return Qnil; } return rb_mod_attr_reader(argc, argv, klass); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#attr_reader;F;[[@0;[[@i ;T;:attr_reader;0;[;{;IC;"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. ;T;[ o;H ;II" overload;F;J0;;$;K0;#I"attr_reader(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @o;H ;II" overload;F;J0;;#;K0;#I"attr(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @o;H ;II" overload;F;J0;;$;K0;#I"attr_reader(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @o;H ;II" overload;F;J0;;#;K0;#I"attr(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @;[;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. @overload attr_reader(symbol, ...) @return [nil] @overload attr(symbol, ...) @return [nil] @overload attr_reader(string, ...) @return [nil] @overload attr(string, ...) @return [nil];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass) { int i; for (i=0; isymbol.id2name. String arguments are converted to symbols. ;T;[o;H ;II" overload;F;J0;;%;K0;#I"attr_writer(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @G;[;I"@return [nil];T;0; @G;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @Go;H ;II" overload;F;J0;;%;K0;#I"attr_writer(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @G;[;I"@return [nil];T;0; @G;@F;Mi;N0;[[I" string;T0[I"...;T0; @G;[;I"Creates an accessor method to allow assignment to the attribute symbol.id2name. String arguments are converted to symbols. @overload attr_writer(symbol, ...) @return [nil] @overload attr_writer(string, ...) @return [nil];T;0; @G;@F;Ao;B;CT;Di: ;EiB ;!@;"I"static VALUE rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass) { int i; 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. module Mod attr_accessor(:one, :two) end Mod.instance_methods.sort #=> [:one, :one=, :two, :two=] ;T;[o;H ;II" overload;F;J0;;&;K0;#I"attr_accessor(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @x;[;I"@return [nil];T;0; @x;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @xo;H ;II" overload;F;J0;;&;K0;#I"attr_accessor(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @x;[;I"@return [nil];T;0; @x;@F;Mi;N0;[[I" string;T0[I"...;T0; @x;[;I"Defines 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. module Mod attr_accessor(:one, :two) end Mod.instance_methods.sort #=> [:one, :one=, :two, :two=] @overload attr_accessor(symbol, ...) @return [nil] @overload attr_accessor(string, ...) @return [nil];T;0; @x;@F;Ao;B;CT;DiO ;Ei^ ;!@;"I"static VALUE rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) { int i; for (i=0; imodule_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. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"mod;T; @;[;I"@yield [mod];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_mod_initialize(VALUE module) { if (rb_block_given_p()) { rb_mod_module_exec(1, &module, module); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#initialize_clone;F;[[I" orig;T0;[[@i;T;;_;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_mod_initialize_clone(VALUE clone, VALUE orig) { VALUE ret; ret = rb_obj_init_dup_clone(clone, orig); if (OBJ_FROZEN(orig)) rb_class_name(clone); return ret; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#instance_methods;F;[[@0;[[@i;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;H ;II" overload;F;J0;;';K0;#I")instance_methods(include_super=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"#Module#public_instance_methods;F;[[@0;[[@i;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;H ;II" overload;F;J0;;(;K0;#I"0public_instance_methods(include_super=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"&Module#protected_instance_methods;F;[[@0;[[@i;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;H ;II" overload;F;J0;;);K0;#I"3protected_instance_methods(include_super=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"$Module#private_instance_methods;F;[[@0;[[@i;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;H ;II" overload;F;J0;;*;K0;#I"1private_instance_methods(include_super=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @9;[;I"@return [Array];T;0; @9;@F;Mi;N0;[[I"include_super;TI" true;T; @9;[;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; @9;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#constants;F;[[@0;[[@$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;H ;II" overload;F;J0;;+;K0;#I"constants(inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @X;[;I"@return [Array];T;0; @X;@F;Mi;N0;[[I" inherit;TI" true;T; @X;[;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; @X;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Module#const_get;F;[[@0;[[@i ;T;:const_get;0;[;{;IC;"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 ;T;[o;H ;II" overload;F;J0;;,;K0;#I"!const_get(sym, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @w;[;I"@return [Object];T;0; @w;@F;Mi;N0;[[I"sym;T0[I" inherit;TI" true;T; @wo;H ;II" overload;F;J0;;,;K0;#I"!const_get(str, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @w;[;I"@return [Object];T;0; @w;@F;Mi;N0;[[I"str;T0[I" inherit;TI" true;T; @w;[;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; @w;@F;Ao;B;CT;Dik ;Ei ;!@;"I"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) { wrong_name: rb_name_err_raise(wrong_constant_name, mod, 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; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#const_set;F;[[I" name;T0[I" value;T0;[[@i ;T;:const_set;0;[;{;IC;"Sets 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 ;T;[o;H ;II" overload;F;J0;;-;K0;#I"const_set(sym, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"sym;T0[I"obj;T0; @o;H ;II" overload;F;J0;;-;K0;#I"const_set(str, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE rb_mod_const_set(VALUE mod, VALUE name, VALUE value) { ID id = id_for_setter(mod, name, const, wrong_constant_name); if (!id) id = rb_intern_str(name); rb_const_set(mod, id, value); return value; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#const_defined?;F;[[@0;[[@i= ;T;:const_defined?;0;[;{;IC;"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;T;[o;H ;II" overload;F;J0;;.;K0;#I"&const_defined?(sym, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"sym;T0[I" inherit;TI" true;T; @o;H ;II" overload;F;J0;;.;K0;#I"&const_defined?(str, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei; ;Mi;!@;"I"n 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) { wrong_name: rb_name_err_raise(wrong_constant_name, mod, 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; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#remove_const;F;[[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;H ;II" overload;F;J0;;/;K0;#I"remove_const(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"VALUE rb_mod_remove_const(VALUE mod, VALUE name) { const ID id = id_for_var(mod, name, a, constant); if (!id) { rb_name_err_raise("constant %2$s::%1$s not defined", mod, name); } return rb_const_remove(mod, id); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#const_missing;F;[[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;H ;II" overload;F;J0;;0;K0;#I"const_missing(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @0;[;I"@return [Object];T;0; @0;@F;Mi;N0;[[I"sym;T0; @0;[;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; @0;@F;Ao;B;CT;Dib;Ei;!@;"I"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; ; F; ;,;;;I"Module#class_variables;F;[[@0;[[@$i ;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;H ;II" overload;F;J0;;1;K0;#I""class_variables(inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @O;[;I"@return [Array];T;0; @O;@F;Mi;N0;[[I" inherit;TI" true;T; @O;[;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; @O;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"!Module#remove_class_variable;F;[[I" name;T0;[[@$i ;T;:remove_class_variable;0;[;{;IC;"Removes the definition of the sym, returning that constant's value. class Dummy @@var = 99 puts @@var remove_class_variable(:@@var) p(defined? @@var) end produces: 99 nil ;T;[o;H ;II" overload;F;J0;;2;K0;#I"remove_class_variable(sym);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @n;[;I"@return [Object];T;0; @n;@F;Mi;N0;[[I"sym;T0; @n;[;I"Removes the definition of the sym, returning that constant's value. class Dummy @@var = 99 puts @@var remove_class_variable(:@@var) p(defined? @@var) end produces: 99 nil @overload remove_class_variable(sym) @return [Object];T;0; @n;@F;Ao;B;CT;Di ;Ei ;!@;"I""VALUE 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) { not_defined: rb_name_err_raise("class variable %1$s not defined for %2$s", mod, name); } 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)); } goto not_defined; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#class_variable_get;F;[[I"iv;T0;[[@i ;T;:class_variable_get;0;[;{;IC;":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 ;T;[o;H ;II" overload;F;J0;;3;K0;#I"class_variable_get(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" symbol;T0; @o;H ;II" overload;F;J0;;3;K0;#I"class_variable_get(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE rb_mod_cvar_get(VALUE obj, VALUE iv) { ID id = id_for_var(obj, iv, a, 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; ; F; ;,;;;I"Module#class_variable_set;F;[[I"iv;T0[I"val;T0;[[@i6 ;T;:class_variable_set;0;[;{;IC;"LSets 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 ;T;[o;H ;II" overload;F;J0;;4;K0;#I"$class_variable_set(symbol, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"obj;T0; @o;H ;II" overload;F;J0;;4;K0;#I"$class_variable_set(string, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" string;T0[I"obj;T0; @;[;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; @;@F;Ao;B;CT;Di" ;Ei4 ;!@;"I"static VALUE rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val) { ID id = id_for_var(obj, iv, a, class); if (!id) id = rb_intern_str(iv); rb_cvar_set(obj, id, val); return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"#Module#class_variable_defined?;F;[[I"iv;T0;[[@iO ;T;:class_variable_defined?;0;[;{;IC;" 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;T;[o;H ;II" overload;F;J0;;5;K0;#I"$class_variable_defined?(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" symbol;T0; @o;H ;II" overload;F;J0;;5;K0;#I"$class_variable_defined?(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;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; @;@F;Ao;B;CT;Di? ;EiM ;Mi;!@;"I"static VALUE rb_mod_cvar_defined(VALUE obj, VALUE iv) { ID id = id_for_var(obj, iv, a, class); if (!id) { return Qfalse; } return rb_cvar_defined(obj, id); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#public_constant;F;[[@0;[[@$i ;T;:public_constant;0;[;{;IC;"/Makes a list of existing constants public. ;T;[o;H ;II" overload;F;J0;;6;K0;#I"!public_constant(symbol, ...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @;[;I"XMakes a list of existing constants public. @overload public_constant(symbol, ...);T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Module#private_constant;F;[[@0;[[@$i ;T;:private_constant;0;[;{;IC;"0Makes a list of existing constants private. ;T;[o;H ;II" overload;F;J0;;7;K0;#I""private_constant(symbol, ...);T;IC;";T;[;[;I";T;0; @8;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @8;[;I"ZMakes a list of existing constants private. @overload private_constant(symbol, ...);T;0; @8;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Module#deprecate_constant;F;[[@0;[[@$i ;T;:deprecate_constant;0;[;{;IC;"3Makes a list of existing constants deprecated. ;T;[o;H ;II" overload;F;J0;;8;K0;#I"$deprecate_constant(symbol, ...);T;IC;";T;[;[;I";T;0; @S;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @S;[;I"_Makes a list of existing constants deprecated. @overload deprecate_constant(symbol, ...);T;0; @S;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Module#singleton_class?;F;[;[[@ig ;T;:singleton_class?;0;[;{;IC;"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;T;[o;H ;II" overload;F;J0;;9;K0;#I"singleton_class?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n;[;I"@return [Boolean];T;0; @n;@F;Mi;N0;[; @n;[;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; @n;@F;Ao;B;CT;DiZ ;Eid ;Mi;!@;"I"static VALUE rb_mod_singleton_p(VALUE klass) { if (RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#autoload;F;[[I"sym;T0[I" file;T0;[[@] in;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;H ;II" overload;F;J0;;;K0;#I"autoload(module, filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;I"ERegisters _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; @;@F;Ao;B;CT;Di`;Eik;!@;"I"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; ; F; ;,;;;I"Module#autoload?;F;[[I"sym;T0;[[@] i;T;;;0;[;{;IC;"Returns _filename_ to be loaded if _name_ is registered as +autoload+ in the namespace of _mod_. module A end A.autoload(:B, "b") A.autoload?(:B) #=> "b";T;[o;H ;II" overload;F;J0;;;K0;#I"autoload?(name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I" name;T0; @;[;I"Returns _filename_ to be loaded if _name_ is registered as +autoload+ in the namespace of _mod_. module A end A.autoload(:B, "b") A.autoload?(:B) #=> "b" @overload autoload?(name) @return [String, nil];T;0; @;@F;Ao;B;CT;Dix;Ei;Mi;!@;"I"static VALUE rb_mod_autoload_p(VALUE mod, VALUE sym) { ID id = rb_check_id(&sym); if (!id) { return Qnil; } return rb_autoload_p(mod, id); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#instance_method;F;[[I"vid;T0;[[@i1;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;H ;II" overload;F;J0;;:;K0;#I"instance_method(symbol);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" symbol;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei-;!@;"I"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(mod, Qundef, id, rb_cUnboundMethod, FALSE); };T;#I"static VALUE;T;$To; ; F; ;,;;;I""Module#public_instance_method;F;[[I"vid;T0;[[@iB;T;:public_instance_method;0;[;{;IC;"?Similar to _instance_method_, searches public method only. ;T;[o;H ;II" overload;F;J0;;;;K0;#I"#public_instance_method(symbol);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" symbol;T0; @;[;I"jSimilar to _instance_method_, searches public method only. @overload public_instance_method(symbol);T;0; @;@F;Ao;B;CT;Di;;Ei>;!@;"I"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(mod, Qundef, id, rb_cUnboundMethod, TRUE); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#define_method;F;[[@0;[[@io;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. 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!" } end class B < A define_method(:barney, instance_method(:fred)) end a = B.new a.barney a.wilma a.create_method(:betty) { p self } a.betty produces: In Fred Charge it! # ;T;[o;H ;II" overload;F;J0;;<;K0;#I""define_method(symbol, method);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" symbol;T0[I" method;T0; @o;H ;II" overload;F;J0;;<;K0;#I"define_method(symbol);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[[I" symbol;T0; @;[;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. 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!" } end class B < A define_method(:barney, instance_method(:fred)) end a = B.new a.barney a.wilma a.create_method(:betty) { p self } a.betty produces: In Fred Charge it! # @overload define_method(symbol, method) @overload define_method(symbol) @yield [];T;0; @;@F;Ao;B;CT;DiL;Eil;!@;"I"g 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) { #if PROC_NEW_REQUIRES_BLOCK body = rb_block_lambda(); #else const rb_execution_context_t *ec = GET_EC(); VALUE block_handler = rb_vm_frame_block_handler(ec->cfp); if (block_handler == VM_BLOCK_HANDLER_NONE) rb_raise(rb_eArgError, proc_without_block); switch (vm_block_handler_type(block_handler)) { case block_handler_type_proc: body = VM_BH_TO_PROC(block_handler); break; case block_handler_type_symbol: body = rb_sym_to_proc(VM_BH_TO_SYMBOL(block_handler)); break; case block_handler_type_iseq: case block_handler_type_ifunc: body = rb_vm_make_lambda(ec, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc); } #endif } 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)", 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; ; F; ;,;;;I"Module#module_exec;F;[[@0;[[@&i;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;H ;II" overload;F;J0;;=;K0;#I"module_exec(arg...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" var...;T; @$o;L ;II" return;F;JI";T;0;K[I" Object;T; @$;[;I"%@yield [var...] @return [Object];T;0; @$;@F;Mi;N0;[[I" arg...;T0; @$o;H ;II" overload;F;J0;:class_exec;K0;#I"class_exec(arg...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" var...;T; @$o;L ;II" return;F;JI";T;0;K[I" Object;T; @$;[;I"%@yield [var...] @return [Object];T;0; @$;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"wVALUE rb_mod_module_exec(int argc, const VALUE *argv, VALUE mod) { return yield_under(mod, mod, argc, argv); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#class_exec;F;[[@0;[[@&i;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;H ;II" overload;F;J0;;=;K0;#I"module_exec(arg...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" var...;T; @[o;L ;II" return;F;JI";T;0;K[I" Object;T; @[;[;I"%@yield [var...] @return [Object];T;0; @[;@F;Mi;N0;[[I" arg...;T0; @[o;H ;II" overload;F;J0;;>;K0;#I"class_exec(arg...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" var...;T; @[o;L ;II" return;F;JI";T;0;K[I" Object;T; @[;[;I"%@yield [var...] @return [Object];T;0; @[;@F;Mi;N0;[[I" arg...;T0; @[;[;@W;0; @[;@F;Ao;B;CT;Di;Ei;!@;"I"wVALUE rb_mod_module_exec(int argc, const VALUE *argv, VALUE mod) { return yield_under(mod, mod, argc, argv); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#module_eval;F;[[@0;[[@&i;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;H ;II" overload;F;J0;:class_eval;K0;#I"/class_eval(string [, filename [, lineno]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I""string[, filename [, lineno]];T0; @o;H ;II" overload;F;J0;;@;K0;#I"class_eval;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"mod;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I""@yield [mod] @return [Object];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;?;K0;#I"0module_eval(string [, filename [, lineno]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I""string[, filename [, lineno]];T0; @o;H ;II" overload;F;J0;;?;K0;#I"module_eval;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"mod;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I""@yield [mod] @return [Object];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"yVALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod) { return specific_eval(argc, argv, mod, mod); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#class_eval;F;[[@0;[[@&i;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;H ;II" overload;F;J0;;@;K0;#I"/class_eval(string [, filename [, lineno]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I""string[, filename [, lineno]];T0; @o;H ;II" overload;F;J0;;@;K0;#I"class_eval;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"mod;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I""@yield [mod] @return [Object];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;?;K0;#I"0module_eval(string [, filename [, lineno]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I""string[, filename [, lineno]];T0; @o;H ;II" overload;F;J0;;?;K0;#I"module_eval;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"mod;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I""@yield [mod] @return [Object];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"yVALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod) { return specific_eval(argc, argv, mod, mod); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Module#remove_method;F;[[@0;[[@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;H ;II" overload;F;J0;;A;K0;#I"remove_method(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @2;[;I"@return [self];T;0; @2;@F;Mi;N0;[[I" symbol;T0; @2o;H ;II" overload;F;J0;;A;K0;#I"remove_method(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @2;[;I"@return [self];T;0; @2;@F;Mi;N0;[[I" string;T0; @2;[;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; @2;@F;Ao;B;CT;Di;Ei;!@;"I".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; ; F; ;,;;;I"Module#undef_method;F;[[@0;[[@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;H ;II" overload;F;J0;;B;K0;#I"undef_method(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @_;[;I"@return [self];T;0; @_;@F;Mi;N0;[[I" symbol;T0; @_o;H ;II" overload;F;J0;;B;K0;#I"undef_method(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @_;[;I"@return [self];T;0; @_;@F;Mi;N0;[[I" string;T0; @_;[;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; @_;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#alias_method;F;[[I" newname;T0[I" oldname;T0;[[@it;T;:alias_method;0;[;{;IC;"aMakes 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 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;H ;II" overload;F;J0;;C;K0;#I"%alias_method(new_name, old_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[[I" new_name;T0[I" old_name;T0; @;[;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 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) @return [self];T;0; @;@F;Ao;B;CT;Di^;Eiq;!@;"I"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); } rb_alias(mod, rb_to_id(newname), oldid); return mod; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#public;F;[[@0;[[@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. ;T;[o;H ;II" overload;F;J0;;;K0;#I" public;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"public(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @o;H ;II" overload;F;J0;;;K0;#I"public(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @;[;I"IWith 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. @overload public @return [self] @overload public(symbol, ...) @return [self] @overload public(string, ...) @return [self];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#protected;F;[[@0;[[@i;T;:protected;0;[;{;IC;"jWith 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. 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;H ;II" overload;F;J0;;D;K0;#I"protected;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;D;K0;#I"protected(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @o;H ;II" overload;F;J0;;D;K0;#I"protected(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @;[;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. 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 [self] @overload protected(symbol, ...) @return [self] @overload protected(string, ...) @return [self];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#private;F;[[@0;[[@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. 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;H ;II" overload;F;J0;;;K0;#I" private;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @+;[;I"@return [self];T;0; @+;@F;Mi;N0;[; @+o;H ;II" overload;F;J0;;;K0;#I"private(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @+;[;I"@return [self];T;0; @+;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @+o;H ;II" overload;F;J0;;;K0;#I"private(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @+;[;I"@return [self];T;0; @+;@F;Mi;N0;[[I" string;T0[I"...;T0; @+;[;I"+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. 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 [self] @overload private(symbol, ...) @return [self] @overload private(string, ...) @return [self];T;0; @+;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#module_function;F;[[@0;[[@ia;T;:module_function;0;[;{;IC;"CCreates 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. 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;H ;II" overload;F;J0;;E;K0;#I"!module_function(symbol, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @i;[;I"@return [self];T;0; @i;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @io;H ;II" overload;F;J0;;E;K0;#I"!module_function(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @i;[;I"@return [self];T;0; @i;@F;Mi;N0;[[I" string;T0[I"...;T0; @i;[;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. 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(symbol, ...) @return [self] @overload module_function(string, ...) @return [self];T;0; @i;@F;Ao;B;CT;Di;;Ei_;!@;"I"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 module; } 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); } return module; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#method_defined?;F;[[@0;[[@iG;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;H ;II" overload;F;J0;;F;K0;#I"*method_defined?(symbol, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" symbol;T0[I" inherit;TI" true;T; @o;H ;II" overload;F;J0;;F;K0;#I"*method_defined?(string, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" string;T0[I" inherit;TI" true;T; @;[;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; @;@F;Ao;B;CT;Di#;EiE;Mi;!@;"I"static VALUE rb_mod_method_defined(int argc, VALUE *argv, VALUE mod) { rb_method_visibility_t visi = check_definition_visibility(mod, argc, argv); return (visi == METHOD_VISI_PUBLIC || visi == METHOD_VISI_PROTECTED) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""Module#public_method_defined?;F;[[@0;[[@ir;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;H ;II" overload;F;J0;;G;K0;#I"1public_method_defined?(symbol, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" symbol;T0[I" inherit;TI" true;T; @o;H ;II" overload;F;J0;;G;K0;#I"1public_method_defined?(string, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" string;T0[I" inherit;TI" true;T; @;[;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; @;@F;Ao;B;CT;DiT;Eip;Mi;!@;"I"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; ; F; ;,;;;I"#Module#private_method_defined?;F;[[@0;[[@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;H ;II" overload;F;J0;;H;K0;#I"2private_method_defined?(symbol, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" symbol;T0[I" inherit;TI" true;T; @o;H ;II" overload;F;J0;;H;K0;#I"2private_method_defined?(string, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" string;T0[I" inherit;TI" true;T; @;[;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; @;@F;Ao;B;CT;Dix;Ei;Mi;!@;"I"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; ; F; ;,;;;I"%Module#protected_method_defined?;F;[[@0;[[@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;H ;II" overload;F;J0;;I;K0;#I"4protected_method_defined?(symbol, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @3;[;I"@return [Boolean];T;0; @3;@F;Mi;N0;[[I" symbol;T0[I" inherit;TI" true;T; @3o;H ;II" overload;F;J0;;I;K0;#I"4protected_method_defined?(string, inherit=true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @3;[;I"@return [Boolean];T;0; @3;@F;Mi;N0;[[I" string;T0[I" inherit;TI" true;T; @3;[;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; @3;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Module#public_class_method;F;[[@0;[[@i;T;:public_class_method;0;[;{;IC;"_Makes a list of existing class methods public. String arguments are converted to symbols. ;T;[o;H ;II" overload;F;J0;;J;K0;#I"%public_class_method(symbol, ...);T;IC;";T;[;[;I";T;0; @f;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @fo;H ;II" overload;F;J0;;J;K0;#I"%public_class_method(string, ...);T;IC;";T;[;[;I";T;0; @f;@F;Mi;N0;[[I" string;T0[I"...;T0; @f;[;I"Makes a list of existing class methods public. String arguments are converted to symbols. @overload public_class_method(symbol, ...) @overload public_class_method(string, ...);T;0; @f;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" Module#private_class_method;F;[[@0;[[@i;T;:private_class_method;0;[;{;IC;"MMakes existing class methods private. Often used to hide the default constructor new. String arguments are converted to symbols. 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;H ;II" overload;F;J0;;K;K0;#I"&private_class_method(symbol, ...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" symbol;T0[I"...;T0; @o;H ;II" overload;F;J0;;K;K0;#I"&private_class_method(string, ...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @;[;I"Makes existing class methods private. Often used to hide the default constructor new. String arguments are converted to symbols. 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, ...);T;0; @;@F;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;,;;;I"Module#include;F;[[@0;[[@i;T;: include;0;[;{;IC;"TInvokes Module.append_features on each parameter in reverse order. ;T;[o;H ;II" overload;F;J0;;L;K0;#I"include(module, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @;[;I"Invokes Module.append_features on each parameter in reverse order. @overload include(module, ...) @return [self];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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"); 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; ; F; ;,;;;I"Module#prepend;F;[[@0;[[@i;T;;R;0;[;{;IC;"UInvokes Module.prepend_features on each parameter in reverse order. ;T;[o;H ;II" overload;F;J0;;R;K0;#I"prepend(module, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @;[;I"Invokes Module.prepend_features on each parameter in reverse order. @overload prepend(module, ...) @return [self];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_mod_prepend(int argc, VALUE *argv, VALUE module) { int i; ID id_prepend_features, id_prepended; 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; ; F; ;,;;;I"Module#append_features;F;[[I" include;T0;[[@i;T;:append_features;0;[;{;IC;"iWhen 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;H ;II" overload;F;J0;;M;K0;#I"append_features(mod);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"mod;T0; @;[;I"When 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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#extend_object;F;[[I"obj;T0;[[@i;T;:extend_object;0;[;{;IC;"0Extends 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;H ;II" overload;F;J0;;N;K0;#I"extend_object(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"bExtends 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; @;@F;Ao;B;CT;Dik;Ei;!@;"I"pstatic VALUE rb_mod_extend_object(VALUE mod, VALUE obj) { rb_extend_object(obj, mod); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Module#prepend_features;F;[[I" prepend;T0;[[@i;T;:prepend_features;0;[;{;IC;"oWhen 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;H ;II" overload;F;J0;;O;K0;#I"prepend_features(mod);T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[[I"mod;T0; @%;[;I"When 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; @%;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Module#refine;F;[[I" klass;T0;[[@i;T;: refine;0;[;{;IC;"]Refine mod in the receiver. Returns a module, where refined methods are defined. ;T;[o;H ;II" overload;F;J0;;P;K0;#I"refine(mod);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @?;[;I"@yield [];T;0; @?;@F;Mi;N0;[[I"mod;T0; @?;[;I"|Refine mod in the receiver. Returns a module, where refined methods are defined. @overload refine(mod) @yield [];T;0; @?;@F;Ao;B;CT;Di;Ei;!@;"I"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_module_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; ; F; ;,;;;I"Module#using;F;[[I" module;T0;[[@i;T;: using;0;[;{;IC;"]Import class refinements from module into the current class or module definition. ;T;[o;H ;II" overload;F;J0;;Q;K0;#I"using(module);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @\;[;I"@return [self];T;0; @\;@F;Mi;N0;[; @\;[;I"Import class refinements from module into the current class or module definition. @overload using(module) @return [self];T;0; @\;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Module.used_modules;F;[;[[@i>;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;H ;II" overload;F;J0;;R;K0;#I"used_modules;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @y;[;I"@return [Array];T;0; @y;@F;Mi;N0;[; @y;[;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; @y;@F;Ao;B;CT;Di%;Ei<;!@;"I"Estatic VALUE rb_mod_s_used_modules(void) { 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; ; F; ;;;;I"Module.nesting;F;[;[[@iX;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;H ;II" overload;F;J0;;S;K0;#I" nesting;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiI;EiU;!@;"I">static VALUE rb_mod_nesting(void) { 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; ; F; ;;;;I"Module.constants;F;[[@0;[[@i;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;H ;II" overload;F;J0;;+;K0;#I"constants;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;+;K0;#I"constants(inherited);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"inherited;T0; @;[;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; @;@F;Ao;B;CT;Dii;Ei};!@;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@9;h;.[;[[@i[@i[@i+;T;: Module;;0;;;[;{;IC;"m********************************************************************* 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;[;[;I"o********************************************************************* 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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Module;F;1@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;H ;II" overload;F;J0;;V;K0;#I"allocate();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di,;Ei?;!@;"I"static VALUE rb_class_alloc(VALUE klass) { VALUE obj; rb_alloc_func_t allocator; if (RCLASS_SUPER(klass) == 0 && klass != rb_cBasicObject) { rb_raise(rb_eTypeError, "can't instantiate uninitialized class"); } if (FL_TEST(klass, FL_SINGLETON)) { rb_raise(rb_eTypeError, "can't create instance of singleton class"); } allocator = rb_get_alloc_func(klass); if (!allocator) { rb_undefined_alloc(klass); } RUBY_DTRACE_CREATE_HOOK(OBJECT, rb_class2name(klass)); obj = (*allocator)(klass); if (rb_obj_class(obj) != rb_class_real(klass)) { rb_raise(rb_eTypeError, "wrong instance allocation"); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Class#new;F;[[@0;[[@i;T;; ;0;[;{;IC;"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. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Diy;Ei;!@;"I"static VALUE rb_class_s_new(int argc, const VALUE *argv, VALUE klass) { VALUE obj; obj = rb_class_alloc(klass); rb_obj_call_init(obj, argc, argv); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Class#initialize;F;[[@0;[[@i ;T;;;0;[;{;IC;"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. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(super_class=Object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Class;T; @7;[;I"@return [Class];T;0; @7;@F;Mi;N0;[[I"super_class;TI" Object;T; @7o;H ;II" overload;F;J0;; ;K0;#I"new(super_class=Object);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"mod;T; @7o;L ;II" return;F;JI";T;0;K[I" Class;T; @7;[;I"!@yield [mod] @return [Class];T;0; @7;@F;Mi;N0;[[I"super_class;TI" Object;T; @7;[;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; @7;@F;Ao;B;CT;Di;Ei ;!@;"I"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(klass); return klass; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Class#superclass;F;[;[[@i;T;:superclass;0;[;{;IC;"fReturns 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 ;T;[o;H ;II" overload;F;J0;;W;K0;#I"superclass;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @k;[;I"@return [nil];T;0; @k;@F;Mi;N0;[; @k;[;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; @k;@F;Ao;B;CT;Di;Ei;!@;"I"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;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i_[@i[@i,;T;;|;;0;;;[;{;IC;"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;[;[;I" 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;Ao;B;CT;Di_;Ei;Mi;!@;I" Class;F;1@@o;9;[[@ix;F;:NIL;;;;;;[;{;IC;"An obsolete alias of +nil+ ;T;[;[;I" An obsolete alias of +nil+ ;T;0; @;@F;Ao;B;CT;Diu;Eiv;!@;I"NIL;F;final); define_final0(wmap, w->final); st_update(w->obj2wmap, (st_data_t)orig, wmap_aset_update, wmap); st_insert(w->wmap2obj, (st_data_t)wmap, (st_data_t)orig); return nonspecial_obj_id(orig); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ObjectSpace::WeakMap#[];F;[[I" wmap;T0;[[@i";T;;;0;[;{;IC;"wmap2obj, (st_data_t)wmap, &data)) return Qnil; obj = (VALUE)data; if (!is_id_value(objspace, obj)) return Qnil; if (!is_live_object(objspace, obj)) return Qnil; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""ObjectSpace::WeakMap#include?;F;[[I"key;T0;[[@i";T;;U;0;[;{;IC;"*Returns +true+ if +key+ is registered;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"*Returns +true+ if +key+ is registered;T;0; @;@F;Ao;B;CT;Di";Ei";Mi;!@;"I"rstatic VALUE wmap_has_key(VALUE self, VALUE key) { return NIL_P(wmap_aref(self, key)) ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!ObjectSpace::WeakMap#member?;F;[[I"key;T0;[[@i";T;;;0;[;{;IC;"*Returns +true+ if +key+ is registered;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;@F;Ao;B;CT;Di";Ei";Mi;!@;"I"rstatic VALUE wmap_has_key(VALUE self, VALUE key) { return NIL_P(wmap_aref(self, key)) ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ObjectSpace::WeakMap#key?;F;[[I"key;T0;[[@i";T;;;0;[;{;IC;"*Returns +true+ if +key+ is registered;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;@F;Ao;B;CT;Di";Ei";Mi;!@;"I"rstatic VALUE wmap_has_key(VALUE self, VALUE key) { return NIL_P(wmap_aref(self, key)) ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!ObjectSpace::WeakMap#inspect;F;[;[[@i ";T;;i;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"static VALUE wmap_inspect(VALUE self) { VALUE str; VALUE c = rb_class_name(CLASS_OF(self)); struct weakmap *w; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void *)self); if (w->wmap2obj) { st_foreach(w->wmap2obj, wmap_inspect_i, str); } RSTRING_PTR(str)[0] = '#'; rb_str_cat2(str, ">"); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ObjectSpace::WeakMap#each;F;[;[[@i*";T;;;0;[;{;IC;"AIterates over keys and objects in a weakly referenced object ;T;[;[;I"AIterates over keys and objects in a weakly referenced object;T;0; @&;@F;Ao;B;CT;Di)";Ei)";!@;"I"static VALUE wmap_each(VALUE self) { struct weakmap *w; rb_objspace_t *objspace = &rb_objspace; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); st_foreach(w->wmap2obj, wmap_each_i, (st_data_t)objspace); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"#ObjectSpace::WeakMap#each_pair;F;[;[[@i*";T;;;0;[;{;IC;"AIterates over keys and objects in a weakly referenced object ;T;[;[;@0;0; @4;@F;Ao;B;CT;Di)";Ei)";!@;"I"static VALUE wmap_each(VALUE self) { struct weakmap *w; rb_objspace_t *objspace = &rb_objspace; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); st_foreach(w->wmap2obj, wmap_each_i, (st_data_t)objspace); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""ObjectSpace::WeakMap#each_key;F;[;[[@iA";T;;;0;[;{;IC;"AIterates over keys and objects in a weakly referenced object ;T;[;[;I"AIterates over keys and objects in a weakly referenced object;T;0; @A;@F;Ao;B;CT;Di@";Ei@";!@;"I"static VALUE wmap_each_key(VALUE self) { struct weakmap *w; rb_objspace_t *objspace = &rb_objspace; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); st_foreach(w->wmap2obj, wmap_each_key_i, (st_data_t)objspace); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"$ObjectSpace::WeakMap#each_value;F;[;[[@iX";T;;;0;[;{;IC;"AIterates over keys and objects in a weakly referenced object ;T;[;[;I"AIterates over keys and objects in a weakly referenced object;T;0; @O;@F;Ao;B;CT;DiW";EiW";!@;"I"static VALUE wmap_each_value(VALUE self) { struct weakmap *w; rb_objspace_t *objspace = &rb_objspace; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); st_foreach(w->wmap2obj, wmap_each_value_i, (st_data_t)objspace); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ObjectSpace::WeakMap#keys;F;[;[[@iq";T;;;0;[;{;IC;"AIterates over keys and objects in a weakly referenced object ;T;[;[;I"AIterates over keys and objects in a weakly referenced object;T;0; @];@F;Ao;B;CT;Dip";Eip";!@;"I"3static VALUE wmap_keys(VALUE self) { struct weakmap *w; struct wmap_iter_arg args; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); args.objspace = &rb_objspace; args.value = rb_ary_new(); st_foreach(w->wmap2obj, wmap_keys_i, (st_data_t)&args); return args.value; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" ObjectSpace::WeakMap#values;F;[;[[@i";T;;;0;[;{;IC;"CIterates over values and objects in a weakly referenced object ;T;[;[;I"CIterates over values and objects in a weakly referenced object;T;0; @k;@F;Ao;B;CT;Di";Ei";!@;"I"7static VALUE wmap_values(VALUE self) { struct weakmap *w; struct wmap_iter_arg args; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); args.objspace = &rb_objspace; args.value = rb_ary_new(); st_foreach(w->wmap2obj, wmap_values_i, (st_data_t)&args); return args.value; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ObjectSpace::WeakMap#size;F;[;[[@i";T;;;0;[;{;IC;"-Returns the number of referenced objects ;T;[;[;I"-Returns the number of referenced objects;T;0; @y;@F;Ao;B;CT;Di";Ei";!@;"I"static VALUE wmap_size(VALUE self) { struct weakmap *w; st_index_t n; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); n = w->wmap2obj->num_entries; #if SIZEOF_ST_INDEX_T <= SIZEOF_LONG return ULONG2NUM(n); #else return ULL2NUM(n); #endif };T;#I"static VALUE;T;$To; ; F; ;,;;;I" ObjectSpace::WeakMap#length;F;[;[[@i";T;;;0;[;{;IC;"-Returns the number of referenced objects ;T;[;[;@;0; @;@F;Ao;B;CT;Di";Ei";!@;"I"static VALUE wmap_size(VALUE self) { struct weakmap *w; st_index_t n; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); n = w->wmap2obj->num_entries; #if SIZEOF_ST_INDEX_T <= SIZEOF_LONG return ULONG2NUM(n); #else return ULL2NUM(n); #endif };T;#I"static VALUE;T;$To; ; F; ;,;;;I""ObjectSpace::WeakMap#finalize;F;[[I" objid;T0;[[@i!;T;: finalize;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di!;Ei!;!@;"I"/static VALUE wmap_finalize(VALUE self, VALUE objid) { st_data_t orig, wmap, data; VALUE obj, *rids, i, size; struct weakmap *w; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); /* Get reference from object id. */ obj = obj_id_to_ref(objid); /* obj is original referenced object and/or weak reference. */ orig = (st_data_t)obj; if (st_delete(w->obj2wmap, &orig, &data)) { rids = (VALUE *)data; size = *rids++; for (i = 0; i < size; ++i) { wmap = (st_data_t)rids[i]; st_delete(w->wmap2obj, &wmap, NULL); } ruby_sized_xfree((VALUE *)data, (size + 1) * sizeof(VALUE)); } wmap = (st_data_t)obj; if (st_delete(w->wmap2obj, &wmap, &orig)) { wmap = (st_data_t)obj; st_update(w->obj2wmap, orig, wmap_final_func, wmap); } return self; };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[@C;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i'[@i`';T;: WeakMap;;0;;;[;{;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;Ao;B;CT;Di';Ei';Mi;!o;2 ;30;40;50;:ObjectSpace;!@;7@;F0;I"ObjectSpace::WeakMap;F;1@ "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;H ;II" overload;F;J0;;^;K0;#I"trace_object_allocations;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I"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; ; T; ;;;;I")ObjectSpace.trace_object_allocations;F;@;@;T;;^;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;H ;II" overload;F;J0;;^;K0;#I"trace_object_allocations;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"/ObjectSpace#trace_object_allocations_start;F;[;[[@i;T;:#trace_object_allocations_start;0;[;{;IC;"'Starts tracing object allocations. ;T;[o;H ;II" overload;F;J0;;_;K0;#I"#trace_object_allocations_start;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"QStarts tracing object allocations. @overload trace_object_allocations_start ;T;0; @;@F;N0;!@;"I"_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); rb_gc_register_mark_object(arg->newobj_trace); arg->freeobj_trace = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_FREEOBJ, freeobj_i, arg); rb_gc_register_mark_object(arg->freeobj_trace); } rb_tracepoint_enable(arg->newobj_trace); rb_tracepoint_enable(arg->freeobj_trace); } return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"/ObjectSpace.trace_object_allocations_start;F;@;@;T;;_;0;@;{;IC;"'Starts tracing object allocations.;T;[o;H ;II" overload;F;J0;;_;K0;#I"#trace_object_allocations_start;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"SStarts tracing object allocations. @overload trace_object_allocations_start;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I".ObjectSpace#trace_object_allocations_stop;F;[;[[@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;H ;II" overload;F;J0;;`;K0;#I""trace_object_allocations_stop;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;N0;!@;"I".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) { rb_tracepoint_disable(arg->newobj_trace); rb_tracepoint_disable(arg->freeobj_trace); } return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I".ObjectSpace.trace_object_allocations_stop;F;@ ;@ ;T;;`;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;H ;II" overload;F;J0;;`;K0;#I""trace_object_allocations_stop;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"/ObjectSpace#trace_object_allocations_clear;F;[;[[@i;T;:#trace_object_allocations_clear;0;[;{;IC;"(Clear recorded tracing information. ;T;[o;H ;II" overload;F;J0;;a;K0;#I"#trace_object_allocations_clear;T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[; @-;[;I"RClear recorded tracing information. @overload trace_object_allocations_clear ;T;0; @-;@F;N0;!@;"I"`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; ; T; ;;;;I"/ObjectSpace.trace_object_allocations_clear;F;@/;@0;T;;a;0;@2;{;IC;"(Clear recorded tracing information.;T;[o;H ;II" overload;F;J0;;a;K0;#I"#trace_object_allocations_clear;T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[; @B;[;I"TClear recorded tracing information. @overload trace_object_allocations_clear;T;0; @B;@F;Ao;B;CT;Di;Ei;Mi;!@;"@@;#@A;$To; ; F; ;,;;;I"5ObjectSpace#trace_object_allocations_debug_start;F;[;[[@i<;T;:)trace_object_allocations_debug_start;0;[;{;IC;" ;T;[;[;I";F;0; @R;@F;N0;!@;"I"-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; ; T; ;;;;I"5ObjectSpace.trace_object_allocations_debug_start;F;@T;@U;T;;b;0;@W;{;IC;" ;T;[;[;@;0; @_;Mi;!@;"@];#@^;$To; ; F; ;,;;;I"&ObjectSpace#allocation_sourcefile;F;[[I"obj;T0;[[@ia;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;H ;II" overload;F;J0;;c;K0;#I""allocation_sourcefile(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @e;[;I"@return [String];T;0; @e;@F;Mi;N0;[[I" object;T0; @e;[;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; @e;@F;N0;!@;"I"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; ; T; ;;;;I"&ObjectSpace.allocation_sourcefile;F;@g;@j;T;;c;0;@l;{;IC;"Returns the source file origin from the given +object+. See ::trace_object_allocations for more information and examples.;T;[o;H ;II" overload;F;J0;;c;K0;#I""allocation_sourcefile(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiZ;Ei`;Mi;!@;"@;#@;$To; ; F; ;,;;;I"&ObjectSpace#allocation_sourceline;F;[[I"obj;T0;[[@iu;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;H ;II" overload;F;J0;;d;K0;#I""allocation_sourceline(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"&ObjectSpace.allocation_sourceline;F;@;@;T;;d;0;@;{;IC;"Returns the original line from source for from the given +object+. See ::trace_object_allocations for more information and examples.;T;[o;H ;II" overload;F;J0;;d;K0;#I""allocation_sourceline(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Din;Eit;Mi;!@;"@;#@;$To; ; F; ;,;;;I"&ObjectSpace#allocation_class_path;F;[[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;H ;II" overload;F;J0;;e;K0;#I""allocation_class_path(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"&ObjectSpace.allocation_class_path;F;@;@;T;;e;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;H ;II" overload;F;J0;;e;K0;#I""allocation_class_path(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"%ObjectSpace#allocation_method_id;F;[[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;H ;II" overload;F;J0;;f;K0;#I"!allocation_method_id(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"%ObjectSpace.allocation_method_id;F;@;@ ;T;;f;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;H ;II" overload;F;J0;;f;K0;#I"!allocation_method_id(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @";[;I"@return [String];T;0; @";@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@ ;#@!;$To; ; F; ;,;;;I"&ObjectSpace#allocation_generation;F;[[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;H ;II" overload;F;J0;;g;K0;#I""allocation_generation(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @9;[;I"@return [Integer, nil];T;0; @9;@F;Mi;N0;[[I" object;T0; @9;[;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; @9;@F;N0;!@;"I"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; ; T; ;;;;I"&ObjectSpace.allocation_generation;F;@;;@>;T;;g;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;H ;II" overload;F;J0;;g;K0;#I""allocation_generation(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @X;[;I"@return [Integer, nil];T;0; @X;@F;Mi;N0;[[I" object;T0; @X;[;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; @X;@F;Ao;B;CT;Di;Ei;Mi;!@;"@V;#@W;$To; ; F; ;,;;;I"ObjectSpace#memsize_of;F;[[I"obj;T0;[[I"ext/objspace/objspace.c;Ti,;T;:memsize_of;0;[;{;IC;"?Return consuming memory size of obj. 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;H ;II" overload;F;J0;;h;K0;#I"memsize_of(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @p;[;I"@return [Integer];T;0; @p;@F;Mi;N0;[[I"obj;T0; @p;[;I"nReturn consuming memory size of obj. 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; @p;@F;N0;!@;"I"gstatic VALUE memsize_of_m(VALUE self, VALUE obj) { return SIZET2NUM(rb_obj_memsize_of(obj)); };T;#I"static VALUE;T;$To; ; T; ;;;;I"ObjectSpace.memsize_of;F;@r;@u;T;;h;0;@x;{;IC;"?Return consuming memory size of obj. 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;H ;II" overload;F;J0;;h;K0;#I"memsize_of(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"oReturn consuming memory size of obj. 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; @;@F;Ao;B;CT;Di;Ei);Mi;!@;"@;#@;$To; ; F; ;,;;;I"ObjectSpace#memsize_of_all;F;[[@0;[[@wim;T;:memsize_of_all;0;[;{;IC;"Return consuming memory size of all living objects. 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;H ;II" overload;F;J0;;i;K0;#I"memsize_of_all([klass]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" [klass];T0; @;[;I"Return consuming memory size of all living objects. 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;N0;!@;"I"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); } rb_objspace_each_objects(total_i, &data); return SIZET2NUM(data.total); };T;#I"static VALUE;T;$To; ; T; ;;;;I"ObjectSpace.memsize_of_all;F;@;@;T;;i;0;@;{;IC;"Return consuming memory size of all living objects. 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;H ;II" overload;F;J0;;i;K0;#I"memsize_of_all([klass]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" [klass];T0; @;[;I"Return consuming memory size of all living objects. 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;Ao;B;CT;DiQ;Eij;Mi;!@;"@;#@;$To; ; F; ;,;;;I"#ObjectSpace#count_objects_size;F;[[@0;[[@wi;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;H ;II" overload;F;J0;;j;K0;#I"&count_objects_size([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"-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; } rb_objspace_each_objects(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; ; T; ;;;;I"#ObjectSpace.count_objects_size;F;@;@;T;;j;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;H ;II" overload;F;J0;;j;K0;#I"&count_objects_size([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"ObjectSpace#count_symbols;F;[[@0;[[@wi,;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;H ;II" overload;F;J0;;k;K0;#I"!count_symbols([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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(); rb_objspace_each_objects(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; ; T; ;;;;I"ObjectSpace.count_symbols;F;@;@;T;;k;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;H ;II" overload;F;J0;;k;K0;#I"!count_symbols([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @+;[;I"@return [Hash];T;0; @+;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei);Mi;!@;"@);#@*;$To; ; F; ;,;;;I"ObjectSpace#count_nodes;F;[[@0;[[@wid;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;H ;II" overload;F;J0;;l;K0;#I"count_nodes([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @B;[;I"@return [Hash];T;0; @B;@F;Mi;N0;[[I"[result_hash];T0; @B;[;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; @B;@F;N0;!@;"I" 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; } rb_objspace_each_objects(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;H ;II" overload;F;J0;;l;K0;#I"count_nodes([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @_;[;I"@return [Hash];T;0; @_;@F;Mi;N0;[[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;Ao;B;CT;DiM;Eia;Mi;!@;"@];#@^;$To; ; F; ;,;;;I"$ObjectSpace#count_tdata_objects;F;[[@0;[[@wi%;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;H ;II" overload;F;J0;;m;K0;#I"'count_tdata_objects([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @v;[;I"@return [Hash];T;0; @v;@F;Mi;N0;[[I"[result_hash];T0; @v;[;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; @v;@F;N0;!@;"I"static VALUE count_tdata_objects(int argc, VALUE *argv, VALUE self) { VALUE hash = setup_hash(argc, argv); rb_objspace_each_objects(cto_i, (void *)hash); return hash; };T;#I"static VALUE;T;$To; ; T; ;;;;I"$ObjectSpace.count_tdata_objects;F;@x;@z;T;;m;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;H ;II" overload;F;J0;;m;K0;#I"'count_tdata_objects([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I"[result_hash];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei";Mi;!@;"@;#@;$To; ; F; ;,;;;I"$ObjectSpace#count_imemo_objects;F;[[@0;[[@wif;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;H ;II" overload;F;J0;;n;K0;#I"'count_imemo_objects([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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_none"); 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_parser_strterm"); } rb_objspace_each_objects(count_imemo_objects_i, (void *)hash); return hash; };T;#I"static VALUE;T;$To; ; T; ;;;;I"$ObjectSpace.count_imemo_objects;F;@;@;T;;n;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;H ;II" overload;F;J0;;n;K0;#I"'count_imemo_objects([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiJ;Eic;Mi;!@;"@;#@;$To; ; F; ;,;;;I"'ObjectSpace#reachable_objects_from;F;[[I"obj;T0;[[@wi;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;H ;II" overload;F;J0;;o;K0;#I" reachable_objects_from(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"static VALUE reachable_objects_from(VALUE self, VALUE obj) { if (rb_objspace_markable_object_p(obj)) { VALUE ret = rb_ary_new(); struct rof_data data; if (rb_typeddata_is_kind_of(obj, &iow_data_type)) { obj = (VALUE)DATA_PTR(obj); } data.refs = st_init_numtable(); data.internals = rb_ary_new(); rb_objspace_reachable_objects_from(obj, reachable_object_from_i, &data); st_foreach(data.refs, collect_values, (st_data_t)ret); return ret; } else { return Qnil; } };T;#I"static VALUE;T;$To; ; T; ;;;;I"'ObjectSpace.reachable_objects_from;F;@;@;T;;o;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;H ;II" overload;F;J0;;o;K0;#I" reachable_objects_from(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I",ObjectSpace#reachable_objects_from_root;F;[;[[@wiF;T;: reachable_objects_from_root;0;[;{;IC;"C[MRI specific feature] Return all reachable objects from root. ;T;[o;H ;II" overload;F;J0;;p;K0;#I" reachable_objects_from_root;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[; @;[;I"{[MRI specific feature] Return all reachable objects from root. @overload reachable_objects_from_root @return [Hash];T;0; @;@F;N0;!@;"I"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; ; T; ;;;;I",ObjectSpace.reachable_objects_from_root;F;@;@;T;;p;0;@;{;IC;"C[MRI specific feature] Return all reachable objects from root.;T;[o;H ;II" overload;F;J0;;p;K0;#I" reachable_objects_from_root;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @/;[;I"@return [Hash];T;0; @/;@F;Mi;N0;[; @/;[;I"|[MRI specific feature] Return all reachable objects from root. @overload reachable_objects_from_root @return [Hash];T;0; @/;@F;Ao;B;CT;Di@;EiD;Mi;!@;"@-;#@.;$To; ; F; ;,;;;I""ObjectSpace#internal_class_of;F;[[I"obj;T0;[[@wij;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;H ;II" overload;F;J0;;q;K0;#I"internal_class_of(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Class;TI" Module;T; @D;[;I"@return [Class, Module];T;0; @D;@F;Mi;N0;[[I"obj;T0; @D;[;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; @D;@F;N0;!@;"I"static 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); } klass = CLASS_OF(obj); return wrap_klass_iow(klass); };T;#I"static VALUE;T;$To; ; T; ;;;;I""ObjectSpace.internal_class_of;F;@F;@I;T;;q;0;@K;{;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;H ;II" overload;F;J0;;q;K0;#I"internal_class_of(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Class;TI" Module;T; @c;[;I"@return [Class, Module];T;0; @c;@F;Mi;N0;[[I"obj;T0; @c;[;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; @c;@F;Ao;B;CT;Dia;Eih;Mi;!@;"@a;#@b;$To; ; F; ;,;;;I""ObjectSpace#internal_super_of;F;[[I"obj;T0;[[@wi;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;H ;II" overload;F;J0;;r;K0;#I"internal_super_of(cls);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Class;TI" Module;T; @{;[;I"@return [Class, Module];T;0; @{;@F;Mi;N0;[[I"cls;T0; @{;[;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; @{;@F;N0;!@;"I"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; ; T; ;;;;I""ObjectSpace.internal_super_of;F;@};@;T;;r;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;H ;II" overload;F;J0;;r;K0;#I"internal_super_of(cls);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Class;TI" Module;T; @;[;I"@return [Class, Module];T;0; @;@F;Mi;N0;[[I"cls;T0; @;[;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; @;@F;Ao;B;CT;Diw;Ei~;Mi;!@;"@;#@;$To; ;IC;[o; ; F; ;,;;;I",ObjectSpace::InternalObjectWrapper#type;F;[;[[@wi;T;: type;0;[;{;IC;"-Returns the type of the internal object. ;T;[;[;I"-Returns the type of the internal object.;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"ystatic VALUE iow_type(VALUE self) { VALUE obj = (VALUE)DATA_PTR(self); return type2sym(BUILTIN_TYPE(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"/ObjectSpace::InternalObjectWrapper#inspect;F;[;[[@wi;T;;i;0;[;{;IC;"See Object#inspect. ;T;[;[;I"See Object#inspect.;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I":ObjectSpace::InternalObjectWrapper#internal_object_id;F;[;[[@wi;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;Ao;B;CT;Di;Ei;!@;"I"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;-{;.[;[[@wi;F;:InternalObjectWrapper;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"'ObjectSpace::InternalObjectWrapper;F;1@@return [#];T;0; @;@F;Mi;N0;[[I"obj;T0[I" output:;TI" :file;T; @o;H ;II" overload;F;J0;;@;K0;#I"#dump(obj, output: :stdout) #;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"obj;T0[I" output:;TI" :stdout;T; @;[;I"Dump the contents of a ruby object as JSON. This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby. @overload dump(obj[, output: :string]) # @overload dump(obj, output: :file) # @return [#] @overload dump(obj, output: :stdout) # @return [nil];T;0; @;@F;N0;!@;"I"jstatic VALUE objspace_dump(int argc, VALUE *argv, VALUE os) { static const char filename[] = "rubyobj"; VALUE obj = Qnil, opts = Qnil, output; struct dump_config dc = {0,}; rb_scan_args(argc, argv, "1:", &obj, &opts); output = dump_output(&dc, opts, sym_string, filename); dump_object(obj, &dc); return dump_result(&dc, output); };T;#I"static VALUE;T;$To; ; T; ;;;;I"ObjectSpace.dump;F;@;@;T;;@;0;@;{;IC;"Dump the contents of a ruby object as JSON. This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby.;T;[o;H ;II" overload;F;J0;;@;K0;#I"#dump(obj[, output: :string]) #;T;IC;";T;[;[;I";T;0; @+;@F;Mi;N0;[[I"obj[, output:;TI" :string];T; @+o;H ;II" overload;F;J0;;@;K0;#I"#dump(obj, output: :file) #;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I"3#@return [#];T;0; @+;@F;Mi;N0;[[I"obj;T0[I" output:;TI" :file;T; @+o;H ;II" overload;F;J0;;@;K0;#I"#dump(obj, output: :stdout) #;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @+;[;I"@return [nil];T;0; @+;@F;Mi;N0;[[I"obj;T0[I" output:;TI" :stdout;T; @+;[;I"Dump the contents of a ruby object as JSON. This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby. @overload dump(obj[, output: :string]) # @overload dump(obj, output: :file) # @return [#] @overload dump(obj, output: :stdout) # @return [nil];T;0; @+;@F;Ao;B;CT;Di;Ei;Mi;!@;"@);#@*;$To; ; F; ;,;;;I"ObjectSpace#dump_all;F;[[@0;[[@i;T;: dump_all;0;[;{;IC;"Dump the contents of the ruby heap as JSON. This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby. ;T;[ o;H ;II" overload;F;J0;;v;K0;#I" dump_all([output: :file]) #;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I"3#@return [#];T;0; @b;@F;Mi;N0;[[I" [output:;TI" :file];T; @bo;H ;II" overload;F;J0;;v;K0;#I" dump_all(output: :stdout) #;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @b;[;I"@return [nil];T;0; @b;@F;Mi;N0;[[I" output:;TI" :stdout;T; @bo;H ;II" overload;F;J0;;v;K0;#I" dump_all(output: :string) #;T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[[I" output:;TI" :string;T; @bo;H ;II" overload;F;J0;;v;K0;#I"dump_all(output:;T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[[I" output:;TI";T; @bo;H ;II" overload;F;J0;;;K0;#I"%open('heap.json','w')) #;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I"#];T;0; @b;@F;Mi;N0;[["'heap.json'0["'w'0; @b;[;I"6Dump the contents of the ruby heap as JSON. This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby. @overload dump_all([output: :file]) # @return [#] @overload dump_all(output: :stdout) # @return [nil] @overload dump_all(output: :string) # @overload dump_all(output: @overload open('heap.json','w')) # @return [#];T;0; @b;@F;N0;!@;"I"static VALUE objspace_dump_all(int argc, VALUE *argv, VALUE os) { static const char filename[] = "rubyheap"; VALUE opts = Qnil, output; struct dump_config dc = {0,}; rb_scan_args(argc, argv, "0:", &opts); output = dump_output(&dc, opts, sym_file, filename); /* 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, output); };T;#I"static VALUE;T;$To; ; T; ;;;;I"ObjectSpace.dump_all;F;@d;@f;T;;v;0;@h;{;IC;"Dump the contents of the ruby heap as JSON. This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby.;T;[ o;H ;II" overload;F;J0;;v;K0;#I" dump_all([output: :file]) #;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I"3#@return [#];T;0; @;@F;Mi;N0;[[I" [output:;TI" :file];T; @o;H ;II" overload;F;J0;;v;K0;#I" dump_all(output: :stdout) #;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" output:;TI" :stdout;T; @o;H ;II" overload;F;J0;;v;K0;#I" dump_all(output: :string) #;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" output:;TI" :string;T; @o;H ;II" overload;F;J0;;v;K0;#I"dump_all(output:;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" output:;TI";T; @o;H ;II" overload;F;J0;;;K0;#I"%open('heap.json','w')) #;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I"#];T;0; @;@F;Mi;N0;[["'heap.json'0["'w'0; @;[;I"3Dump the contents of the ruby heap as JSON. This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby. @overload dump_all([output: :file]) # @return [#] @overload dump_all(output: :stdout) # @return [nil] @overload dump_all(output: :string) # @overload dump_all(output: @overload open('heap.json','w')) # @return [#];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"ObjectSpace#each_object;F;[[@0;[[@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;H ;II" overload;F;J0;;w;K0;#I"each_object([module]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"#@yield [obj] @return [Integer];T;0; @;@F;Mi;N0;[[I"[;T0; @o;H ;II" overload;F;J0;;w;K0;#I"each_object([module]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"ObjectSpace.each_object;F;@;@ ;T;;w;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;H ;II" overload;F;J0;;w;K0;#I"each_object([module]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @2o;L ;II" return;F;JI";T;0;K[I" Integer;T; @2;[;I"#@yield [obj] @return [Integer];T;0; @2;@F;Mi;N0;[[I"[;T0; @2o;H ;II" overload;F;J0;;w;K0;#I"each_object([module]);T;IC;";T;[;[;I";T;0; @2;@F;Mi;N0;[[I"[;T0; @2;[;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; @2;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"@0;#@1;$To; ; F; ;,;;;I" ObjectSpace#garbage_collect;F;[[@0;[[@i;T;:garbage_collect;0;[;{;IC;"Initiates garbage collection, unless manually disabled. This method is defined with keyword arguments that default to true: def GC.start(full_mark: true, immediate_sweep: true); end Use full_mark: false to perform a minor GC. Use immediate_sweep: false to defer sweeping (use lazy sweep). Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" start;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @X;[;I"@return [nil];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;x;K0;#I"garbage_collect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @X;[;I"@return [nil];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;:GC;K0;#I"GC;(garbage_collect);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @X;[;I"@return [nil];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;;K0;#I"2start(full_mark: true, immediate_sweep: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @X;[;I"@return [nil];T;0; @X;@F;Mi;N0;[[I"full_mark:;TI" true;T[I"immediate_sweep:;TI" true;T; @Xo;H ;II" overload;F;J0;;x;K0;#I"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. ;T;[o;H ;II" overload;F;J0;;z;K0;#I"(define_finalizer(obj, aProc=proc());T;IC;";T;[;[;I";T;0; @";@F;Mi;N0;[[I"obj;T0[I" aProc;TI" proc();T; @";[;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. @overload define_finalizer(obj, aProc=proc()) ;T;0; @";@F;N0;!@;"I"0static 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); } return define_final0(obj, block); };T;#I"static VALUE;T;$To; ; T; ;;;;I"!ObjectSpace.define_finalizer;F;@$;@&;T;;z;0;@(;{;IC;"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.;T;[o;H ;II" overload;F;J0;;z;K0;#I"(define_finalizer(obj, aProc=proc());T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[[I"obj;T0[I" aProc;TI" proc();T; @=;[;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. @overload define_finalizer(obj, aProc=proc());T;0; @=;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"@;;#@<;$To; ; F; ;,;;;I"#ObjectSpace#undefine_finalizer;F;[[I"obj;T0;[[@i ;T;:undefine_finalizer;0;[;{;IC;"+Removes all finalizers for obj. ;T;[o;H ;II" overload;F;J0;;{;K0;#I"undefine_finalizer(obj);T;IC;";T;[;[;I";T;0; @R;@F;Mi;N0;[[I"obj;T0; @R;[;I"NRemoves all finalizers for obj. @overload undefine_finalizer(obj) ;T;0; @R;@F;N0;!@;"I"`static VALUE undefine_final(VALUE os, VALUE obj) { return rb_undefine_finalizer(obj); };T;#I"static VALUE;T;$To; ; T; ;;;;I"#ObjectSpace.undefine_finalizer;F;@T;@W;T;;{;0;@Y;{;IC;"+Removes all finalizers for obj.;T;[o;H ;II" overload;F;J0;;{;K0;#I"undefine_finalizer(obj);T;IC;";T;[;[;I";T;0; @k;@F;Mi;N0;[[I"obj;T0; @k;[;I"PRemoves all finalizers for obj. @overload undefine_finalizer(obj);T;0; @k;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"@i;#@j;$To; ; F; ;,;;;I"ObjectSpace#_id2ref;F;[[I" objid;T0;[[@iw ;T;: _id2ref;0;[;{;IC;"+Converts an object id to a reference to the object. May not be called on an object id passed as a parameter to a finalizer. s = "I am a string" #=> "I am a string" r = ObjectSpace._id2ref(s.object_id) #=> "I am a string" r == s #=> true ;T;[o;H ;II" overload;F;J0;;|;K0;#I"_id2ref(object_id);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @};[;I"@return [Object];T;0; @};@F;Mi;N0;[[I"object_id;T0; @};[;I"\Converts an object id to a reference to the object. May not be called on an object id passed as a parameter to a finalizer. s = "I am a string" #=> "I am a string" r = ObjectSpace._id2ref(s.object_id) #=> "I am a string" r == s #=> true @overload _id2ref(object_id) @return [Object];T;0; @};@F;N0;!@;"I"1static VALUE id2ref(VALUE obj, VALUE objid) { #if SIZEOF_LONG == SIZEOF_VOIDP #define NUM2PTR(x) NUM2ULONG(x) #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP #define NUM2PTR(x) NUM2ULL(x) #endif rb_objspace_t *objspace = &rb_objspace; VALUE ptr; void *p0; ptr = NUM2PTR(objid); p0 = (void *)ptr; if (ptr == Qtrue) return Qtrue; if (ptr == Qfalse) return Qfalse; if (ptr == Qnil) return Qnil; if (FIXNUM_P(ptr)) return (VALUE)ptr; if (FLONUM_P(ptr)) return (VALUE)ptr; ptr = obj_id_to_ref(objid); if ((ptr % sizeof(RVALUE)) == (4 << 2)) { ID symid = ptr / sizeof(RVALUE); if (rb_id2str(symid) == 0) rb_raise(rb_eRangeError, "%p is not symbol id value", p0); return ID2SYM(symid); } if (!is_id_value(objspace, ptr)) { rb_raise(rb_eRangeError, "%p is not id value", p0); } if (!is_live_object(objspace, ptr)) { rb_raise(rb_eRangeError, "%p is recycled object", p0); } if (RBASIC(ptr)->klass == 0) { rb_raise(rb_eRangeError, "%p is internal object", p0); } return (VALUE)ptr; };T;#I"static VALUE;T;$To; ; T; ;;;;I"ObjectSpace._id2ref;F;@;@;T;;|;0;@;{;IC;"+Converts an object id to a reference to the object. May not be called on an object id passed as a parameter to a finalizer. s = "I am a string" #=> "I am a string" r = ObjectSpace._id2ref(s.object_id) #=> "I am a string" r == s #=> true;T;[o;H ;II" overload;F;J0;;|;K0;#I"_id2ref(object_id);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"object_id;T0; @;[;I"^Converts an object id to a reference to the object. May not be called on an object id passed as a parameter to a finalizer. s = "I am a string" #=> "I am a string" r = ObjectSpace._id2ref(s.object_id) #=> "I am a string" r == s #=> true @overload _id2ref(object_id) @return [Object];T;0; @;@F;Ao;B;CT;Dij ;Eit ;Mi;!@;"@;#@;$To; ; F; ;,;;;I"ObjectSpace#count_objects;F;[[@0;[[@i ;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;H ;II" overload;F;J0;;};K0;#I"!count_objects([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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]; RVALUE *p, *pend; p = page->start; pend = p + page->total_slots; for (;p < pend; p++) { if (p->as.basic.flags) { counts[BUILTIN_TYPE(p)]++; } else { freed++; } } total += page->total_slots; } if (hash == Qnil) { 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; switch (i) { #define COUNT_TYPE(t) case (t): type = ID2SYM(rb_intern(#t)); break; COUNT_TYPE(T_NONE); COUNT_TYPE(T_OBJECT); COUNT_TYPE(T_CLASS); COUNT_TYPE(T_MODULE); COUNT_TYPE(T_FLOAT); COUNT_TYPE(T_STRING); COUNT_TYPE(T_REGEXP); COUNT_TYPE(T_ARRAY); COUNT_TYPE(T_HASH); COUNT_TYPE(T_STRUCT); COUNT_TYPE(T_BIGNUM); COUNT_TYPE(T_FILE); COUNT_TYPE(T_DATA); COUNT_TYPE(T_MATCH); COUNT_TYPE(T_COMPLEX); COUNT_TYPE(T_RATIONAL); COUNT_TYPE(T_NIL); COUNT_TYPE(T_TRUE); COUNT_TYPE(T_FALSE); COUNT_TYPE(T_SYMBOL); COUNT_TYPE(T_FIXNUM); COUNT_TYPE(T_IMEMO); COUNT_TYPE(T_UNDEF); COUNT_TYPE(T_ICLASS); COUNT_TYPE(T_ZOMBIE); #undef COUNT_TYPE default: type = INT2NUM(i); break; } if (counts[i]) rb_hash_aset(hash, type, SIZET2NUM(counts[i])); } return hash; };T;#I"static VALUE;T;$To; ; T; ;;;;I"ObjectSpace.count_objects;F;@;@;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;H ;II" overload;F;J0;;};K0;#I"!count_objects([result_hash]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Diu ;Ei ;Mi;!@;"@;#@;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[ [@i&[@i[@wi[@wi[@i[@iO';T;;];;0;;;[;{;IC;"The objspace library extends the ObjectSpace module and adds several methods to get internal statistic information about object/memory management. You need to require 'objspace' to use this extension module. Generally, you *SHOULD NOT* use this library if you do not know about the MRI implementation. Mainly, this library is for (memory) profiler developers and MRI developers who need to know about MRI memory usage.;T;[;[;I" The objspace library extends the ObjectSpace module and adds several methods to get internal statistic information about object/memory management. You need to require 'objspace' to use this extension module. Generally, you *SHOULD NOT* use this library if you do not know about the MRI implementation. Mainly, this library is for (memory) profiler developers and MRI developers who need to know about MRI memory usage. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;I"ObjectSpace;Fo; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i22[@i2;T;: IOError;;0;;;[;{;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;Ao;B;CT;Di22;Ei@2;!@;I" IOError;F;1o;2 ;30;40;50;;;!@;7@7;F;o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iD2[@i2;T;: EOFError;;0;;;[;{;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;Ao;B;CT;DiD2;EiQ2;!@;I" EOFError;F;1@@Vo;9;[[@i3;F;: STDIN;;;;;;[;{;IC;"Holds the original stdin ;T;[;[;I"Holds the original stdin;T;0; @%;@F;Ao;B;CT;Di3;Ei3;!@;I" STDIN;F; ["--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;!@;I" ARGF;F;arr into a binary sequence according to the directives in aTemplateString (see the table below) Directives ``A,'' ``a,'' and ``Z'' may be followed by a count, which gives the width of the resulting field. The remaining directives also may take a count, indicating the number of array elements to convert. If the count is an asterisk (``*''), all remaining array elements will be converted. Any of the directives ``sSiIlL'' may be followed by an underscore (``_'') or exclamation mark (``!'') to use the underlying platform's native size for the specified type; otherwise, they use a platform-independent size. Spaces are ignored in the template string. See also String#unpack. a = [ "a", "b", "c" ] n = [ 65, 66, 67 ] a.pack("A3A3A3") #=> "a b c " a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000" n.pack("ccc") #=> "ABC" If aBufferString is specified and its capacity is enough, +pack+ uses it as the buffer and returns it. When the offset is specified by the beginning of aTemplateString, the result is filled after the offset. If original contents of aBufferString exists and it's longer than the offset, the rest of offsetOfBuffer are overwritten by the result. If it's shorter, the gap is filled with ``\0''. Note that ``buffer:'' option does not guarantee not to allocate memory in +pack+. If the capacity of aBufferString is not enough, +pack+ allocates memory. Directives for +pack+. Integer | Array | Directive | Element | Meaning ---------------------------------------------------------------------------- C | Integer | 8-bit unsigned (unsigned char) S | Integer | 16-bit unsigned, native endian (uint16_t) L | Integer | 32-bit unsigned, native endian (uint32_t) Q | Integer | 64-bit unsigned, native endian (uint64_t) J | Integer | pointer width unsigned, native endian (uintptr_t) | | (J is available since Ruby 2.3.) | | c | Integer | 8-bit signed (signed char) s | Integer | 16-bit signed, native endian (int16_t) l | Integer | 32-bit signed, native endian (int32_t) q | Integer | 64-bit signed, native endian (int64_t) j | Integer | pointer width signed, native endian (intptr_t) | | (j is available since Ruby 2.3.) | | S_ S! | Integer | unsigned short, native endian I I_ I! | Integer | unsigned int, native endian L_ L! | Integer | unsigned long, native endian Q_ Q! | Integer | unsigned long long, native endian (ArgumentError | | if the platform has no long long type.) | | (Q_ and Q! is available since Ruby 2.1.) J! | Integer | uintptr_t, native endian (same with J) | | (J! is available since Ruby 2.3.) | | s_ s! | Integer | signed short, native endian i i_ i! | Integer | signed int, native endian l_ l! | Integer | signed long, native endian q_ q! | Integer | signed long long, native endian (ArgumentError | | if the platform has no long long type.) | | (q_ and q! is available since Ruby 2.1.) j! | Integer | intptr_t, native endian (same with j) | | (j! is available since Ruby 2.3.) | | S> s> S!> s!> | Integer | same as the directives without ">" except L> l> L!> l!> | | big endian I!> i!> | | (available since Ruby 1.9.3) Q> q> Q!> q!> | | "S>" is same as "n" J> j> J!> j!> | | "L>" is same as "N" | | S< s< S!< s!< | Integer | same as the directives without "<" except L< l< L!< l!< | | little endian I!< i!< | | (available since Ruby 1.9.3) Q< q< Q!< q!< | | "S<" is same as "v" J< j< J!< j!< | | "L<" is same as "V" | | n | Integer | 16-bit unsigned, network (big-endian) byte order N | Integer | 32-bit unsigned, network (big-endian) byte order v | Integer | 16-bit unsigned, VAX (little-endian) byte order V | Integer | 32-bit unsigned, VAX (little-endian) byte order | | U | Integer | UTF-8 character w | Integer | BER-compressed integer Float | Array | Directive | Element | Meaning --------------------------------------------------------------------------- D d | Float | double-precision, native format F f | Float | single-precision, native format E | Float | double-precision, little-endian byte order e | Float | single-precision, little-endian byte order G | Float | double-precision, network (big-endian) byte order g | Float | single-precision, network (big-endian) byte order String | Array | Directive | Element | Meaning --------------------------------------------------------------------------- A | String | arbitrary binary string (space padded, count is width) a | String | arbitrary binary string (null padded, count is width) Z | String | same as ``a'', except that null is added with * B | String | bit string (MSB first) b | String | bit string (LSB first) H | String | hex string (high nibble first) h | String | hex string (low nibble first) u | String | UU-encoded string M | String | quoted printable, MIME encoding (see also RFC2045) | | (text mode but input must use LF and output LF) m | String | base64 encoded string (see RFC 2045, count is width) | | (if count is 0, no line feed are added, see RFC 4648) P | String | pointer to a structure (fixed-length string) p | String | pointer to a null-terminated string Misc. | Array | Directive | Element | Meaning --------------------------------------------------------------------------- @ | --- | moves to absolute position X | --- | back up a byte x | --- | null byte ;T;[o;H ;II" overload;F;J0;;;K0;#I"pack( aTemplateString );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"aBinaryString;T; @V;[;I"@return [aBinaryString];T;0; @V;@F;Mi;N0;[[I"aTemplateString;T0; @Vo;H ;II" overload;F;J0;;;K0;#I"3pack( aTemplateString, buffer: aBufferString );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"aBufferString;T; @V;[;I"@return [aBufferString];T;0; @V;@F;Mi;N0;[[I"aTemplateString;T0[I" buffer:;TI"aBufferString;T; @V;[;I"Packs the contents of arr into a binary sequence according to the directives in aTemplateString (see the table below) Directives ``A,'' ``a,'' and ``Z'' may be followed by a count, which gives the width of the resulting field. The remaining directives also may take a count, indicating the number of array elements to convert. If the count is an asterisk (``*''), all remaining array elements will be converted. Any of the directives ``sSiIlL'' may be followed by an underscore (``_'') or exclamation mark (``!'') to use the underlying platform's native size for the specified type; otherwise, they use a platform-independent size. Spaces are ignored in the template string. See also String#unpack. a = [ "a", "b", "c" ] n = [ 65, 66, 67 ] a.pack("A3A3A3") #=> "a b c " a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000" n.pack("ccc") #=> "ABC" If aBufferString is specified and its capacity is enough, +pack+ uses it as the buffer and returns it. When the offset is specified by the beginning of aTemplateString, the result is filled after the offset. If original contents of aBufferString exists and it's longer than the offset, the rest of offsetOfBuffer are overwritten by the result. If it's shorter, the gap is filled with ``\0''. Note that ``buffer:'' option does not guarantee not to allocate memory in +pack+. If the capacity of aBufferString is not enough, +pack+ allocates memory. Directives for +pack+. Integer | Array | Directive | Element | Meaning ---------------------------------------------------------------------------- C | Integer | 8-bit unsigned (unsigned char) S | Integer | 16-bit unsigned, native endian (uint16_t) L | Integer | 32-bit unsigned, native endian (uint32_t) Q | Integer | 64-bit unsigned, native endian (uint64_t) J | Integer | pointer width unsigned, native endian (uintptr_t) | | (J is available since Ruby 2.3.) | | c | Integer | 8-bit signed (signed char) s | Integer | 16-bit signed, native endian (int16_t) l | Integer | 32-bit signed, native endian (int32_t) q | Integer | 64-bit signed, native endian (int64_t) j | Integer | pointer width signed, native endian (intptr_t) | | (j is available since Ruby 2.3.) | | S_ S! | Integer | unsigned short, native endian I I_ I! | Integer | unsigned int, native endian L_ L! | Integer | unsigned long, native endian Q_ Q! | Integer | unsigned long long, native endian (ArgumentError | | if the platform has no long long type.) | | (Q_ and Q! is available since Ruby 2.1.) J! | Integer | uintptr_t, native endian (same with J) | | (J! is available since Ruby 2.3.) | | s_ s! | Integer | signed short, native endian i i_ i! | Integer | signed int, native endian l_ l! | Integer | signed long, native endian q_ q! | Integer | signed long long, native endian (ArgumentError | | if the platform has no long long type.) | | (q_ and q! is available since Ruby 2.1.) j! | Integer | intptr_t, native endian (same with j) | | (j! is available since Ruby 2.3.) | | S> s> S!> s!> | Integer | same as the directives without ">" except L> l> L!> l!> | | big endian I!> i!> | | (available since Ruby 1.9.3) Q> q> Q!> q!> | | "S>" is same as "n" J> j> J!> j!> | | "L>" is same as "N" | | S< s< S!< s!< | Integer | same as the directives without "<" except L< l< L!< l!< | | little endian I!< i!< | | (available since Ruby 1.9.3) Q< q< Q!< q!< | | "S<" is same as "v" J< j< J!< j!< | | "L<" is same as "V" | | n | Integer | 16-bit unsigned, network (big-endian) byte order N | Integer | 32-bit unsigned, network (big-endian) byte order v | Integer | 16-bit unsigned, VAX (little-endian) byte order V | Integer | 32-bit unsigned, VAX (little-endian) byte order | | U | Integer | UTF-8 character w | Integer | BER-compressed integer Float | Array | Directive | Element | Meaning --------------------------------------------------------------------------- D d | Float | double-precision, native format F f | Float | single-precision, native format E | Float | double-precision, little-endian byte order e | Float | single-precision, little-endian byte order G | Float | double-precision, network (big-endian) byte order g | Float | single-precision, network (big-endian) byte order String | Array | Directive | Element | Meaning --------------------------------------------------------------------------- A | String | arbitrary binary string (space padded, count is width) a | String | arbitrary binary string (null padded, count is width) Z | String | same as ``a'', except that null is added with * B | String | bit string (MSB first) b | String | bit string (LSB first) H | String | hex string (high nibble first) h | String | hex string (low nibble first) u | String | UU-encoded string M | String | quoted printable, MIME encoding (see also RFC2045) | | (text mode but input must use LF and output LF) m | String | base64 encoded string (see RFC 2045, count is width) | | (if count is 0, no line feed are added, see RFC 4648) P | String | pointer to a structure (fixed-length string) p | String | pointer to a null-terminated string Misc. | Array | Directive | Element | Meaning --------------------------------------------------------------------------- @ | --- | moves to absolute position X | --- | back up a byte x | --- | null byte @overload pack( aTemplateString ) @return [aBinaryString] @overload pack( aTemplateString, buffer: aBufferString ) @return [aBufferString];T;0; @V;@F;Ao;B;CT;Di;Ei,;!@T;"I".9static VALUE pack_pack(int argc, VALUE *argv, VALUE ary) { static const char nul10[] = "\0\0\0\0\0\0\0\0\0\0"; static const char spc10[] = " "; const char *p, *pend; VALUE fmt, opt = Qnil, res, from, associates = 0, buffer = 0; char type; long len, idx, plen; const char *ptr; int enc_info = 1; /* 0 - BINARY, 1 - US-ASCII, 2 - UTF-8 */ #ifdef NATINT_PACK int natint; /* native integer */ #endif int integer_size, bigendian_p; rb_scan_args(argc, argv, "10:", &fmt, &opt); StringValue(fmt); p = RSTRING_PTR(fmt); pend = p + RSTRING_LEN(fmt); if (!NIL_P(opt)) { static ID keyword_ids[1]; if (!keyword_ids[0]) CONST_ID(keyword_ids[0], "buffer"); rb_get_kwargs(opt, keyword_ids, 0, 1, &buffer); if (buffer != Qundef && !RB_TYPE_P(buffer, T_STRING)) rb_raise(rb_eTypeError, "buffer must be String, not %s", rb_obj_classname(buffer)); } if (buffer) res = buffer; else res = rb_str_buf_new(0); idx = 0; #define TOO_FEW (rb_raise(rb_eArgError, toofew), 0) #define MORE_ITEM (idx < RARRAY_LEN(ary)) #define THISFROM (MORE_ITEM ? RARRAY_AREF(ary, idx) : TOO_FEW) #define NEXTFROM (MORE_ITEM ? RARRAY_AREF(ary, idx++) : TOO_FEW) while (p < pend) { int explicit_endian = 0; if (RSTRING_PTR(fmt) + RSTRING_LEN(fmt) != pend) { rb_raise(rb_eRuntimeError, "format string modified"); } type = *p++; /* get data type */ #ifdef NATINT_PACK natint = 0; #endif if (ISSPACE(type)) continue; if (type == '#') { while ((p < pend) && (*p != '\n')) { p++; } continue; } { modifiers: switch (*p) { case '_': case '!': if (strchr(natstr, type)) { #ifdef NATINT_PACK natint = 1; #endif p++; } else { rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, natstr); } goto modifiers; case '<': case '>': if (!strchr(endstr, type)) { rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, endstr); } if (explicit_endian) { rb_raise(rb_eRangeError, "Can't use both '<' and '>'"); } explicit_endian = *p++; goto modifiers; } } if (*p == '*') { /* set data length */ len = strchr("@Xxu", type) ? 0 : strchr("PMm", type) ? 1 : RARRAY_LEN(ary) - idx; p++; } else if (ISDIGIT(*p)) { errno = 0; len = STRTOUL(p, (char**)&p, 10); if (errno) { rb_raise(rb_eRangeError, "pack length too big"); } } else { len = 1; } switch (type) { case 'U': /* if encoding is US-ASCII, upgrade to UTF-8 */ if (enc_info == 1) enc_info = 2; break; case 'm': case 'M': case 'u': /* keep US-ASCII (do nothing) */ break; default: /* fall back to BINARY */ enc_info = 0; break; } switch (type) { case 'A': case 'a': case 'Z': case 'B': case 'b': case 'H': case 'h': from = NEXTFROM; if (NIL_P(from)) { ptr = ""; plen = 0; } else { StringValue(from); ptr = RSTRING_PTR(from); plen = RSTRING_LEN(from); OBJ_INFECT(res, from); } if (p[-1] == '*') len = plen; switch (type) { case 'a': /* arbitrary binary string (null padded) */ case 'A': /* arbitrary binary string (ASCII space padded) */ case 'Z': /* null terminated string */ if (plen >= len) { rb_str_buf_cat(res, ptr, len); if (p[-1] == '*' && type == 'Z') rb_str_buf_cat(res, nul10, 1); } else { rb_str_buf_cat(res, ptr, plen); len -= plen; while (len >= 10) { rb_str_buf_cat(res, (type == 'A')?spc10:nul10, 10); len -= 10; } rb_str_buf_cat(res, (type == 'A')?spc10:nul10, len); } break; #define castchar(from) (char)((from) & 0xff) case 'b': /* bit string (ascending) */ { int byte = 0; long i, j = 0; if (len > plen) { j = (len - plen + 1)/2; len = plen; } for (i=0; i++ < len; ptr++) { if (*ptr & 1) byte |= 128; if (i & 7) byte >>= 1; else { char c = castchar(byte); rb_str_buf_cat(res, &c, 1); byte = 0; } } if (len & 7) { char c; byte >>= 7 - (len & 7); c = castchar(byte); rb_str_buf_cat(res, &c, 1); } len = j; goto grow; } break; case 'B': /* bit string (descending) */ { int byte = 0; long i, j = 0; if (len > plen) { j = (len - plen + 1)/2; len = plen; } for (i=0; i++ < len; ptr++) { byte |= *ptr & 1; if (i & 7) byte <<= 1; else { char c = castchar(byte); rb_str_buf_cat(res, &c, 1); byte = 0; } } if (len & 7) { char c; byte <<= 7 - (len & 7); c = castchar(byte); rb_str_buf_cat(res, &c, 1); } len = j; goto grow; } break; case 'h': /* hex string (low nibble first) */ { int byte = 0; long i, j = 0; if (len > plen) { j = (len + 1) / 2 - (plen + 1) / 2; len = plen; } for (i=0; i++ < len; ptr++) { if (ISALPHA(*ptr)) byte |= (((*ptr & 15) + 9) & 15) << 4; else byte |= (*ptr & 15) << 4; if (i & 1) byte >>= 4; else { char c = castchar(byte); rb_str_buf_cat(res, &c, 1); byte = 0; } } if (len & 1) { char c = castchar(byte); rb_str_buf_cat(res, &c, 1); } len = j; goto grow; } break; case 'H': /* hex string (high nibble first) */ { int byte = 0; long i, j = 0; if (len > plen) { j = (len + 1) / 2 - (plen + 1) / 2; len = plen; } for (i=0; i++ < len; ptr++) { if (ISALPHA(*ptr)) byte |= ((*ptr & 15) + 9) & 15; else byte |= *ptr & 15; if (i & 1) byte <<= 4; else { char c = castchar(byte); rb_str_buf_cat(res, &c, 1); byte = 0; } } if (len & 1) { char c = castchar(byte); rb_str_buf_cat(res, &c, 1); } len = j; goto grow; } break; } break; case 'c': /* signed char */ case 'C': /* unsigned char */ integer_size = 1; bigendian_p = BIGENDIAN_P(); /* not effective */ goto pack_integer; case 's': /* s for int16_t, s! for signed short */ integer_size = NATINT_LEN(short, 2); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'S': /* S for uint16_t, S! for unsigned short */ integer_size = NATINT_LEN(short, 2); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'i': /* i and i! for signed int */ integer_size = (int)sizeof(int); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'I': /* I and I! for unsigned int */ integer_size = (int)sizeof(int); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'l': /* l for int32_t, l! for signed long */ integer_size = NATINT_LEN(long, 4); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'L': /* L for uint32_t, L! for unsigned long */ integer_size = NATINT_LEN(long, 4); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'q': /* q for int64_t, q! for signed long long */ integer_size = NATINT_LEN_Q; bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'Q': /* Q for uint64_t, Q! for unsigned long long */ integer_size = NATINT_LEN_Q; bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'j': /* j for intptr_t */ integer_size = sizeof(intptr_t); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'J': /* J for uintptr_t */ integer_size = sizeof(uintptr_t); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'n': /* 16 bit (2 bytes) integer (network byte-order) */ integer_size = 2; bigendian_p = 1; goto pack_integer; case 'N': /* 32 bit (4 bytes) integer (network byte-order) */ integer_size = 4; bigendian_p = 1; goto pack_integer; case 'v': /* 16 bit (2 bytes) integer (VAX byte-order) */ integer_size = 2; bigendian_p = 0; goto pack_integer; case 'V': /* 32 bit (4 bytes) integer (VAX byte-order) */ integer_size = 4; bigendian_p = 0; goto pack_integer; pack_integer: if (explicit_endian) { bigendian_p = explicit_endian == '>'; } if (integer_size > MAX_INTEGER_PACK_SIZE) rb_bug("unexpected intger size for pack: %d", integer_size); while (len-- > 0) { char intbuf[MAX_INTEGER_PACK_SIZE]; from = NEXTFROM; rb_integer_pack(from, intbuf, integer_size, 1, 0, INTEGER_PACK_2COMP | (bigendian_p ? INTEGER_PACK_BIG_ENDIAN : INTEGER_PACK_LITTLE_ENDIAN)); rb_str_buf_cat(res, intbuf, integer_size); } break; case 'f': /* single precision float in native format */ case 'F': /* ditto */ while (len-- > 0) { float f; from = NEXTFROM; f = VALUE_to_float(from); rb_str_buf_cat(res, (char*)&f, sizeof(float)); } break; case 'e': /* single precision float in VAX byte-order */ while (len-- > 0) { FLOAT_CONVWITH(tmp); from = NEXTFROM; tmp.f = VALUE_to_float(from); HTOVF(tmp); rb_str_buf_cat(res, tmp.buf, sizeof(float)); } break; case 'E': /* double precision float in VAX byte-order */ while (len-- > 0) { DOUBLE_CONVWITH(tmp); from = NEXTFROM; tmp.d = RFLOAT_VALUE(rb_to_float(from)); HTOVD(tmp); rb_str_buf_cat(res, tmp.buf, sizeof(double)); } break; case 'd': /* double precision float in native format */ case 'D': /* ditto */ while (len-- > 0) { double d; from = NEXTFROM; d = RFLOAT_VALUE(rb_to_float(from)); rb_str_buf_cat(res, (char*)&d, sizeof(double)); } break; case 'g': /* single precision float in network byte-order */ while (len-- > 0) { FLOAT_CONVWITH(tmp); from = NEXTFROM; tmp.f = VALUE_to_float(from); HTONF(tmp); rb_str_buf_cat(res, tmp.buf, sizeof(float)); } break; case 'G': /* double precision float in network byte-order */ while (len-- > 0) { DOUBLE_CONVWITH(tmp); from = NEXTFROM; tmp.d = RFLOAT_VALUE(rb_to_float(from)); HTOND(tmp); rb_str_buf_cat(res, tmp.buf, sizeof(double)); } break; case 'x': /* null byte */ grow: while (len >= 10) { rb_str_buf_cat(res, nul10, 10); len -= 10; } rb_str_buf_cat(res, nul10, len); break; case 'X': /* back up byte */ shrink: plen = RSTRING_LEN(res); if (plen < len) rb_raise(rb_eArgError, "X outside of string"); rb_str_set_len(res, plen - len); break; case '@': /* null fill to absolute position */ len -= RSTRING_LEN(res); if (len > 0) goto grow; len = -len; if (len > 0) goto shrink; break; case '%': rb_raise(rb_eArgError, "%% is not supported"); break; case 'U': /* Unicode character */ while (len-- > 0) { SIGNED_VALUE l; char buf[8]; int le; from = NEXTFROM; from = rb_to_int(from); l = NUM2LONG(from); if (l < 0) { rb_raise(rb_eRangeError, "pack(U): value out of range"); } le = rb_uv_to_utf8(buf, l); rb_str_buf_cat(res, (char*)buf, le); } break; case 'u': /* uuencoded string */ case 'm': /* base64 encoded string */ from = NEXTFROM; StringValue(from); ptr = RSTRING_PTR(from); plen = RSTRING_LEN(from); OBJ_INFECT(res, from); if (len == 0 && type == 'm') { encodes(res, ptr, plen, type, 0); ptr += plen; break; } if (len <= 2) len = 45; else if (len > 63 && type == 'u') len = 63; else len = len / 3 * 3; while (plen > 0) { long todo; if (plen > len) todo = len; else todo = plen; encodes(res, ptr, todo, type, 1); plen -= todo; ptr += todo; } break; case 'M': /* quoted-printable encoded string */ from = rb_obj_as_string(NEXTFROM); OBJ_INFECT(res, from); if (len <= 1) len = 72; qpencode(res, from, len); break; case 'P': /* pointer to packed byte string */ from = THISFROM; if (!NIL_P(from)) { StringValue(from); if (RSTRING_LEN(from) < len) { rb_raise(rb_eArgError, "too short buffer for P(%ld for %ld)", RSTRING_LEN(from), len); } } len = 1; /* FALL THROUGH */ case 'p': /* pointer to string */ while (len-- > 0) { char *t; from = NEXTFROM; if (NIL_P(from)) { t = 0; } else { t = StringValuePtr(from); OBJ_INFECT(res, from); rb_obj_taint(from); } if (!associates) { associates = rb_ary_new(); } rb_ary_push(associates, from); rb_str_buf_cat(res, (char*)&t, sizeof(char*)); } break; case 'w': /* BER compressed integer */ while (len-- > 0) { VALUE buf = rb_str_new(0, 0); size_t numbytes; int sign; char *cp; from = NEXTFROM; from = rb_to_int(from); numbytes = rb_absint_numwords(from, 7, NULL); if (numbytes == 0) numbytes = 1; buf = rb_str_new(NULL, numbytes); sign = rb_integer_pack(from, RSTRING_PTR(buf), RSTRING_LEN(buf), 1, 1, INTEGER_PACK_BIG_ENDIAN); if (sign < 0) rb_raise(rb_eArgError, "can't compress negative numbers"); if (sign == 2) rb_bug("buffer size problem?"); cp = RSTRING_PTR(buf); while (1 < numbytes) { *cp |= 0x80; cp++; numbytes--; } rb_str_buf_cat(res, RSTRING_PTR(buf), RSTRING_LEN(buf)); } break; default: { unknown_directive("pack", type, fmt); break; } } } if (associates) { str_associate(res, associates); } OBJ_INFECT(res, fmt); switch (enc_info) { case 1: ENCODING_CODERANGE_SET(res, rb_usascii_encindex(), ENC_CODERANGE_7BIT); break; case 2: rb_enc_set_index(res, rb_utf8_encindex()); break; default: /* do nothing, keep ASCII-8BIT */ break; } return res; };T;#I"static VALUE;T;$To; ; F; ;;;;I" Array.[];F;[[@0;[[I" array.c;Ti;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;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;;;;I"Array.try_convert;F;[[I"ary;T0;[[@i;T;; ;0;[;{;IC;"Tries to convert +obj+ into an array, using +to_ary+ method. Returns the converted array or +nil+ if +obj+ cannot be converted for any reason. This method can be used to check if an argument is an array. Array.try_convert([1]) #=> [1] Array.try_convert("1") #=> nil if tmp = Array.try_convert(arg) # the argument is an array elsif tmp = String.try_convert(arg) # the argument is a string end ;T;[o;H ;II" overload;F;J0;; ;K0;#I"try_convert(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"Tries to convert +obj+ into an array, using +to_ary+ method. Returns the converted array or +nil+ if +obj+ cannot be converted for any reason. This method can be used to check if an argument is an array. Array.try_convert([1]) #=> [1] Array.try_convert("1") #=> nil if tmp = Array.try_convert(arg) # the argument is an array elsif tmp = String.try_convert(arg) # the argument is a string end @overload try_convert(obj) @return [Array, nil];T;0; @;@F;Ao;B;CT;Dim;Ei};!@T;"I"gstatic VALUE rb_ary_s_try_convert(VALUE dummy, VALUE ary) { return rb_check_array_type(ary); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#initialize;F;[[@0;[[@i;T;;;0;[;{;IC;"Returns a new array. In the first form, if no arguments are sent, the new array will be empty. When a +size+ and an optional +default+ are sent, an array is created with +size+ copies of +default+. Take notice that all elements will reference the same object +default+. The second form creates a copy of the array passed as a parameter (the array is generated by calling to_ary on the parameter). first_array = ["Matz", "Guido"] second_array = Array.new(first_array) #=> ["Matz", "Guido"] first_array.equal? second_array #=> false In the last form, an array of the given size is created. Each element in this array is created by passing the element's index to the given block and storing the return value. Array.new(3) {|index| index ** 2} # => [0, 1, 4] == Common gotchas When sending the second parameter, the same object will be used as the value for all the array elements: a = Array.new(2, Hash.new) # => [{}, {}] a[0]['cat'] = 'feline' a # => [{"cat"=>"feline"}, {"cat"=>"feline"}] a[1]['cat'] = 'Felix' a # => [{"cat"=>"Felix"}, {"cat"=>"Felix"}] Since all the Array elements store the same hash, changes to one of them will affect them all. If multiple copies are what you want, you should use the block version which uses the result of that block each time an element of the array needs to be initialized: a = Array.new(2) {Hash.new} a[0]['cat'] = 'feline' a # => [{"cat"=>"feline"}, {}] ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(size=0, default=nil);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" size;TI"0;T[I" default;TI"nil;T; @o;H ;II" overload;F;J0;; ;K0;#I"new(array);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" array;T0; @o;H ;II" overload;F;J0;; ;K0;#I"new(size);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" index;T; @;[;I"@yield [index];T;0; @;@F;Mi;N0;[[I" size;T0; @;[;I"Returns a new array. In the first form, if no arguments are sent, the new array will be empty. When a +size+ and an optional +default+ are sent, an array is created with +size+ copies of +default+. Take notice that all elements will reference the same object +default+. The second form creates a copy of the array passed as a parameter (the array is generated by calling to_ary on the parameter). first_array = ["Matz", "Guido"] second_array = Array.new(first_array) #=> ["Matz", "Guido"] first_array.equal? second_array #=> false In the last form, an array of the given size is created. Each element in this array is created by passing the element's index to the given block and storing the return value. Array.new(3) {|index| index ** 2} # => [0, 1, 4] == Common gotchas When sending the second parameter, the same object will be used as the value for all the array elements: a = Array.new(2, Hash.new) # => [{}, {}] a[0]['cat'] = 'feline' a # => [{"cat"=>"feline"}, {"cat"=>"feline"}] a[1]['cat'] = 'Felix' a # => [{"cat"=>"Felix"}, {"cat"=>"Felix"}] Since all the Array elements store the same hash, changes to one of them will affect them all. If multiple copies are what you want, you should use the block version which uses the result of that block each time an element of the array needs to be initialized: a = Array.new(2) {Hash.new} a[0]['cat'] = 'feline' a # => [{"cat"=>"feline"}, {}] @overload new(size=0, default=nil) @overload new(array) @overload new(size) @yield [index];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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 ["x", "y", "z"] a #=> ["x", "y", "z"] ;T;[o;H ;II" overload;F;J0;;';K0;#I"replace(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary;T0; @o;H ;II" overload;F;J0;;];K0;#I"&initialize_copy(other_ary) -> ary;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"other_ary;T0; @;[;I"TReplaces the contents of +self+ with the contents of +other_ary+, truncating or expanding if necessary. a = [ "a", "b", "c", "d", "e" ] a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"] a #=> ["x", "y", "z"] @overload replace(other_ary) @return [Array] @overload initialize_copy(other_ary) -> ary;T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"&VALUE 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 = 0; if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else if (ARY_SHARED_P(copy)) { shared = ARY_SHARED(copy); FL_UNSET_SHARED(copy); } FL_SET_EMBED(copy); ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig)); if (shared) { rb_ary_decrement_share(shared); } ARY_SET_LEN(copy, RARRAY_LEN(orig)); } else { VALUE shared = 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); } ary_verify(copy); return copy; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Array#inspect;F;[;[[@ib ;T;;i;0;[;{;IC;"jCreates a string representation of +self+. [ "a", "b", "c" ].to_s #=> "[\"a\", \"b\", \"c\"]" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"Creates a string representation of +self+. [ "a", "b", "c" ].to_s #=> "[\"a\", \"b\", \"c\"]" @overload inspect @return [String] @overload to_s @return [String];T;0; o; ; F; ;,;;;I"Array#to_s;F;[;[[@i;F;;h;;0;[;{;@;!@T;"I"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;Ao;B;CT;DiX ;Ei` ;!@T;"I"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;#@B;$T@:o; ; F; ;,;;;I"Array#to_a;F;[;[[@ix ;T;;;0;[;{;IC;"aReturns +self+. If called on a subclass of Array, converts the receiver to an Array object. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @E;[;I"@return [Array];T;0; @E;@F;Mi;N0;[; @E;[;I"Returns +self+. If called on a subclass of Array, converts the receiver to an Array object. @overload to_a @return [Array];T;0; @E;@F;Ao;B;CT;Dio ;Eiu ;!@T;"I"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; ; F; ;,;;;I"Array#to_h;F;[;[[@i ;T;;;0;[;{;IC;"HReturns the result of interpreting ary as an array of [key, value] pairs. [[:foo, :bar], [1, 2]].to_h # => {:foo => :bar, 1 => 2} If a block is given, the results of the block on each element of the array will be used as pairs. ["foo", "bar"].to_h {|s| [s.ord, s]} # => {102=>"foo", 98=>"bar"} ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_h;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @`;[;I"@return [Hash];T;0; @`;@F;Mi;N0;[; @`o;H ;II" overload;F;J0;;;K0;#I" to_h;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @`o;L ;II" return;F;JI";T;0;K[I" Hash;T; @`;[;I"@yield [] @return [Hash];T;0; @`;@F;Mi;N0;[; @`;[;I"Returns the result of interpreting ary as an array of [key, value] pairs. [[:foo, :bar], [1, 2]].to_h # => {:foo => :bar, 1 => 2} If a block is given, the results of the block on each element of the array will be used as pairs. ["foo", "bar"].to_h {|s| [s.ord, s]} # => {102=>"foo", 98=>"bar"} @overload to_h @return [Hash] @overload to_h @yield [] @return [Hash];T;0; @`;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; i false [ "a", "c", 7 ] == [ "a", "c", 7 ] #=> true [ "a", "c", 7 ] == [ "a", "d", "f" ] #=> false ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"other_ary;T0; @;[;I"{Equality --- Two arrays are equal if they contain the same number of elements and if each element is equal to (according to Object#==) the corresponding element in +other_ary+. [ "a", "c" ] == [ "a", "c", 7 ] #=> false [ "a", "c", 7 ] == [ "a", "c", 7 ] #=> true [ "a", "c", 7 ] == [ "a", "d", "f" ] #=> false @overload ==(other_ary) @return [Boolean];T;0; @;@F;Ao;B;CT;Di`;Eik;!@T;"I"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; ; F; ;,;;;I"Array#eql?;F;[[I" ary2;T0;[[@i;T;;R;0;[;{;IC;"~Returns +true+ if +self+ and +other+ are the same object, or are both arrays with the same content (according to Object#eql?).;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" other;T0; @;[;I"Returns +true+ if +self+ and +other+ are the same object, or are both arrays with the same content (according to Object#eql?). @overload eql?(other) @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@T;"I"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; ; F; ;,;;;I"Array#hash;F;[;[[@i;T;;U;0;[;{;IC;"Compute a hash-code for this array. Two arrays with the same content will have the same hash code (and will compare using #eql?). See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Compute a hash-code for this array. Two arrays with the same content will have the same hash code (and will compare using #eql?). See also Object#hash. @overload hash @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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 "cab" a[6] #=> nil a[1, 2] #=> [ "b", "c" ] a[1..3] #=> [ "b", "c", "d" ] a[4..7] #=> [ "e" ] a[6..10] #=> nil a[-3, 3] #=> [ "c", "d", "e" ] # special cases a[5] #=> nil a[6, 1] #=> nil a[5, 1] #=> [] a[5..10] #=> [] ;T;[ o;H ;II" overload;F;J0;;;K0;#I"[](index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[I" index;T0; @o;H ;II" overload;F;J0;;;K0;#I"[](start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" start;T0[I" length;T0; @o;H ;II" overload;F;J0;;;K0;#I"[](range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" range;T0; @o;H ;II" overload;F;J0;;;K0;#I"slice(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[I" index;T0; @o;H ;II" overload;F;J0;;;K0;#I"slice(start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" start;T0[I" length;T0; @o;H ;II" overload;F;J0;;;K0;#I"slice(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" range;T0; @;[;I"Element Reference --- Returns the element at +index+, or returns a subarray starting at the +start+ index and continuing for +length+ elements, or returns a subarray specified by +range+ of indices. Negative indices count backward from the end of the array (-1 is the last element). For +start+ and +range+ cases the starting index is just before an element. Additionally, an empty array is returned when the starting index for an element range is at the end of the array. Returns +nil+ if the index (or starting index) are out of range. a = [ "a", "b", "c", "d", "e" ] a[2] + a[0] + a[1] #=> "cab" a[6] #=> nil a[1, 2] #=> [ "b", "c" ] a[1..3] #=> [ "b", "c", "d" ] a[4..7] #=> [ "e" ] a[6..10] #=> nil a[-3, 3] #=> [ "c", "d", "e" ] # special cases a[5] #=> nil a[6, 1] #=> nil a[5, 1] #=> [] a[5..10] #=> [] @overload [](index) @return [Object, nil] @overload [](start, length) @return [Array, nil] @overload [](range) @return [Array, nil] @overload slice(index) @return [Object, nil] @overload slice(start, length) @return [Array, nil] @overload slice(range) @return [Array, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#[]=;F;[[@0;[[@i;T;;+;0;[;{;IC;"vElement Assignment --- Sets the element at +index+, or replaces a subarray from the +start+ index for +length+ elements, or replaces a subarray specified by the +range+ of indices. If indices are greater than the current capacity of the array, the array grows automatically. Elements are inserted into the array at +start+ if +length+ is zero. Negative indices will count backward from the end of the array. For +start+ and +range+ cases the starting index is just before an element. An IndexError is raised if a negative index points past the beginning of the array. See also Array#push, and Array#unshift. a = Array.new a[4] = "4"; #=> [nil, nil, nil, nil, "4"] a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"] a[1..2] = [ 1, 2 ] #=> ["a", 1, 2, nil, "4"] a[0, 2] = "?" #=> ["?", 2, nil, "4"] a[0..2] = "A" #=> ["A", "4"] a[-1] = "Z" #=> ["A", "Z"] a[1..-1] = nil #=> ["A", nil] a[1..-1] = [] #=> ["A"] a[0, 0] = [ 1, 2 ] #=> [1, 2, "A"] a[3, 0] = "B" #=> [1, 2, "A", "B"] ;T;[o;H ;II" overload;F;J0;;+;K0;#I"[]=(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @r;[;I"@return [Object];T;0; @r;@F;Mi;N0;[[I" index;T0; @ro;H ;II" overload;F;J0;;+;K0;#I"[]=(start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @r;[;I"@return [Object, nil];T;0; @r;@F;Mi;N0;[[I" start;T0[I" length;T0; @ro;H ;II" overload;F;J0;;+;K0;#I"[]=(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @r;[;I"@return [Object, nil];T;0; @r;@F;Mi;N0;[[I" range;T0; @r;[;I"Element Assignment --- Sets the element at +index+, or replaces a subarray from the +start+ index for +length+ elements, or replaces a subarray specified by the +range+ of indices. If indices are greater than the current capacity of the array, the array grows automatically. Elements are inserted into the array at +start+ if +length+ is zero. Negative indices will count backward from the end of the array. For +start+ and +range+ cases the starting index is just before an element. An IndexError is raised if a negative index points past the beginning of the array. See also Array#push, and Array#unshift. a = Array.new a[4] = "4"; #=> [nil, nil, nil, nil, "4"] a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"] a[1..2] = [ 1, 2 ] #=> ["a", 1, 2, nil, "4"] a[0, 2] = "?" #=> ["?", 2, nil, "4"] a[0..2] = "A" #=> ["A", "4"] a[-1] = "Z" #=> ["A", "Z"] a[1..-1] = nil #=> ["A", nil] a[1..-1] = [] #=> ["A"] a[0, 0] = [ 1, 2 ] #=> [1, 2, "A"] a[3, 0] = "B" #=> [1, 2, "A", "B"] @overload []=(index) @return [Object] @overload []=(start, length) @return [Object, nil] @overload []=(range) @return [Object, nil];T;0; @r;@F;Ao;B;CT;Di;Ei;!@T;"I"static VALUE rb_ary_aset(int argc, VALUE *argv, VALUE ary) { long offset, beg, len; VALUE rpl; if (argc == 3) { rb_ary_modify_check(ary); beg = NUM2LONG(argv[0]); len = NUM2LONG(argv[1]); goto range; } rb_check_arity(argc, 2, 2); rb_ary_modify_check(ary); if (FIXNUM_P(argv[0])) { offset = FIX2LONG(argv[0]); goto fixnum; } if (rb_range_beg_len(argv[0], &beg, &len, RARRAY_LEN(ary), 1)) { /* check if idx is Range */ range: rpl = rb_ary_to_ary(argv[argc-1]); rb_ary_splice(ary, beg, len, RARRAY_CONST_PTR_TRANSIENT(rpl), RARRAY_LEN(rpl)); RB_GC_GUARD(rpl); return argv[argc-1]; } offset = NUM2LONG(argv[0]); fixnum: rb_ary_store(ary, offset, argv[1]); return argv[1]; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Array#at;F;[[I"pos;T0;[[@i/;T;;8;0;[;{;IC;"Returns the element at +index+. A negative index counts from the end of +self+. Returns +nil+ if the index is out of range. See also Array#[]. a = [ "a", "b", "c", "d", "e" ] a.at(0) #=> "a" a.at(-1) #=> "e" ;T;[o;H ;II" overload;F;J0;;8;K0;#I"at(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[I" index;T0; @;[;I"Returns the element at +index+. A negative index counts from the end of +self+. Returns +nil+ if the index is out of range. See also Array#[]. a = [ "a", "b", "c", "d", "e" ] a.at(0) #=> "a" a.at(-1) #=> "e" @overload at(index) @return [Object, nil];T;0; @;@F;Ao;B;CT;Di";Ei,;!@T;"I"[VALUE rb_ary_at(VALUE ary, VALUE pos) { return rb_ary_entry(ary, NUM2LONG(pos)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Array#fetch;F;[[@0;[[@i;T;;;0;[;{;IC;"Tries to return the element at position +index+, but throws an IndexError exception if the referenced +index+ lies outside of the array bounds. This error can be prevented by supplying a second argument, which will act as a +default+ value. Alternatively, if a block is given it will only be executed when an invalid +index+ is referenced. Negative values of +index+ count from the end of the array. a = [ 11, 22, 33, 44 ] a.fetch(1) #=> 22 a.fetch(-1) #=> 44 a.fetch(4, 'cat') #=> "cat" a.fetch(100) {|i| puts "#{i} is out of bounds"} #=> "100 is out of bounds" ;T;[o;H ;II" overload;F;J0;;;K0;#I"fetch(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" index;T0; @o;H ;II" overload;F;J0;;;K0;#I"fetch(index, default);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I" index;T0[I" default;T0; @o;H ;II" overload;F;J0;;;K0;#I"fetch(index);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" index;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"$@yield [index] @return [Object];T;0; @;@F;Mi;N0;[[I" index;T0; @;[;I"Tries to return the element at position +index+, but throws an IndexError exception if the referenced +index+ lies outside of the array bounds. This error can be prevented by supplying a second argument, which will act as a +default+ value. Alternatively, if a block is given it will only be executed when an invalid +index+ is referenced. Negative values of +index+ count from the end of the array. a = [ 11, 22, 33, 44 ] a.fetch(1) #=> 22 a.fetch(-1) #=> 44 a.fetch(4, 'cat') #=> "cat" a.fetch(100) {|i| puts "#{i} is out of bounds"} #=> "100 is out of bounds" @overload fetch(index) @return [Object] @overload fetch(index, default) @return [Object] @overload fetch(index) @yield [index] @return [Object];T;0; @;@F;Ao;B;CT;Dil;Ei;!@T;"I"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; ; F; ;,;;;I"Array#first;F;[[@0;[[@iD;T;;;0;[;{;IC;"%Returns the first element, or the first +n+ elements, of the array. If the array is empty, the first form returns +nil+, and the second form returns an empty array. See also Array#last for the opposite effect. a = [ "q", "r", "s", "t" ] a.first #=> "q" a.first(2) #=> ["q", "r"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" first;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" first(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"n;T0; @;[;I"tReturns the first element, or the first +n+ elements, of the array. If the array is empty, the first form returns +nil+, and the second form returns an empty array. See also Array#last for the opposite effect. a = [ "q", "r", "s", "t" ] a.first #=> "q" a.first(2) #=> ["q", "r"] @overload first @return [Object, nil] @overload first(n) @return [Array];T;0; @;@F;Ao;B;CT;Di5;EiB;!@T;"I"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; ; F; ;,;;;I"Array#last;F;[[@0;[[@i_;T;: last;0;[;{;IC;"Returns the last element(s) of +self+. If the array is empty, the first form returns +nil+. See also Array#first for the opposite effect. a = [ "w", "x", "y", "z" ] a.last #=> "z" a.last(2) #=> ["y", "z"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" last;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @A;[;I"@return [Object, nil];T;0; @A;@F;Mi;N0;[; @Ao;H ;II" overload;F;J0;;;K0;#I" last(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @A;[;I"@return [Array];T;0; @A;@F;Mi;N0;[[I"n;T0; @A;[;I")Returns the last element(s) of +self+. If the array is empty, the first form returns +nil+. See also Array#first for the opposite effect. a = [ "w", "x", "y", "z" ] a.last #=> "z" a.last(2) #=> ["y", "z"] @overload last @return [Object, nil] @overload last(n) @return [Array];T;0; @A;@F;Ao;B;CT;DiP;Ei];!@T;"I"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; ; F; ;,;;;I"Array#concat;F;[[@0;[[@i;T;;P;0;[;{;IC;"Appends the elements of other_arys to +self+. [ "a", "b" ].concat( ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat( ["b"], ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat #=> [ "a" ] a = [ 1, 2, 3 ] a.concat( [ 4, 5 ]) a #=> [ 1, 2, 3, 4, 5 ] a = [ 1, 2 ] a.concat(a, a) #=> [1, 2, 1, 2, 1, 2] See also Array#+. ;T;[o;H ;II" overload;F;J0;;P;K0;#I"(concat(other_ary1, other_ary2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @m;[;I"@return [Array];T;0; @m;@F;Mi;N0;[[I"other_ary1;T0[I"other_ary2;T0[I"...;T0; @m;[;I"Appends the elements of other_arys to +self+. [ "a", "b" ].concat( ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat( ["b"], ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat #=> [ "a" ] a = [ 1, 2, 3 ] a.concat( [ 4, 5 ]) a #=> [ 1, 2, 3, 4, 5 ] a = [ 1, 2 ] a.concat(a, a) #=> [1, 2, 1, 2, 1, 2] See also Array#+. @overload concat(other_ary1, other_ary2, ...) @return [Array];T;0; @m;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#union;F;[[@0;[[@iO;T;; ;0;[;{;IC;"Set Union --- Returns a new array by joining other_arys with +self+, excluding any duplicates and preserving the order from the given arrays. It compares elements using their #hash and #eql? methods for efficiency. [ "a", "b", "c" ].union( [ "c", "d", "a" ] ) #=> [ "a", "b", "c", "d" ] [ "a" ].union( ["e", "b"], ["a", "c", "b"] ) #=> [ "a", "e", "b", "c" ] [ "a" ].union #=> [ "a" ] See also Array#|. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"'union(other_ary1, other_ary2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary1;T0[I"other_ary2;T0[I"...;T0; @;[;I"Set Union --- Returns a new array by joining other_arys with +self+, excluding any duplicates and preserving the order from the given arrays. It compares elements using their #hash and #eql? methods for efficiency. [ "a", "b", "c" ].union( [ "c", "d", "a" ] ) #=> [ "a", "b", "c", "d" ] [ "a" ].union( ["e", "b"], ["a", "c", "b"] ) #=> [ "a", "e", "b", "c" ] [ "a" ].union #=> [ "a" ] See also Array#|. @overload union(other_ary1, other_ary2, ...) @return [Array];T;0; @;@F;Ao;B;CT;Di?;EiL;!@T;"I"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; ; F; ;,;;;I"Array#difference;F;[[@0;[[@i;T;:difference;0;[;{;IC;"Array Difference Returns a new array that is a copy of the receiver, removing any items that also appear in any of the arrays given as arguments. The order is preserved from the original array. It compares elements using their #hash and #eql? methods for efficiency. [ 1, 1, 2, 2, 3, 3, 4, 5 ].difference([ 1, 2, 4 ]) #=> [ 3, 3, 5 ] [ 1, 'c', :s, 'yep' ].difference([ 1 ], [ 'a', 'c' ]) #=> [ :s, "yep" ] If you need set-like behavior, see the library class Set. See also Array#-. ;T;[o;H ;II" overload;F;J0;;;K0;#I",difference(other_ary1, other_ary2, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary1;T0[I"other_ary2;T0[I"...;T0; @;[;I"7Array Difference Returns a new array that is a copy of the receiver, removing any items that also appear in any of the arrays given as arguments. The order is preserved from the original array. It compares elements using their #hash and #eql? methods for efficiency. [ 1, 1, 2, 2, 3, 3, 4, 5 ].difference([ 1, 2, 4 ]) #=> [ 3, 3, 5 ] [ 1, 'c', :s, 'yep' ].difference([ 1 ], [ 'a', 'c' ]) #=> [ :s, "yep" ] If you need set-like behavior, see the library class Set. See also Array#-. @overload difference(other_ary1, other_ary2, ...) @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I" Array#<<;F;[[I" item;T0;[[@i;T;;Q;0;[;{;IC;""Append---Pushes the given object on to the end of this array. This expression returns the array itself, so several appends may be chained together. a = [ 1, 2 ] a << "c" << "d" << [ 3, 4 ] #=> [ 1, 2, "c", "d", [ 3, 4 ] ] a #=> [ 1, 2, "c", "d", [ 3, 4 ] ] ;T;[o;H ;II" overload;F;J0;;Q;K0;#I" <<(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"IAppend---Pushes the given object on to the end of this array. This expression returns the array itself, so several appends may be chained together. a = [ 1, 2 ] a << "c" << "d" << [ 3, 4 ] #=> [ 1, 2, "c", "d", [ 3, 4 ] ] a #=> [ 1, 2, "c", "d", [ 3, 4 ] ] @overload <<(obj) @return [Array];T;0; @;@F;Ao;B;CT;Dio;Ei|;!@T;"I"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; ; F; ;,;;;I"Array#push;F;[[@0;[[@i;T;;;0;[;{;IC;"aAppend --- Pushes the given object(s) on to the end of this array. This expression returns the array itself, so several appends may be chained together. See also Array#pop for the opposite effect. a = [ "a", "b", "c" ] a.push("d", "e", "f") #=> ["a", "b", "c", "d", "e", "f"] [1, 2, 3].push(4).push(5) #=> [1, 2, 3, 4, 5] ;T;[o;H ;II" overload;F;J0;;;K0;#I"push(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0[I"...;T0; @o;H ;II" overload;F;J0;: append;K0;#I"append(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0[I"...;T0; @;[;I"Append --- Pushes the given object(s) on to the end of this array. This expression returns the array itself, so several appends may be chained together. See also Array#pop for the opposite effect. a = [ "a", "b", "c" ] a.push("d", "e", "f") #=> ["a", "b", "c", "d", "e", "f"] [1, 2, 3].push(4).push(5) #=> [1, 2, 3, 4, 5] @overload push(obj, ...) @return [Array] @overload append(obj, ...) @return [Array];T;0; o; ; F; ;,;;;I"Array#append;F;[;[[@i;F;;;;0;[;{;@;!@T;"I"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;Ao;B;CT;Di;Ei;!@T;"I"mstatic VALUE rb_ary_push_m(int argc, VALUE *argv, VALUE ary) { return rb_ary_cat(ary, argv, argc); };T;#@(;$T@ o; ; F; ;,;;;I"Array#pop;F;[[@0;[[@i;T;;;0;[;{;IC;"hRemoves the last element from +self+ and returns it, or +nil+ if the array is empty. If a number +n+ is given, returns an array of the last +n+ elements (or less) just like array.slice!(-n, n) does. See also Array#push for the opposite effect. a = [ "a", "b", "c", "d" ] a.pop #=> "d" a.pop(2) #=> ["b", "c"] a #=> ["a"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"pop;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @+;[;I"@return [Object, nil];T;0; @+;@F;Mi;N0;[; @+o;H ;II" overload;F;J0;;;K0;#I" pop(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @+;[;I"@return [Array];T;0; @+;@F;Mi;N0;[[I"n;T0; @+;[;I"Removes the last element from +self+ and returns it, or +nil+ if the array is empty. If a number +n+ is given, returns an array of the last +n+ elements (or less) just like array.slice!(-n, n) does. See also Array#push for the opposite effect. a = [ "a", "b", "c", "d" ] a.pop #=> "d" a.pop(2) #=> ["b", "c"] a #=> ["a"] @overload pop @return [Object, nil] @overload pop(n) @return [Array];T;0; @+;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#shift;F;[[@0;[[@i;T;;;0;[;{;IC;"hRemoves the first element of +self+ and returns it (shifting all other elements down by one). Returns +nil+ if the array is empty. If a number +n+ is given, returns an array of the first +n+ elements (or less) just like array.slice!(0, n) does. With +ary+ containing only the remainder elements, not including what was shifted to +new_ary+. See also Array#unshift for the opposite effect. args = [ "-m", "-q", "filename" ] args.shift #=> "-m" args #=> ["-q", "filename"] args = [ "-m", "-q", "filename" ] args.shift(2) #=> ["-m", "-q"] args #=> ["filename"] ;T;[o;H ;II" overload;F;J0;;;K0;#I" shift;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @W;[;I"@return [Object, nil];T;0; @W;@F;Mi;N0;[; @Wo;H ;II" overload;F;J0;;;K0;#I" shift(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @W;[;I"@return [Array];T;0; @W;@F;Mi;N0;[[I"n;T0; @W;[;I"Removes the first element of +self+ and returns it (shifting all other elements down by one). Returns +nil+ if the array is empty. If a number +n+ is given, returns an array of the first +n+ elements (or less) just like array.slice!(0, n) does. With +ary+ containing only the remainder elements, not including what was shifted to +new_ary+. See also Array#unshift for the opposite effect. args = [ "-m", "-q", "filename" ] args.shift #=> "-m" args #=> ["-q", "filename"] args = [ "-m", "-q", "filename" ] args.shift(2) #=> ["-m", "-q"] args #=> ["filename"] @overload shift @return [Object, nil] @overload shift(n) @return [Array];T;0; @W;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#unshift;F;[[@0;[[@i;T;: unshift;0;[;{;IC;"Prepends objects to the front of +self+, moving other elements upwards. See also Array#shift for the opposite effect. a = [ "b", "c", "d" ] a.unshift("a") #=> ["a", "b", "c", "d"] a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"unshift(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0[I"...;T0; @o;H ;II" overload;F;J0;;R;K0;#I"prepend(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0[I"...;T0; @;[;I"NPrepends objects to the front of +self+, moving other elements upwards. See also Array#shift for the opposite effect. a = [ "b", "c", "d" ] a.unshift("a") #=> ["a", "b", "c", "d"] a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"] @overload unshift(obj, ...) @return [Array] @overload prepend(obj, ...) @return [Array];T;0; o; ; F; ;,;;;I"Array#prepend;F;[;[[@i;F;;R;;0;[;{;@;!@T;"I"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;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#insert;F;[[@0;[[@i;T;;,;0;[;{;IC;"Inserts the given values before the element with the given +index+. Negative indices count backwards from the end of the array, where +-1+ is the last element. If a negative index is used, the given values will be inserted after that element, so using an index of +-1+ will insert the values at the end of the array. a = %w{ a b c d } a.insert(2, 99) #=> ["a", "b", 99, "c", "d"] a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"] ;T;[o;H ;II" overload;F;J0;;,;K0;#I"insert(index, obj...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" index;T0[I" obj...;T0; @;[;I"Inserts the given values before the element with the given +index+. Negative indices count backwards from the end of the array, where +-1+ is the last element. If a negative index is used, the given values will be inserted after that element, so using an index of +-1+ will insert the values at the end of the array. a = %w{ a b c d } a.insert(2, 99) #=> ["a", "b", 99, "c", "d"] a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"] @overload insert(index, obj...) @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#each;F;[;[[@i ;T;;;0;[;{;IC;"Calls the given block once for each element in +self+, passing that element as a parameter. Returns the array itself. If no block is given, an Enumerator is returned. a = [ "a", "b", "c" ] a.each {|x| print x, " -- " } produces: a -- b -- c -- ;T;[o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"ZCalls the given block once for each element in +self+, passing that element as a parameter. Returns the array itself. If no block is given, an Enumerator is returned. a = [ "a", "b", "c" ] a.each {|x| print x, " -- " } produces: a -- b -- c -- @overload each @yield [item] @return [Array] @overload each @return [Enumerator];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"VALUE rb_ary_each(VALUE ary) { long i; ary_verify(ary); RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); for (i=0; i;T;:each_index;0;[;{;IC;"Same as Array#each, but passes the +index+ of the element instead of the element itself. An Enumerator is returned if no block is given. a = [ "a", "b", "c" ] a.each_index {|x| print x, " -- " } produces: 0 -- 1 -- 2 -- ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" index;T; @ o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"#@yield [index] @return [Array];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I"each_index;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @ ;[;I"@return [Enumerator];T;0; @ ;@F;Mi;N0;[; @ ;[;I"NSame as Array#each, but passes the +index+ of the element instead of the element itself. An Enumerator is returned if no block is given. a = [ "a", "b", "c" ] a.each_index {|x| print x, " -- " } produces: 0 -- 1 -- 2 -- @overload each_index @yield [index] @return [Array] @overload each_index @return [Enumerator];T;0; @ ;@F;Ao;B;CT;Di,;Ei=;!@T;"I"static VALUE rb_ary_each_index(VALUE ary) { long i; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); for (i=0; i 5 [].length #=> 0 ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @c;[;I"@return [Integer];T;0; @c;@F;Mi;N0;[; @c;[;I"Returns the number of elements in +self+. May be zero. [ 1, 2, 3, 4, 5 ].length #=> 5 [].length #=> 0 @overload length @return [Integer];T;0; o; ; F; ;,;;;I"Array#size;F;[;[[@i;F;;;;0;[;{;@j;!@T;"I"hstatic VALUE rb_ary_length(VALUE ary) { long len = RARRAY_LEN(ary); return LONG2NUM(len); };T;#I"static VALUE;T;@F;Ao;B;CT;Dik;Eir;!@T;"I"hstatic VALUE rb_ary_length(VALUE ary) { long len = RARRAY_LEN(ary); return LONG2NUM(len); };T;#@;$T@{o; ; F; ;,;;;I"Array#empty?;F;[;[[@i;T;;;0;[;{;IC;"LReturns +true+ if +self+ contains no elements. [].empty? #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"sReturns +true+ if +self+ contains no elements. [].empty? #=> true @overload empty? @return [Boolean];T;0; @;@F;Ao;B;CT;Di|;Ei;Mi;!@T;"I"ostatic VALUE rb_ary_empty_p(VALUE ary) { if (RARRAY_LEN(ary) == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#find_index;F;[[@0;[[@i;T;; ;0;[;{;IC;"Returns the _index_ of the first object in +ary+ such that the object is == to +obj+. If a block is given instead of an argument, returns the _index_ of the first object for which the block returns +true+. Returns +nil+ if no match is found. See also Array#rindex. An Enumerator is returned if neither a block nor argument is given. a = [ "a", "b", "c" ] a.index("b") #=> 1 a.index("z") #=> nil a.index {|x| x == "b"} #=> 1 ;T;[ o;H ;II" overload;F;J0;; ;K0;#I"find_index(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;; ;K0;#I"find_index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I")@yield [item] @return [Integer, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I"find_index;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [ Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;1;K0;#I"index(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;1;K0;#I" index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I")@yield [item] @return [Integer, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;1;K0;#I" index;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [ Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"Returns the _index_ of the first object in +ary+ such that the object is == to +obj+. If a block is given instead of an argument, returns the _index_ of the first object for which the block returns +true+. Returns +nil+ if no match is found. See also Array#rindex. An Enumerator is returned if neither a block nor argument is given. a = [ "a", "b", "c" ] a.index("b") #=> 1 a.index("z") #=> nil a.index {|x| x == "b"} #=> 1 @overload find_index(obj) @return [Integer, nil] @overload find_index @yield [item] @return [Integer, nil] @overload find_index @return [ Enumerator] @overload index(obj) @return [Integer, nil] @overload index @yield [item] @return [Integer, nil] @overload index @return [ Enumerator];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; i== to +obj+. If a block is given instead of an argument, returns the _index_ of the first object for which the block returns +true+. Returns +nil+ if no match is found. See also Array#rindex. An Enumerator is returned if neither a block nor argument is given. a = [ "a", "b", "c" ] a.index("b") #=> 1 a.index("z") #=> nil a.index {|x| x == "b"} #=> 1 ;T;[ o;H ;II" overload;F;J0;; ;K0;#I"find_index(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;; ;K0;#I"find_index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I")@yield [item] @return [Integer, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I"find_index;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [ Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;1;K0;#I"index(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"@return [Integer, nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;1;K0;#I" index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I")@yield [item] @return [Integer, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;1;K0;#I" index;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [ Enumerator];T;0; @;@F;Mi;N0;[; @;[;@ ;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; i== to +obj+. If a block is given instead of an argument, returns the _index_ of the first object for which the block returns +true+, starting from the last object. Returns +nil+ if no match is found. See also Array#index. If neither block nor argument is given, an Enumerator is returned instead. a = [ "a", "b", "b", "b", "c" ] a.rindex("b") #=> 3 a.rindex("z") #=> nil a.rindex {|x| x == "b"} #=> 3 ;T;[o;H ;II" overload;F;J0;;2;K0;#I"rindex(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @~;[;I"@return [Integer, nil];T;0; @~;@F;Mi;N0;[[I"obj;T0; @~o;H ;II" overload;F;J0;;2;K0;#I" rindex;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @~o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @~;[;I")@yield [item] @return [Integer, nil];T;0; @~;@F;Mi;N0;[; @~o;H ;II" overload;F;J0;;2;K0;#I" rindex;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @~;[;I"@return [ Enumerator];T;0; @~;@F;Mi;N0;[; @~;[;I"Returns the _index_ of the last object in +self+ == to +obj+. If a block is given instead of an argument, returns the _index_ of the first object for which the block returns +true+, starting from the last object. Returns +nil+ if no match is found. See also Array#index. If neither block nor argument is given, an Enumerator is returned instead. a = [ "a", "b", "b", "b", "c" ] a.rindex("b") #=> 3 a.rindex("z") #=> nil a.rindex {|x| x == "b"} #=> 3 @overload rindex(obj) @return [Integer, nil] @overload rindex @yield [item] @return [Integer, nil] @overload rindex @return [ Enumerator];T;0; @~;@F;Ao;B;CT;Di;Ei;!@T;"I";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); } } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#join;F;[[@0;[[@i4 ;T;;.;0;[;{;IC;"Returns a string created by converting each element of the array to a string, separated by the given +separator+. If the +separator+ is +nil+, it uses current $,. If both the +separator+ and $, are +nil+, it uses an empty string. [ "a", "b", "c" ].join #=> "abc" [ "a", "b", "c" ].join("-") #=> "a-b-c" For nested arrays, join is applied recursively: [ "a", [1, 2, [:x, :y]], "b" ].join("-") #=> "a-1-2-x-y-b" ;T;[o;H ;II" overload;F;J0;;.;K0;#I"join(separator=$,);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"separator;TI"$,;T; @;[;I"Returns a string created by converting each element of the array to a string, separated by the given +separator+. If the +separator+ is +nil+, it uses current $,. If both the +separator+ and $, are +nil+, it uses an empty string. [ "a", "b", "c" ].join #=> "abc" [ "a", "b", "c" ].join("-") #=> "a-b-c" For nested arrays, join is applied recursively: [ "a", [1, 2, [:x, :y]], "b" ].join("-") #=> "a-1-2-x-y-b" @overload join(separator=$,) @return [String];T;0; @;@F;Ao;B;CT;Di" ;Ei1 ;!@T;"I"static VALUE rb_ary_join_m(int argc, VALUE *argv, VALUE ary) { VALUE sep; if (rb_check_arity(argc, 0, 1) == 0) { sep = rb_output_fs; } else if (NIL_P(sep = argv[0])) { sep = rb_output_fs; } return rb_ary_join(ary, sep); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#reverse;F;[;[[@i ;T;;N;0;[;{;IC;"Returns a new array containing +self+'s elements in reverse order. [ "a", "b", "c" ].reverse #=> ["c", "b", "a"] [ 1 ].reverse #=> [1] ;T;[o;H ;II" overload;F;J0;;N;K0;#I" reverse;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Returns a new array containing +self+'s elements in reverse order. [ "a", "b", "c" ].reverse #=> ["c", "b", "a"] [ 1 ].reverse #=> [1] @overload reverse @return [Array];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#reverse!;F;[;[[@i ;T;;O;0;[;{;IC;"Reverses +self+ in place. a = [ "a", "b", "c" ] a.reverse! #=> ["c", "b", "a"] a #=> ["c", "b", "a"] ;T;[o;H ;II" overload;F;J0;;O;K0;#I" reverse!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Reverses +self+ in place. a = [ "a", "b", "c" ] a.reverse! #=> ["c", "b", "a"] a #=> ["c", "b", "a"] @overload reverse! @return [Array];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I"Tstatic VALUE rb_ary_reverse_bang(VALUE ary) { return rb_ary_reverse(ary); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#rotate;F;[[@0;[[@iF ;T;: rotate;0;[;{;IC;"Returns a new array by rotating +self+ so that the element at +count+ is the first element of the new array. If +count+ is negative then it rotates in the opposite direction, starting from the end of +self+ where +-1+ is the last element. a = [ "a", "b", "c", "d" ] a.rotate #=> ["b", "c", "d", "a"] a #=> ["a", "b", "c", "d"] a.rotate(2) #=> ["c", "d", "a", "b"] a.rotate(-3) #=> ["b", "c", "d", "a"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"rotate(count=1);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" count;TI"1;T; @;[;I"Returns a new array by rotating +self+ so that the element at +count+ is the first element of the new array. If +count+ is negative then it rotates in the opposite direction, starting from the end of +self+ where +-1+ is the last element. a = [ "a", "b", "c", "d" ] a.rotate #=> ["b", "c", "d", "a"] a #=> ["a", "b", "c", "d"] a.rotate(2) #=> ["c", "d", "a", "b"] a.rotate(-3) #=> ["b", "c", "d", "a"] @overload rotate(count=1) @return [Array];T;0; @;@F;Ao;B;CT;Di5 ;EiC ;!@T;"I"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; ; F; ;,;;;I"Array#rotate!;F;[[@0;[[@i- ;T;: rotate!;0;[;{;IC;"Rotates +self+ in place so that the element at +count+ comes first, and returns +self+. If +count+ is negative then it rotates in the opposite direction, starting from the end of the array where +-1+ is the last element. a = [ "a", "b", "c", "d" ] a.rotate! #=> ["b", "c", "d", "a"] a #=> ["b", "c", "d", "a"] a.rotate!(2) #=> ["d", "a", "b", "c"] a.rotate!(-3) #=> ["a", "b", "c", "d"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"rotate!(count=1);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @1;[;I"@return [Array];T;0; @1;@F;Mi;N0;[[I" count;TI"1;T; @1;[;I"Rotates +self+ in place so that the element at +count+ comes first, and returns +self+. If +count+ is negative then it rotates in the opposite direction, starting from the end of the array where +-1+ is the last element. a = [ "a", "b", "c", "d" ] a.rotate! #=> ["b", "c", "d", "a"] a #=> ["b", "c", "d", "a"] a.rotate!(2) #=> ["d", "a", "b", "c"] a.rotate!(-3) #=> ["a", "b", "c", "d"] @overload rotate!(count=1) @return [Array];T;0; @1;@F;Ao;B;CT;Di ;Ei* ;!@T;"I"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; ; F; ;,;;;I"Array#sort;F;[;[[@i ;T;;;0;[;{;IC;"Returns a new array created by sorting +self+. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block must implement a comparison between +a+ and +b+ and return an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ are equivalent, or an integer greater than 0 when +a+ follows +b+. The result is not guaranteed to be stable. When the comparison of two elements returns +0+, the order of the elements is unpredictable. ary = [ "d", "a", "e", "c", "b" ] ary.sort #=> ["a", "b", "c", "d", "e"] ary.sort {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"] See also Enumerable#sort_by. ;T;[o;H ;II" overload;F;J0;;;K0;#I" sort;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @P;[;I"@return [Array];T;0; @P;@F;Mi;N0;[; @Po;H ;II" overload;F;J0;;;K0;#I" sort;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @Po;L ;II" return;F;JI";T;0;K[I" Array;T; @P;[;I""@yield [a, b] @return [Array];T;0; @P;@F;Mi;N0;[; @P;[;I"Returns a new array created by sorting +self+. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block must implement a comparison between +a+ and +b+ and return an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ are equivalent, or an integer greater than 0 when +a+ follows +b+. The result is not guaranteed to be stable. When the comparison of two elements returns +0+, the order of the elements is unpredictable. ary = [ "d", "a", "e", "c", "b" ] ary.sort #=> ["a", "b", "c", "d", "e"] ary.sort {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"] See also Enumerable#sort_by. @overload sort @return [Array] @overload sort @yield [a, b] @return [Array];T;0; @P;@F;Ao;B;CT;Di ;Ei ;!@T;"I"kVALUE rb_ary_sort(VALUE ary) { ary = rb_ary_dup(ary); rb_ary_sort_bang(ary); return ary; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Array#sort!;F;[;[[@i ;T;: sort!;0;[;{;IC;"Sorts +self+ in place. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block must implement a comparison between +a+ and +b+ and return an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ are equivalent, or an integer greater than 0 when +a+ follows +b+. The result is not guaranteed to be stable. When the comparison of two elements returns +0+, the order of the elements is unpredictable. ary = [ "d", "a", "e", "c", "b" ] ary.sort! #=> ["a", "b", "c", "d", "e"] ary.sort! {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"] See also Enumerable#sort_by. ;T;[o;H ;II" overload;F;J0;;;K0;#I" sort!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @~;[;I"@return [Array];T;0; @~;@F;Mi;N0;[; @~o;H ;II" overload;F;J0;;;K0;#I" sort!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @~o;L ;II" return;F;JI";T;0;K[I" Array;T; @~;[;I""@yield [a, b] @return [Array];T;0; @~;@F;Mi;N0;[; @~;[;I"Sorts +self+ in place. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block must implement a comparison between +a+ and +b+ and return an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ are equivalent, or an integer greater than 0 when +a+ follows +b+. The result is not guaranteed to be stable. When the comparison of two elements returns +0+, the order of the elements is unpredictable. ary = [ "d", "a", "e", "c", "b" ] ary.sort! #=> ["a", "b", "c", "d", "e"] ary.sort! {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"] See also Enumerable#sort_by. @overload sort! @return [Array] @overload sort! @yield [a, b] @return [Array];T;0; @~;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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.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; ; F; ;,;;;I"Array#sort_by!;F;[;[[@i ;T;: sort_by!;0;[;{;IC;"DSorts +self+ in place using a set of keys generated by mapping the values in +self+ through the given block. The result is not guaranteed to be stable. When two keys are equal, the order of the corresponding elements is unpredictable. If no block is given, an Enumerator is returned instead. See also Enumerable#sort_by. ;T;[o;H ;II" overload;F;J0;;;K0;#I" sort_by!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"!@yield [obj] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" sort_by!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"Sorts +self+ in place using a set of keys generated by mapping the values in +self+ through the given block. The result is not guaranteed to be stable. When two keys are equal, the order of the corresponding elements is unpredictable. If no block is given, an Enumerator is returned instead. See also Enumerable#sort_by. @overload sort_by! @yield [obj] @return [Array] @overload sort_by! @return [Enumerator];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#collect;F;[;[[@i ;T;;;0;[;{;IC;"Invokes the given block once for each element of +self+. Creates a new array containing the values returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.collect {|x| x + "!"} #=> ["a!", "b!", "c!", "d!"] a.map.with_index {|x, i| x * i} #=> ["", "b", "cc", "ddd"] a #=> ["a", "b", "c", "d"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"map;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"eInvokes the given block once for each element of +self+. Creates a new array containing the values returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.collect {|x| x + "!"} #=> ["a!", "b!", "c!", "d!"] a.map.with_index {|x, i| x * i} #=> ["", "b", "cc", "ddd"] a #=> ["a", "b", "c", "d"] @overload collect @yield [item] @return [Array] @overload map @yield [item] @return [Array] @overload collect @return [Enumerator] @overload map @return [Enumerator];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#collect!;F;[;[[@i ;T;: collect!;0;[;{;IC;"uInvokes the given block once for each element of +self+, replacing the element with the value returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.map! {|x| x + "!" } a #=> [ "a!", "b!", "c!", "d!" ] a.collect!.with_index {|x, i| x[0...i] } a #=> ["", "b", "c!", "d!"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" collect!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @%o;L ;II" return;F;JI";T;0;K[I" Array;T; @%;[;I""@yield [item] @return [Array];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;: map!;K0;#I" map!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @%o;L ;II" return;F;JI";T;0;K[I" Array;T; @%;[;I""@yield [item] @return [Array];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;;;K0;#I" collect!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @%;[;I"@return [Enumerator];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;;;K0;#I" map!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @%;[;I"@return [Enumerator];T;0; @%;@F;Mi;N0;[; @%;[;I"-Invokes the given block once for each element of +self+, replacing the element with the value returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.map! {|x| x + "!" } a #=> [ "a!", "b!", "c!", "d!" ] a.collect!.with_index {|x, i| x[0...i] } a #=> ["", "b", "c!", "d!"] @overload collect! @yield [item] @return [Array] @overload map! @yield [item] @return [Array] @overload collect! @return [Enumerator] @overload map! @return [Enumerator];T;0; @%;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#map;F;[;[[@i ;T;;;0;[;{;IC;"Invokes the given block once for each element of +self+. Creates a new array containing the values returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.collect {|x| x + "!"} #=> ["a!", "b!", "c!", "d!"] a.map.with_index {|x, i| x * i} #=> ["", "b", "cc", "ddd"] a #=> ["a", "b", "c", "d"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @qo;L ;II" return;F;JI";T;0;K[I" Array;T; @q;[;I""@yield [item] @return [Array];T;0; @q;@F;Mi;N0;[; @qo;H ;II" overload;F;J0;;;K0;#I"map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @qo;L ;II" return;F;JI";T;0;K[I" Array;T; @q;[;I""@yield [item] @return [Array];T;0; @q;@F;Mi;N0;[; @qo;H ;II" overload;F;J0;;;K0;#I" collect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @q;[;I"@return [Enumerator];T;0; @q;@F;Mi;N0;[; @qo;H ;II" overload;F;J0;;;K0;#I"map;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @q;[;I"@return [Enumerator];T;0; @q;@F;Mi;N0;[; @q;[;@!;0; @q;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#map!;F;[;[[@i ;T;;;0;[;{;IC;"uInvokes the given block once for each element of +self+, replacing the element with the value returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.map! {|x| x + "!" } a #=> [ "a!", "b!", "c!", "d!" ] a.collect!.with_index {|x, i| x[0...i] } a #=> ["", "b", "c!", "d!"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" collect!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" map!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" collect!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" map!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;@m;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#select;F;[;[[@i\ ;T;;;0;[;{;IC;"pReturns a new array containing all elements of +ary+ for which the given +block+ returns a true value. If no block is given, an Enumerator is returned instead. [1,2,3,4,5].select {|num| num.even? } #=> [2, 4] a = %w[ a b c d e f ] a.select {|v| v =~ /[aeiou]/ } #=> ["a", "e"] See also Enumerable#select. Array#filter is an alias for Array#select. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"(Returns a new array containing all elements of +ary+ for which the given +block+ returns a true value. If no block is given, an Enumerator is returned instead. [1,2,3,4,5].select {|num| num.even? } #=> [2, 4] a = %w[ a b c d e f ] a.select {|v| v =~ /[aeiou]/ } #=> ["a", "e"] See also Enumerable#select. Array#filter is an alias for Array#select. @overload select @yield [item] @return [Array] @overload select @return [Enumerator] @overload filter @yield [item] @return [Array] @overload filter @return [Enumerator];T;0; @;@F;Ao;B;CT;DiF ;Ei^ ;!@T;"I"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; ; F; ;,;;;I"Array#select!;F;[;[[@i ;T;;;0;[;{;IC;"Invokes the given block passing in successive elements from +self+, deleting elements for which the block returns a +false+ value. The array may not be changed instantly every time the block is called. If changes were made, it will return +self+, otherwise it returns +nil+. If no block is given, an Enumerator is returned instead. See also Array#keep_if. Array#filter! is an alias for Array#select!. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @So;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @S;[;I"'@yield [item] @return [Array, nil];T;0; @S;@F;Mi;N0;[; @So;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @S;[;I"@return [Enumerator];T;0; @S;@F;Mi;N0;[; @So;H ;II" overload;F;J0;;;K0;#I" filter!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @So;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @S;[;I"'@yield [item] @return [Array, nil];T;0; @S;@F;Mi;N0;[; @So;H ;II" overload;F;J0;;;K0;#I" filter!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @S;[;I"@return [Enumerator];T;0; @S;@F;Mi;N0;[; @S;[;I"[Invokes the given block passing in successive elements from +self+, deleting elements for which the block returns a +false+ value. The array may not be changed instantly every time the block is called. If changes were made, it will return +self+, otherwise it returns +nil+. If no block is given, an Enumerator is returned instead. See also Array#keep_if. Array#filter! is an alias for Array#select!. @overload select! @yield [item] @return [Array, nil] @overload select! @return [Enumerator] @overload filter! @yield [item] @return [Array, nil] @overload filter! @return [Enumerator];T;0; @S;@F;Ao;B;CT;Di ;Ei ;!@T;"I".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; ; F; ;,;;;I"Array#filter;F;[;[[@i\ ;T;;;0;[;{;IC;"pReturns a new array containing all elements of +ary+ for which the given +block+ returns a true value. If no block is given, an Enumerator is returned instead. [1,2,3,4,5].select {|num| num.even? } #=> [2, 4] a = %w[ a b c d e f ] a.select {|v| v =~ /[aeiou]/ } #=> ["a", "e"] See also Enumerable#select. Array#filter is an alias for Array#select. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" filter;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;@O;0; @;@F;Ao;B;CT;DiF ;Ei^ ;!@T;"I"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; ; F; ;,;;;I"Array#filter!;F;[;[[@i ;T;;;0;[;{;IC;"Invokes the given block passing in successive elements from +self+, deleting elements for which the block returns a +false+ value. The array may not be changed instantly every time the block is called. If changes were made, it will return +self+, otherwise it returns +nil+. If no block is given, an Enumerator is returned instead. See also Array#keep_if. Array#filter! is an alias for Array#select!. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"'@yield [item] @return [Array, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" select!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" filter!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"'@yield [item] @return [Array, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" filter!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I".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; ; F; ;,;;;I"Array#keep_if;F;[;[[@i ;T;;;0;[;{;IC;":Deletes every element of +self+ for which the given block evaluates to +false+, and returns +self+. If no block is given, an Enumerator is returned instead. a = %w[ a b c d e f ] a.keep_if {|v| v =~ /[aeiou]/ } #=> ["a", "e"] a #=> ["a", "e"] See also Array#select!. ;T;[o;H ;II" overload;F;J0;;;K0;#I" keep_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @9o;L ;II" return;F;JI";T;0;K[I" Array;T; @9;[;I""@yield [item] @return [Array];T;0; @9;@F;Mi;N0;[; @9o;H ;II" overload;F;J0;;;K0;#I" keep_if;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @9;[;I"@return [Enumerator];T;0; @9;@F;Mi;N0;[; @9;[;I"Deletes every element of +self+ for which the given block evaluates to +false+, and returns +self+. If no block is given, an Enumerator is returned instead. a = %w[ a b c d e f ] a.keep_if {|v| v =~ /[aeiou]/ } #=> ["a", "e"] a #=> ["a", "e"] See also Array#select!. @overload keep_if @yield [item] @return [Array] @overload keep_if @return [Enumerator];T;0; @9;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#values_at;F;[[@0;[[@i9 ;T;;;0;[;{;IC;"Returns an array containing the elements in +self+ corresponding to the given +selector+(s). The selectors may be either integer indices or ranges. See also Array#select. a = %w{ a b c d e f } a.values_at(1, 3, 5) # => ["b", "d", "f"] a.values_at(1, 3, 5, 7) # => ["b", "d", "f", nil] a.values_at(-1, -2, -2, -7) # => ["f", "e", "e", nil] a.values_at(4..6, 3...6) # => ["e", "f", nil, "d", "e", "f"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"values_at(selector, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @f;[;I"@return [Array];T;0; @f;@F;Mi;N0;[[I" selector;T0[I"...;T0; @f;[;I"Returns an array containing the elements in +self+ corresponding to the given +selector+(s). The selectors may be either integer indices or ranges. See also Array#select. a = %w{ a b c d e f } a.values_at(1, 3, 5) # => ["b", "d", "f"] a.values_at(1, 3, 5, 7) # => ["b", "d", "f", nil] a.values_at(-1, -2, -2, -7) # => ["f", "e", "e", nil] a.values_at(4..6, 3...6) # => ["e", "f", nil, "d", "e", "f"] @overload values_at(selector, ...) @return [Array];T;0; @f;@F;Ao;B;CT;Di' ;Ei6 ;!@T;"I"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; ; F; ;,;;;I"Array#delete;F;[[I" item;T0;[[@i ;T;;p;0;[;{;IC;"Deletes all items from +self+ that are equal to +obj+. Returns the last deleted item, or +nil+ if no matching item is found. If the optional code block is given, the result of the block is returned if the item is not found. (To remove +nil+ elements and get an informative return value, use Array#compact!) a = [ "a", "b", "b", "b", "c" ] a.delete("b") #=> "b" a #=> ["a", "c"] a.delete("z") #=> nil a.delete("z") {"not found"} #=> "not found" ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;p;K0;#I"delete(obj);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"^Deletes all items from +self+ that are equal to +obj+. Returns the last deleted item, or +nil+ if no matching item is found. If the optional code block is given, the result of the block is returned if the item is not found. (To remove +nil+ elements and get an informative return value, use Array#compact!) a = [ "a", "b", "b", "b", "c" ] a.delete("b") #=> "b" a #=> ["a", "c"] a.delete("z") #=> nil a.delete("z") {"not found"} #=> "not found" @overload delete(obj) @return [nil] @overload delete(obj) @yield [];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#delete_at;F;[[I"pos;T0;[[@iO ;T;:delete_at;0;[;{;IC;"Deletes the element at the specified +index+, returning that element, or +nil+ if the +index+ is out of range. See also Array#slice! a = ["ant", "bat", "cat", "dog"] a.delete_at(2) #=> "cat" a #=> ["ant", "bat", "dog"] a.delete_at(99) #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"delete_at(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[I" index;T0; @;[;I"JDeletes the element at the specified +index+, returning that element, or +nil+ if the +index+ is out of range. See also Array#slice! a = ["ant", "bat", "cat", "dog"] a.delete_at(2) #=> "cat" a #=> ["ant", "bat", "dog"] a.delete_at(99) #=> nil @overload delete_at(index) @return [Object, nil];T;0; @;@F;Ao;B;CT;Di@ ;EiL ;!@T;"I"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; ; F; ;,;;;I"Array#delete_if;F;[;[[@i;T;;;0;[;{;IC;"HDeletes every element of +self+ for which block evaluates to +true+. The array is changed instantly every time the block is called, not after the iteration is over. See also Array#reject! If no block is given, an Enumerator is returned instead. scores = [ 97, 42, 75 ] scores.delete_if {|score| score < 80 } #=> [97] ;T;[o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"Deletes every element of +self+ for which block evaluates to +true+. The array is changed instantly every time the block is called, not after the iteration is over. See also Array#reject! If no block is given, an Enumerator is returned instead. scores = [ 97, 42, 75 ] scores.delete_if {|score| score < 80 } #=> [97] @overload delete_if @yield [item] @return [Array] @overload delete_if @return [Enumerator];T;0; @;@F;Ao;B;CT;Di ;Ei;!@T;"I"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; ; F; ;,;;;I"Array#reject;F;[;[[@i ;T;;;0;[;{;IC;"Returns a new array containing the items in +self+ for which the given block is not +true+. The ordering of non-rejected elements is maintained. See also Array#delete_if If no block is given, an Enumerator is returned instead. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"AReturns a new array containing the items in +self+ for which the given block is not +true+. The ordering of non-rejected elements is maintained. See also Array#delete_if If no block is given, an Enumerator is returned instead. @overload reject @yield [item] @return [Array] @overload reject @return [Enumerator];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#reject!;F;[;[[@i ;T;;;0;[;{;IC;""Deletes every element of +self+ for which the block evaluates to +true+, if no changes were made returns +nil+. The array may not be changed instantly every time the block is called. See also Enumerable#reject and Array#delete_if. If no block is given, an Enumerator is returned instead. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @,o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @,;[;I"'@yield [item] @return [Array, nil];T;0; @,;@F;Mi;N0;[; @,o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @,;[;I"@return [Enumerator];T;0; @,;@F;Mi;N0;[; @,;[;I"Deletes every element of +self+ for which the block evaluates to +true+, if no changes were made returns +nil+. The array may not be changed instantly every time the block is called. See also Enumerable#reject and Array#delete_if. If no block is given, an Enumerator is returned instead. @overload reject! @yield [item] @return [Array, nil] @overload reject! @return [Enumerator];T;0; @,;@F;Ao;B;CT;Di ;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#zip;F;[[@0;[[@iB;T;;%;0;[;{;IC;"Converts any arguments to arrays, then merges elements of +self+ with corresponding elements from each argument. This generates a sequence of ary.size _n_-element arrays, where _n_ is one more than the count of arguments. If the size of any argument is less than the size of the initial array, +nil+ values are supplied. If a block is given, it is invoked for each output +array+, otherwise an array of arrays is returned. a = [ 4, 5, 6 ] b = [ 7, 8, 9 ] [1, 2, 3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]] a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]] ;T;[o;H ;II" overload;F;J0;;%;K0;#I"zip(arg, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @Z;[;I"@return [Array];T;0; @Z;@F;Mi;N0;[[I"arg;T0[I"...;T0; @Zo;H ;II" overload;F;J0;;%;K0;#I"zip(arg, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"arr;T; @Zo;L ;II" return;F;JI";T;0;K[I"nil;T; @Z;[;I"@yield [arr] @return [nil];T;0; @Z;@F;Mi;N0;[[I"arg;T0[I"...;T0; @Z;[;I"Converts any arguments to arrays, then merges elements of +self+ with corresponding elements from each argument. This generates a sequence of ary.size _n_-element arrays, where _n_ is one more than the count of arguments. If the size of any argument is less than the size of the initial array, +nil+ values are supplied. If a block is given, it is invoked for each output +array+, otherwise an array of arrays is returned. a = [ 4, 5, 6 ] b = [ 7, 8, 9 ] [1, 2, 3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]] a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]] @overload zip(arg, ...) @return [Array] @overload zip(arg, ...) @yield [arr] @return [nil];T;0; @Z;@F;Ao;B;CT;Di*;EiA;!@T;"I"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 [[1, 3, 5], [2, 4, 6]] If the length of the subarrays don't match, an IndexError is raised. ;T;[o;H ;II" overload;F;J0;;;K0;#I"transpose;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Assumes that +self+ is an array of arrays and transposes the rows and columns. a = [[1,2], [3,4], [5,6]] a.transpose #=> [[1, 3, 5], [2, 4, 6]] If the length of the subarrays don't match, an IndexError is raised. @overload transpose @return [Array];T;0; @;@F;Ao;B;CT;Di|;Ei;!@T;"I"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 ["x", "y", "z"] a #=> ["x", "y", "z"] ;T;[o;H ;II" overload;F;J0;;';K0;#I"replace(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary;T0; @o;H ;II" overload;F;J0;;];K0;#I"&initialize_copy(other_ary) -> ary;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"other_ary;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"&VALUE 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 = 0; if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else if (ARY_SHARED_P(copy)) { shared = ARY_SHARED(copy); FL_UNSET_SHARED(copy); } FL_SET_EMBED(copy); ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig)); if (shared) { rb_ary_decrement_share(shared); } ARY_SET_LEN(copy, RARRAY_LEN(orig)); } else { VALUE shared = 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); } ary_verify(copy); return copy; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Array#clear;F;[;[[@i;T;;3;0;[;{;IC;"`Removes all elements from +self+. a = [ "a", "b", "c", "d", "e" ] a.clear #=> [ ] ;T;[o;H ;II" overload;F;J0;;3;K0;#I" clear;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Removes all elements from +self+. a = [ "a", "b", "c", "d", "e" ] a.clear #=> [ ] @overload clear @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#fill;F;[[@0;[[@i;T;: fill;0;[;{;IC;"The first three forms set the selected elements of +self+ (which may be the entire array) to +obj+. A +start+ of +nil+ is equivalent to zero. A +length+ of +nil+ is equivalent to the length of the array. The last three forms fill the array with the value of the given block, which is passed the absolute index of each element to be filled. Negative values of +start+ count from the end of the array, where +-1+ is the last element. a = [ "a", "b", "c", "d" ] a.fill("x") #=> ["x", "x", "x", "x"] a.fill("z", 2, 2) #=> ["x", "x", "z", "z"] a.fill("y", 0..1) #=> ["y", "y", "z", "z"] a.fill {|i| i*i} #=> [0, 1, 4, 9] a.fill(-2) {|i| i*i*i} #=> [0, 1, 8, 27] ;T;[ o;H ;II" overload;F;J0;;;K0;#I"fill(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;;K0;#I" fill(obj, start [, length]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0[I"start[, length];T0; @o;H ;II" overload;F;J0;;;K0;#I"fill(obj, range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"obj;T0[I" range;T0; @o;H ;II" overload;F;J0;;;K0;#I" fill;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" index;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"#@yield [index] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"fill(start [, length]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" index;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"#@yield [index] @return [Array];T;0; @;@F;Mi;N0;[[I"start[, length];T0; @o;H ;II" overload;F;J0;;;K0;#I"fill(range);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" index;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"#@yield [index] @return [Array];T;0; @;@F;Mi;N0;[[I" range;T0; @;[;I"The first three forms set the selected elements of +self+ (which may be the entire array) to +obj+. A +start+ of +nil+ is equivalent to zero. A +length+ of +nil+ is equivalent to the length of the array. The last three forms fill the array with the value of the given block, which is passed the absolute index of each element to be filled. Negative values of +start+ count from the end of the array, where +-1+ is the last element. a = [ "a", "b", "c", "d" ] a.fill("x") #=> ["x", "x", "x", "x"] a.fill("z", 2, 2) #=> ["x", "x", "z", "z"] a.fill("y", 0..1) #=> ["y", "y", "z", "z"] a.fill {|i| i*i} #=> [0, 1, 4, 9] a.fill(-2) {|i| i*i*i} #=> [0, 1, 8, 27] @overload fill(obj) @return [Array] @overload fill(obj, start [, length]) @return [Array] @overload fill(obj, range) @return [Array] @overload fill @yield [index] @return [Array] @overload fill(start [, length]) @yield [index] @return [Array] @overload fill(range) @yield [index] @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#include?;F;[[I" item;T0;[[@i;T;;U;0;[;{;IC;"Returns +true+ if the given +object+ is present in +self+ (that is, if any element == +object+), otherwise returns +false+. a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false;T;[o;H ;II" overload;F;J0;;U;K0;#I"include?(object);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @h;[;I"@return [Boolean];T;0; @h;@F;Mi;N0;[[I" object;T0; @h;[;I"Returns +true+ if the given +object+ is present in +self+ (that is, if any element == +object+), otherwise returns +false+. a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false @overload include?(object) @return [Boolean];T;0; @h;@F;Ao;B;CT;Di;Ei;Mi;!@T;"I"VALUE rb_ary_includes(VALUE ary, VALUE item) { long i; VALUE e; for (i=0; i;F;[[I" ary2;T0;[[@i;T;;V;0;[;{;IC;"\Comparison --- Returns an integer (+-1+, +0+, or +1) if this array is less than, equal to, or greater than +other_ary+. Each object in each array is compared (using the <=> operator). Arrays are compared in an "element-wise" manner; the first element of +ary+ is compared with the first one of +other_ary+ using the <=> operator, then each of the second elements, etc... As soon as the result of any such comparison is non zero (i.e. the two corresponding elements are not equal), that result is returned for the whole array comparison. If all the elements are equal, then the result is based on a comparison of the array lengths. Thus, two arrays are "equal" according to Array#<=> if, and only if, they have the same length and the value of each element is equal to the value of the corresponding element in the other array. +nil+ is returned if the +other_ary+ is not an array or if the comparison of two elements returned +nil+. [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1 [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1 [ 1, 2 ] <=> [ 1, :two ] #=> nil ;T;[o;H ;II" overload;F;J0;;V;K0;#I"<=>(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @;[;I" @return [ -1, 0, +1, nil];T;0; @;@F;Mi;N0;[[I"other_ary;T0; @;[;I"Comparison --- Returns an integer (+-1+, +0+, or +1) if this array is less than, equal to, or greater than +other_ary+. Each object in each array is compared (using the <=> operator). Arrays are compared in an "element-wise" manner; the first element of +ary+ is compared with the first one of +other_ary+ using the <=> operator, then each of the second elements, etc... As soon as the result of any such comparison is non zero (i.e. the two corresponding elements are not equal), that result is returned for the whole array comparison. If all the elements are equal, then the result is based on a comparison of the array lengths. Thus, two arrays are "equal" according to Array#<=> if, and only if, they have the same length and the value of each element is equal to the value of the corresponding element in the other array. +nil+ is returned if the +other_ary+ is not an array or if the comparison of two elements returned +nil+. [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1 [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1 [ 1, 2 ] <=> [ 1, :two ] #=> nil @overload <=>(other_ary) @return [ -1, 0, +1, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#slice;F;[[@0;[[@i;T;;;0;[;{;IC;"Element Reference --- Returns the element at +index+, or returns a subarray starting at the +start+ index and continuing for +length+ elements, or returns a subarray specified by +range+ of indices. Negative indices count backward from the end of the array (-1 is the last element). For +start+ and +range+ cases the starting index is just before an element. Additionally, an empty array is returned when the starting index for an element range is at the end of the array. Returns +nil+ if the index (or starting index) are out of range. a = [ "a", "b", "c", "d", "e" ] a[2] + a[0] + a[1] #=> "cab" a[6] #=> nil a[1, 2] #=> [ "b", "c" ] a[1..3] #=> [ "b", "c", "d" ] a[4..7] #=> [ "e" ] a[6..10] #=> nil a[-3, 3] #=> [ "c", "d", "e" ] # special cases a[5] #=> nil a[6, 1] #=> nil a[5, 1] #=> [] a[5..10] #=> [] ;T;[ o;H ;II" overload;F;J0;;;K0;#I"[](index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[I" index;T0; @o;H ;II" overload;F;J0;;;K0;#I"[](start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" start;T0[I" length;T0; @o;H ;II" overload;F;J0;;;K0;#I"[](range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" range;T0; @o;H ;II" overload;F;J0;;;K0;#I"slice(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[I" index;T0; @o;H ;II" overload;F;J0;;;K0;#I"slice(start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" start;T0[I" length;T0; @o;H ;II" overload;F;J0;;;K0;#I"slice(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" range;T0; @;[;@n;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#slice!;F;[[@0;[[@ij ;T;;};0;[;{;IC;"zDeletes the element(s) given by an +index+ (optionally up to +length+ elements) or by a +range+. Returns the deleted object (or objects), or +nil+ if the +index+ is out of range. a = [ "a", "b", "c" ] a.slice!(1) #=> "b" a #=> ["a", "c"] a.slice!(-1) #=> "c" a #=> ["a"] a.slice!(100) #=> nil a #=> ["a"] ;T;[o;H ;II" overload;F;J0;;};K0;#I"slice!(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;TI"nil;T; @;[;I"@return [Object, nil];T;0; @;@F;Mi;N0;[[I" index;T0; @o;H ;II" overload;F;J0;;};K0;#I"slice!(start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" start;T0[I" length;T0; @o;H ;II" overload;F;J0;;};K0;#I"slice!(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" range;T0; @;[;I"Deletes the element(s) given by an +index+ (optionally up to +length+ elements) or by a +range+. Returns the deleted object (or objects), or +nil+ if the +index+ is out of range. a = [ "a", "b", "c" ] a.slice!(1) #=> "b" a #=> ["a", "c"] a.slice!(-1) #=> "c" a #=> ["a"] a.slice!(100) #=> nil a #=> ["a"] @overload slice!(index) @return [Object, nil] @overload slice!(start, length) @return [Array, nil] @overload slice!(range) @return [Array, nil];T;0; @;@F;Ao;B;CT;DiU ;Eii ;!@T;"I" static VALUE rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) { VALUE arg1, arg2; long pos, len, orig_len; rb_ary_modify_check(ary); if (argc == 2) { pos = NUM2LONG(argv[0]); len = NUM2LONG(argv[1]); delete_pos_len: if (len < 0) return Qnil; orig_len = RARRAY_LEN(ary); if (pos < 0) { pos += orig_len; if (pos < 0) return Qnil; } else if (orig_len < pos) return Qnil; if (orig_len < pos + len) { len = orig_len - pos; } if (len == 0) return rb_ary_new2(0); arg2 = rb_ary_new4(len, RARRAY_CONST_PTR_TRANSIENT(ary)+pos); RBASIC_SET_CLASS(arg2, rb_obj_class(ary)); rb_ary_splice(ary, pos, len, 0, 0); return arg2; } rb_check_arity(argc, 1, 2); arg1 = argv[0]; if (!FIXNUM_P(arg1)) { switch (rb_range_beg_len(arg1, &pos, &len, RARRAY_LEN(ary), 0)) { case Qtrue: /* valid range */ goto delete_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; ; F; ;,;;;I"Array#assoc;F;[[I"key;T0;[[@i ;T;;;0;[;{;IC;"Searches through an array whose elements are also arrays comparing +obj+ with the first element of each contained array using obj.==. Returns the first contained array that matches (that is, the first associated array), or +nil+ if no match is found. See also Array#rassoc s1 = [ "colors", "red", "blue", "green" ] s2 = [ "letters", "a", "b", "c" ] s3 = "foo" a = [ s1, s2, s3 ] a.assoc("letters") #=> [ "letters", "a", "b", "c" ] a.assoc("foo") #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"assoc(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @\;[;I"@return [nil];T;0; @\;@F;Mi;N0;[[I"obj;T0; @\;[;I"Searches through an array whose elements are also arrays comparing +obj+ with the first element of each contained array using obj.==. Returns the first contained array that matches (that is, the first associated array), or +nil+ if no match is found. See also Array#rassoc s1 = [ "colors", "red", "blue", "green" ] s2 = [ "letters", "a", "b", "c" ] s3 = "foo" a = [ s1, s2, s3 ] a.assoc("letters") #=> [ "letters", "a", "b", "c" ] a.assoc("foo") #=> nil @overload assoc(obj) @return [nil];T;0; @\;@F;Ao;B;CT;Di;Ei ;!@T;"I"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; ; F; ;,;;;I"Array#rassoc;F;[[I" value;T0;[[@i.;T;;;0;[;{;IC;"gSearches through the array whose elements are also arrays. Compares +obj+ with the second element of each contained array using obj.==. Returns the first contained array that matches +obj+. See also Array#assoc. a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ] a.rassoc("two") #=> [2, "two"] a.rassoc("four") #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I"rassoc(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @{;[;I"@return [nil];T;0; @{;@F;Mi;N0;[[I"obj;T0; @{;[;I"Searches through the array whose elements are also arrays. Compares +obj+ with the second element of each contained array using obj.==. Returns the first contained array that matches +obj+. See also Array#assoc. a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ] a.rassoc("two") #=> [2, "two"] a.rassoc("four") #=> nil @overload rassoc(obj) @return [nil];T;0; @{;@F;Ao;B;CT;Di;Ei+;!@T;"I"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; ; F; ;,;;;I" Array#+;F;[[I"y;T0;[[@io;T;;(;0;[;{;IC;"Concatenation --- Returns a new array built by concatenating the two arrays together to produce a third array. [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ] a = [ "a", "b", "c" ] c = a + [ "d", "e", "f" ] c #=> [ "a", "b", "c", "d", "e", "f" ] a #=> [ "a", "b", "c" ] Note that x += y is the same as x = x + y This means that it produces a new array. As a consequence, repeated use of += on arrays can be quite inefficient. See also Array#concat. ;T;[o;H ;II" overload;F;J0;;(;K0;#I"+(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary;T0; @;[;I"@Concatenation --- Returns a new array built by concatenating the two arrays together to produce a third array. [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ] a = [ "a", "b", "c" ] c = a + [ "d", "e", "f" ] c #=> [ "a", "b", "c", "d", "e", "f" ] a #=> [ "a", "b", "c" ] Note that x += y is the same as x = x + y This means that it produces a new array. As a consequence, repeated use of += on arrays can be quite inefficient. See also Array#concat. @overload +(other_ary) @return [Array];T;0; @;@F;Ao;B;CT;DiX;Eil;!@T;"I"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; ; F; ;,;;;I" Array#*;F;[[I" times;T0;[[@i;T;;);0;[;{;IC;"Repetition --- With a String argument, equivalent to ary.join(str). Otherwise, returns a new array built by concatenating the +int+ copies of +self+. [ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ] [ 1, 2, 3 ] * "," #=> "1,2,3" ;T;[o;H ;II" overload;F;J0;;);K0;#I" *(int);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"int;T0; @o;H ;II" overload;F;J0;;);K0;#I" *(str);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"str;T0; @;[;I"6Repetition --- With a String argument, equivalent to ary.join(str). Otherwise, returns a new array built by concatenating the +int+ copies of +self+. [ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ] [ 1, 2, 3 ] * "," #=> "1,2,3" @overload *(int) @return [Array] @overload *(str);T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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_obj_class(ary), 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_obj_class(ary), 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: OBJ_INFECT(ary2, ary); return ary2; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Array#-;F;[[I" ary2;T0;[[@it;T;;<;0;[;{;IC;"Array Difference Returns a new array that is a copy of the original array, removing any items that also appear in +other_ary+. The order is preserved from the original array. It compares elements using their #hash and #eql? methods for efficiency. [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ] If you need set-like behavior, see the library class Set. See also Array#difference. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"-(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary;T0; @;[;I"Array Difference Returns a new array that is a copy of the original array, removing any items that also appear in +other_ary+. The order is preserved from the original array. It compares elements using their #hash and #eql? methods for efficiency. [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ] If you need set-like behavior, see the library class Set. See also Array#difference. @overload -(other_ary) @return [Array];T;0; @;@F;Ao;B;CT;Dia;Eiq;!@T;"I"static VALUE rb_ary_diff(VALUE ary1, VALUE ary2) { VALUE ary3; VALUE hash; long i; ary2 = to_ary(ary2); ary3 = rb_ary_new(); if (RARRAY_LEN(ary1) <= SMALL_ARRAY_LEN || RARRAY_LEN(ary2) <= SMALL_ARRAY_LEN) { for (i=0; i [ 1, 3 ] [ 'a', 'b', 'b', 'z' ] & [ 'a', 'b', 'c' ] #=> [ 'a', 'b' ] See also Array#uniq. ;T;[o;H ;II" overload;F;J0;;;K0;#I"&(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary;T0; @;[;I"Set Intersection --- Returns a new array containing unique elements common to the two arrays. The order is preserved from the original array. It compares elements using their #hash and #eql? methods for efficiency. [ 1, 1, 3, 5 ] & [ 3, 2, 1 ] #=> [ 1, 3 ] [ 'a', 'b', 'b', 'z' ] & [ 'a', 'b', 'c' ] #=> [ 'a', 'b' ] See also Array#uniq. @overload &(other_ary) @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; i [ "a", "b", "c", "d" ] [ "c", "d", "a" ] | [ "a", "b", "c" ] #=> [ "c", "d", "a", "b" ] See also Array#union. ;T;[o;H ;II" overload;F;J0;;;K0;#I"|(other_ary);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"other_ary;T0; @ ;[;I"Set Union --- Returns a new array by joining +ary+ with +other_ary+, excluding any duplicates and preserving the order from the given arrays. It compares elements using their #hash and #eql? methods for efficiency. [ "a", "b", "c" ] | [ "c", "d", "a" ] #=> [ "a", "b", "c", "d" ] [ "c", "d", "a" ] | [ "a", "b", "c" ] #=> [ "c", "d", "a", "b" ] See also Array#union. @overload |(other_ary) @return [Array];T;0; @ ;@F;Ao;B;CT;Di;Ei';!@T;"I"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; ; F; ;,;;;I"Array#max;F;[[@0;[[@i;T;;;0;[;{;IC;"EReturns the object in _ary_ with the maximum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. ary = %w(albatross dog horse) ary.max #=> "horse" ary.max {|a, b| a.length <=> b.length} #=> "albatross" If the +n+ argument is given, maximum +n+ elements are returned as an array. ary = %w[albatross dog horse] ary.max(2) #=> ["horse", "dog"] ary.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I"max;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @?;[;I"@return [Object];T;0; @?;@F;Mi;N0;[; @?o;H ;II" overload;F;J0;;;K0;#I"max;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @?o;L ;II" return;F;JI";T;0;K[I" Object;T; @?;[;I"#@yield [a, b] @return [Object];T;0; @?;@F;Mi;N0;[; @?o;H ;II" overload;F;J0;;;K0;#I" max(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @?;[;I"@return [Array];T;0; @?;@F;Mi;N0;[[I"n;T0; @?o;H ;II" overload;F;J0;;;K0;#I" max(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @?o;L ;II" return;F;JI";T;0;K[I" Array;T; @?;[;I""@yield [a, b] @return [Array];T;0; @?;@F;Mi;N0;[[I"n;T0; @?;[;I"Returns the object in _ary_ with the maximum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. ary = %w(albatross dog horse) ary.max #=> "horse" ary.max {|a, b| a.length <=> b.length} #=> "albatross" If the +n+ argument is given, maximum +n+ elements are returned as an array. ary = %w[albatross dog horse] ary.max(2) #=> ["horse", "dog"] ary.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"] @overload max @return [Object] @overload max @yield [a, b] @return [Object] @overload max(n) @return [Array] @overload max(n) @yield [a, b] @return [Array];T;0; @?;@F;Ao;B;CT;Dim;Ei;!@T;"I"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); 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 { for (i = 0; i < RARRAY_LEN(ary); i++) { v = RARRAY_AREF(ary, i); if (result == Qundef || OPTIMIZED_CMP(v, result, cmp_opt) > 0) { result = v; } } } if (result == Qundef) return Qnil; return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#min;F;[[@0;[[@i;T;;;0;[;{;IC;"AReturns the object in _ary_ with the minimum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. ary = %w(albatross dog horse) ary.min #=> "albatross" ary.min {|a, b| a.length <=> b.length} #=> "dog" If the +n+ argument is given, minimum +n+ elements are returned as an array. ary = %w[albatross dog horse] ary.min(2) #=> ["albatross", "dog"] ary.min(2) {|a, b| a.length <=> b.length } #=> ["dog", "horse"] ;T;[ o;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"$@yield [ a,b ] @return [Object];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" min(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"n;T0; @o;H ;II" overload;F;J0;;;K0;#I" min(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"#@yield [ a,b ] @return [Array];T;0; @;@F;Mi;N0;[[I"n;T0; @;[;I"Returns the object in _ary_ with the minimum value. The first form assumes all objects implement Comparable; the second uses the block to return a <=> b. ary = %w(albatross dog horse) ary.min #=> "albatross" ary.min {|a, b| a.length <=> b.length} #=> "dog" If the +n+ argument is given, minimum +n+ elements are returned as an array. ary = %w[albatross dog horse] ary.min(2) #=> ["albatross", "dog"] ary.min(2) {|a, b| a.length <=> b.length } #=> ["dog", "horse"] @overload min @return [Object] @overload min @yield [ a,b ] @return [Object] @overload min(n) @return [Array] @overload min(n) @yield [ a,b ] @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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); 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 { for (i = 0; i < RARRAY_LEN(ary); i++) { v = RARRAY_AREF(ary, i); if (result == Qundef || OPTIMIZED_CMP(v, result, cmp_opt) < 0) { result = v; } } } if (result == Qundef) return Qnil; return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#uniq;F;[;[[@i-;T;;0;0;[;{;IC;"Returns a new array by removing duplicate values in +self+. If a block is given, it will use the return value of the block for comparison. It compares values using their #hash and #eql? methods for efficiency. +self+ is traversed in order, and the first occurrence is kept. a = [ "a", "a", "b", "b", "c" ] a.uniq # => ["a", "b", "c"] b = [["student","sam"], ["student","george"], ["teacher","matz"]] b.uniq {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]] ;T;[o;H ;II" overload;F;J0;;0;K0;#I" uniq;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;0;K0;#I" uniq;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I""@yield [item] @return [Array];T;0; @;@F;Mi;N0;[; @;[;I"=Returns a new array by removing duplicate values in +self+. If a block is given, it will use the return value of the block for comparison. It compares values using their #hash and #eql? methods for efficiency. +self+ is traversed in order, and the first occurrence is kept. a = [ "a", "a", "b", "b", "c" ] a.uniq # => ["a", "b", "c"] b = [["student","sam"], ["student","george"], ["teacher","matz"]] b.uniq {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]] @overload uniq @return [Array] @overload uniq @yield [item] @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei,;!@T;"I"static VALUE rb_ary_uniq(VALUE ary) { VALUE hash, uniq; if (RARRAY_LEN(ary) <= 1) return rb_ary_dup(ary); 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); } RBASIC_SET_CLASS(uniq, rb_obj_class(ary)); ary_recycle_hash(hash); return uniq; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#uniq!;F;[;[[@i;T;: uniq!;0;[;{;IC;"PRemoves duplicate elements from +self+. If a block is given, it will use the return value of the block for comparison. It compares values using their #hash and #eql? methods for efficiency. +self+ is traversed in order, and the first occurrence is kept. Returns +nil+ if no changes are made (that is, no duplicates are found). a = [ "a", "a", "b", "b", "c" ] a.uniq! # => ["a", "b", "c"] b = [ "a", "b", "c" ] b.uniq! # => nil c = [["student","sam"], ["student","george"], ["teacher","matz"]] c.uniq! {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]] ;T;[o;H ;II" overload;F;J0;;;K0;#I" uniq!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" uniq!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"'@yield [item] @return [Array, nil];T;0; @;@F;Mi;N0;[; @;[;I"Removes duplicate elements from +self+. If a block is given, it will use the return value of the block for comparison. It compares values using their #hash and #eql? methods for efficiency. +self+ is traversed in order, and the first occurrence is kept. Returns +nil+ if no changes are made (that is, no duplicates are found). a = [ "a", "a", "b", "b", "c" ] a.uniq! # => ["a", "b", "c"] b = [ "a", "b", "c" ] b.uniq! # => nil c = [["student","sam"], ["student","george"], ["teacher","matz"]] c.uniq! {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]] @overload uniq! @return [Array, nil] @overload uniq! @yield [item] @return [Array, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#compact;F;[;[[@io;T;;;0;[;{;IC;"Returns a copy of +self+ with all +nil+ elements removed. [ "a", nil, "b", nil, "c", nil ].compact #=> [ "a", "b", "c" ] ;T;[o;H ;II" overload;F;J0;;;K0;#I" compact;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @A;[;I"@return [Array];T;0; @A;@F;Mi;N0;[; @A;[;I"Returns a copy of +self+ with all +nil+ elements removed. [ "a", nil, "b", nil, "c", nil ].compact #=> [ "a", "b", "c" ] @overload compact @return [Array];T;0; @A;@F;Ao;B;CT;Die;Eil;!@T;"I"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; ; F; ;,;;;I"Array#compact!;F;[;[[@iN;T;;;0;[;{;IC;"Removes +nil+ elements from the array. Returns +nil+ if no changes were made, otherwise returns the array. [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ] [ "a", "b", "c" ].compact! #=> nil ;T;[o;H ;II" overload;F;J0;;;K0;#I" compact!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @\;[;I"@return [Array, nil];T;0; @\;@F;Mi;N0;[; @\;[;I"Removes +nil+ elements from the array. Returns +nil+ if no changes were made, otherwise returns the array. [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ] [ "a", "b", "c" ].compact! #=> nil @overload compact! @return [Array, nil];T;0; @\;@F;Ao;B;CT;DiB;EiK;!@T;"I"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; ; F; ;,;;;I"Array#flatten;F;[[@0;[[@i%;T;;;0;[;{;IC;"-Returns a new array that is a one-dimensional flattening of +self+ (recursively). That is, for every element that is an array, extract its elements into the new array. The optional +level+ argument determines the level of recursion to flatten. s = [ 1, 2, 3 ] #=> [1, 2, 3] t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]] a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10] a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] a = [ 1, 2, [3, [4, 5] ] ] a.flatten(1) #=> [1, 2, 3, [4, 5]] ;T;[o;H ;II" overload;F;J0;;;K0;#I" flatten;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @x;[;I"@return [Array];T;0; @x;@F;Mi;N0;[; @xo;H ;II" overload;F;J0;;;K0;#I"flatten(level);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @x;[;I"@return [Array];T;0; @x;@F;Mi;N0;[[I" level;T0; @x;[;I"~Returns a new array that is a one-dimensional flattening of +self+ (recursively). That is, for every element that is an array, extract its elements into the new array. The optional +level+ argument determines the level of recursion to flatten. s = [ 1, 2, 3 ] #=> [1, 2, 3] t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]] a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10] a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] a = [ 1, 2, [3, [4, 5] ] ] a.flatten(1) #=> [1, 2, 3, [4, 5]] @overload flatten @return [Array] @overload flatten(level) @return [Array];T;0; @x;@F;Ao;B;CT;Di;Ei#;!@T;"I"fstatic VALUE rb_ary_flatten(int argc, VALUE *argv, VALUE ary) { int mod = 0, 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, &mod); OBJ_INFECT(result, ary); return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#flatten!;F;[[@0;[[@i;T;: flatten!;0;[;{;IC;"Flattens +self+ in place. Returns +nil+ if no modifications were made (i.e., the array contains no subarrays.) The optional +level+ argument determines the level of recursion to flatten. a = [ 1, 2, [3, [4, 5] ] ] a.flatten! #=> [1, 2, 3, 4, 5] a.flatten! #=> nil a #=> [1, 2, 3, 4, 5] a = [ 1, 2, [3, [4, 5] ] ] a.flatten!(1) #=> [1, 2, 3, [4, 5]] ;T;[o;H ;II" overload;F;J0;;;K0;#I" flatten!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"flatten!(level);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[[I" level;T0; @;[;I"Flattens +self+ in place. Returns +nil+ if no modifications were made (i.e., the array contains no subarrays.) The optional +level+ argument determines the level of recursion to flatten. a = [ 1, 2, [3, [4, 5] ] ] a.flatten! #=> [1, 2, 3, 4, 5] a.flatten! #=> nil a #=> [1, 2, 3, 4, 5] a = [ 1, 2, [3, [4, 5] ] ] a.flatten!(1) #=> [1, 2, 3, [4, 5]] @overload flatten! @return [Array, nil] @overload flatten!(level) @return [Array, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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, &mod); if (mod == 0) { ary_discard(result); 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; ; F; ;,;;;I"Array#count;F;[[@0;[[@i;T;;r;0;[;{;IC;"aReturns the number of elements. If an argument is given, counts the number of elements which equal +obj+ using ==. If a block is given, counts the number of elements for which the block returns a true value. ary = [1, 2, 4, 2] ary.count #=> 4 ary.count(2) #=> 2 ary.count {|x| x%2 == 0} #=> 3 ;T;[o;H ;II" overload;F;J0;;r;K0;#I" count;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;r;K0;#I"count(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;r;K0;#I" count;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" item;T; @o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"$@yield [item] @return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"Returns the number of elements. If an argument is given, counts the number of elements which equal +obj+ using ==. If a block is given, counts the number of elements for which the block returns a true value. ary = [1, 2, 4, 2] ary.count #=> 4 ary.count(2) #=> 2 ary.count {|x| x%2 == 0} #=> 3 @overload count @return [Integer] @overload count(obj) @return [Integer] @overload count @yield [item] @return [Integer];T;0; @;@F;Ao;B;CT;Diw;Ei;!@T;"I"'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; ; F; ;,;;;I"Array#shuffle!;F;[[@0;[[@iL;T;: shuffle!;0;[;{;IC;"&Shuffles elements in +self+ in place. a = [ 1, 2, 3 ] #=> [1, 2, 3] a.shuffle! #=> [2, 3, 1] a #=> [2, 3, 1] The optional +rng+ argument will be used as the random number generator. a.shuffle!(random: Random.new(1)) #=> [1, 3, 2] ;T;[o;H ;II" overload;F;J0;;;K0;#I" shuffle!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I"shuffle!(random: rng);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I" random:;TI"rng;T; @ ;[;I"Shuffles elements in +self+ in place. a = [ 1, 2, 3 ] #=> [1, 2, 3] a.shuffle! #=> [2, 3, 1] a #=> [2, 3, 1] The optional +rng+ argument will be used as the random number generator. a.shuffle!(random: Random.new(1)) #=> [1, 3, 2] @overload shuffle! @return [Array] @overload shuffle!(random: rng) @return [Array];T;0; @ ;@F;Ao;B;CT;Di<;EiJ;!@T;"I"static VALUE rb_ary_shuffle_bang(int argc, VALUE *argv, VALUE ary) { VALUE opts, randgen = rb_cRandom; long i, len; if (OPTHASH_GIVEN_P(opts)) { VALUE rnd; ID keyword_ids[1]; keyword_ids[0] = id_random; rb_get_kwargs(opts, keyword_ids, 0, 1, &rnd); if (rnd != Qundef) { randgen = rnd; } } rb_check_arity(argc, 0, 0); rb_ary_modify(ary); i = len = RARRAY_LEN(ary); RARRAY_PTR_USE(ary, ptr, { while (i) { long j = RAND_UPTO(i); VALUE tmp; if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR_TRANSIENT(ary)) { rb_raise(rb_eRuntimeError, "modified during shuffle"); } tmp = ptr[--i]; ptr[i] = ptr[j]; ptr[j] = tmp; } }); /* WB: no new reference */ return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#shuffle;F;[[@0;[[@i;T;: shuffle;0;[;{;IC;"5Returns a new array with elements of +self+ shuffled. a = [ 1, 2, 3 ] #=> [1, 2, 3] a.shuffle #=> [2, 3, 1] a #=> [1, 2, 3] The optional +rng+ argument will be used as the random number generator. a.shuffle(random: Random.new(1)) #=> [1, 3, 2] ;T;[o;H ;II" overload;F;J0;;;K0;#I" shuffle;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @9;[;I"@return [Array];T;0; @9;@F;Mi;N0;[; @9o;H ;II" overload;F;J0;;;K0;#I"shuffle(random: rng);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @9;[;I"@return [Array];T;0; @9;@F;Mi;N0;[[I" random:;TI"rng;T; @9;[;I"Returns a new array with elements of +self+ shuffled. a = [ 1, 2, 3 ] #=> [1, 2, 3] a.shuffle #=> [2, 3, 1] a #=> [1, 2, 3] The optional +rng+ argument will be used as the random number generator. a.shuffle(random: Random.new(1)) #=> [1, 3, 2] @overload shuffle @return [Array] @overload shuffle(random: rng) @return [Array];T;0; @9;@F;Ao;B;CT;Dio;Ei};!@T;"I"static VALUE rb_ary_shuffle(int argc, VALUE *argv, VALUE ary) { ary = rb_ary_dup(ary); rb_ary_shuffle_bang(argc, argv, ary); return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#sample;F;[[@0;[[@i;T;: sample;0;[;{;IC;"sChoose a random element or +n+ random elements from the array. The elements are chosen by using random and unique indices into the array in order to ensure that an element doesn't repeat itself unless the array already contained duplicate elements. If the array is empty the first form returns +nil+ and the second form returns an empty array. a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] a.sample #=> 7 a.sample(4) #=> [6, 4, 2, 5] The optional +rng+ argument will be used as the random number generator. a.sample(random: Random.new(1)) #=> 6 a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2] ;T;[ o;H ;II" overload;F;J0;;;K0;#I" sample;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @e;[;I"@return [Object];T;0; @e;@F;Mi;N0;[; @eo;H ;II" overload;F;J0;;;K0;#I"sample(random: rng);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @e;[;I"@return [Object];T;0; @e;@F;Mi;N0;[[I" random:;TI"rng;T; @eo;H ;II" overload;F;J0;;;K0;#I"sample(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @e;[;I"@return [Array];T;0; @e;@F;Mi;N0;[[I"n;T0; @eo;H ;II" overload;F;J0;;;K0;#I"sample(n, random: rng);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @e;[;I"@return [Array];T;0; @e;@F;Mi;N0;[[I"n;T0[I" random:;TI"rng;T; @e;[;I"#Choose a random element or +n+ random elements from the array. The elements are chosen by using random and unique indices into the array in order to ensure that an element doesn't repeat itself unless the array already contained duplicate elements. If the array is empty the first form returns +nil+ and the second form returns an empty array. a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] a.sample #=> 7 a.sample(4) #=> [6, 4, 2, 5] The optional +rng+ argument will be used as the random number generator. a.sample(random: Random.new(1)) #=> 6 a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2] @overload sample @return [Object] @overload sample(random: rng) @return [Object] @overload sample(n) @return [Array] @overload sample(n, random: rng) @return [Array];T;0; @e;@F;Ao;B;CT;Di;Ei;!@T;"I" static VALUE rb_ary_sample(int argc, VALUE *argv, VALUE ary) { VALUE nv, result; VALUE opts, randgen = rb_cRandom; long n, len, i, j, k, idx[10]; long rnds[numberof(idx)]; long memo_threshold; if (OPTHASH_GIVEN_P(opts)) { VALUE rnd; ID keyword_ids[1]; keyword_ids[0] = id_random; rb_get_kwargs(opts, keyword_ids, 0, 1, &rnd); if (rnd != Qundef) { randgen = rnd; } } len = RARRAY_LEN(ary); if (rb_check_arity(argc, 0, 1) == 0) { if (len < 2) i = 0; else i = RAND_UPTO(len); return rb_ary_elt(ary, i); } nv = argv[0]; n = NUM2LONG(nv); if (n < 0) rb_raise(rb_eArgError, "negative sample number"); if (n > len) n = len; if (n <= numberof(idx)) { for (i = 0; i < n; ++i) { rnds[i] = RAND_UPTO(len - i); } } k = len; len = RARRAY_LEN(ary); if (len < k && n <= numberof(idx)) { for (i = 0; i < n; ++i) { if (rnds[i] >= len) return rb_ary_new_capa(0); } } if (n > len) n = len; switch (n) { case 0: return rb_ary_new_capa(0); case 1: i = rnds[0]; return rb_ary_new_from_values(1, &RARRAY_AREF(ary, i)); case 2: i = rnds[0]; j = rnds[1]; if (j >= i) j++; return rb_ary_new_from_args(2, RARRAY_AREF(ary, i), RARRAY_AREF(ary, j)); case 3: i = rnds[0]; j = rnds[1]; k = rnds[2]; { long l = j, g = i; if (j >= i) l = i, g = ++j; if (k >= l && (++k >= g)) ++k; } return rb_ary_new_from_args(3, RARRAY_AREF(ary, i), RARRAY_AREF(ary, j), RARRAY_AREF(ary, k)); } memo_threshold = len < 2560 ? len / 128 : len < 5120 ? len / 64 : len < 10240 ? len / 32 : len / 16; if (n <= numberof(idx)) { long sorted[numberof(idx)]; sorted[0] = idx[0] = rnds[0]; for (i=1; i max_idx) max_idx = r; } len = RARRAY_LEN(ary); if (len <= max_idx) n = 0; else if (n > len) n = len; RARRAY_PTR_USE_TRANSIENT(ary, ptr_ary, { for (i=0; i 0 && (n < 0 || 0 < n--)) { for (i=0; i [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] a.permutation(1).to_a #=> [[1],[2],[3]] a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]] a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] a.permutation(0).to_a #=> [[]] # one permutation of length 0 a.permutation(4).to_a #=> [] # no permutations of length 4 ;T;[ o;H ;II" overload;F;J0;;;K0;#I"permutation;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"p;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@yield [p] @return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"permutation;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"permutation(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"p;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@yield [p] @return [Array];T;0; @;@F;Mi;N0;[[I"n;T0; @o;H ;II" overload;F;J0;;;K0;#I"permutation(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[[I"n;T0; @;[;I"When invoked with a block, yield all permutations of length +n+ of the elements of the array, then return the array itself. If +n+ is not specified, yield all permutations of all elements. The implementation makes no guarantees about the order in which the permutations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2, 3] a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] a.permutation(1).to_a #=> [[1],[2],[3]] a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]] a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] a.permutation(0).to_a #=> [[]] # one permutation of length 0 a.permutation(4).to_a #=> [] # no permutations of length 4 @overload permutation @yield [p] @return [Array] @overload permutation @return [Enumerator] @overload permutation(n) @yield [p] @return [Array] @overload permutation(n) @return [Enumerator];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#combination;F;[[I"num;T0;[[@i];T;:combination;0;[;{;IC;"When invoked with a block, yields all combinations of length +n+ of elements from the array and then returns the array itself. The implementation makes no guarantees about the order in which the combinations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2, 3, 4] a.combination(1).to_a #=> [[1],[2],[3],[4]] a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]] a.combination(4).to_a #=> [[1,2,3,4]] a.combination(0).to_a #=> [[]] # one combination of length 0 a.combination(5).to_a #=> [] # no combinations of length 5 ;T;[o;H ;II" overload;F;J0;;;K0;#I"combination(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"c;T; @7o;L ;II" return;F;JI";T;0;K[I" Array;T; @7;[;I"@yield [c] @return [Array];T;0; @7;@F;Mi;N0;[[I"n;T0; @7o;H ;II" overload;F;J0;;;K0;#I"combination(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @7;[;I"@return [Enumerator];T;0; @7;@F;Mi;N0;[[I"n;T0; @7;[;I"When invoked with a block, yields all combinations of length +n+ of elements from the array and then returns the array itself. The implementation makes no guarantees about the order in which the combinations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2, 3, 4] a.combination(1).to_a #=> [[1],[2],[3],[4]] a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]] a.combination(4).to_a #=> [[1,2,3,4]] a.combination(0).to_a #=> [[]] # one combination of length 0 a.combination(5).to_a #=> [] # no combinations of length 5 @overload combination(n) @yield [c] @return [Array] @overload combination(n) @return [Enumerator];T;0; @7;@F;Ao;B;CT;DiD;Ei\;!@T;"I"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; ; F; ;,;;;I"Array#repeated_permutation;F;[[I"num;T0;[[@i;T;:repeated_permutation;0;[;{;IC;"When invoked with a block, yield all repeated permutations of length +n+ of the elements of the array, then return the array itself. The implementation makes no guarantees about the order in which the repeated permutations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2] a.repeated_permutation(1).to_a #=> [[1], [2]] a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]] a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2], # [2,1,1],[2,1,2],[2,2,1],[2,2,2]] a.repeated_permutation(0).to_a #=> [[]] # one permutation of length 0 ;T;[o;H ;II" overload;F;J0;;;K0;#I"repeated_permutation(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"p;T; @jo;L ;II" return;F;JI";T;0;K[I" Array;T; @j;[;I"@yield [p] @return [Array];T;0; @j;@F;Mi;N0;[[I"n;T0; @jo;H ;II" overload;F;J0;;;K0;#I"repeated_permutation(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @j;[;I"@return [Enumerator];T;0; @j;@F;Mi;N0;[[I"n;T0; @j;[;I" When invoked with a block, yield all repeated permutations of length +n+ of the elements of the array, then return the array itself. The implementation makes no guarantees about the order in which the repeated permutations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2] a.repeated_permutation(1).to_a #=> [[1], [2]] a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]] a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2], # [2,1,1],[2,1,2],[2,2,1],[2,2,2]] a.repeated_permutation(0).to_a #=> [[]] # one permutation of length 0 @overload repeated_permutation(n) @yield [p] @return [Array] @overload repeated_permutation(n) @return [Enumerator];T;0; @j;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#repeated_combination;F;[[I"num;T0;[[@i$;T;:repeated_combination;0;[;{;IC;"When invoked with a block, yields all repeated combinations of length +n+ of elements from the array and then returns the array itself. The implementation makes no guarantees about the order in which the repeated combinations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2, 3] a.repeated_combination(1).to_a #=> [[1], [2], [3]] a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]] a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3], # [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]] a.repeated_combination(4).to_a #=> [[1,1,1,1],[1,1,1,2],[1,1,1,3],[1,1,2,2],[1,1,2,3], # [1,1,3,3],[1,2,2,2],[1,2,2,3],[1,2,3,3],[1,3,3,3], # [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]] a.repeated_combination(0).to_a #=> [[]] # one combination of length 0 ;T;[o;H ;II" overload;F;J0;;;K0;#I"repeated_combination(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"c;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@yield [c] @return [Array];T;0; @;@F;Mi;N0;[[I"n;T0; @o;H ;II" overload;F;J0;;;K0;#I"repeated_combination(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[[I"n;T0; @;[;I"2When invoked with a block, yields all repeated combinations of length +n+ of elements from the array and then returns the array itself. The implementation makes no guarantees about the order in which the repeated combinations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2, 3] a.repeated_combination(1).to_a #=> [[1], [2], [3]] a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]] a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3], # [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]] a.repeated_combination(4).to_a #=> [[1,1,1,1],[1,1,1,2],[1,1,1,3],[1,1,2,2],[1,1,2,3], # [1,1,3,3],[1,2,2,2],[1,2,2,3],[1,2,3,3],[1,3,3,3], # [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]] a.repeated_combination(0).to_a #=> [[]] # one combination of length 0 @overload repeated_combination(n) @yield [c] @return [Array] @overload repeated_combination(n) @return [Enumerator];T;0; @;@F;Ao;B;CT;Di ;Ei#;!@T;"I"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; ; F; ;,;;;I"Array#product;F;[[@0;[[@i\;T;: product;0;[;{;IC;"UReturns an array of all combinations of elements from all arrays. The length of the returned array is the product of the length of +self+ and the argument arrays. If given a block, #product will yield all combinations and return +self+ instead. [1,2,3].product([4,5]) #=> [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]] [1,2].product([1,2]) #=> [[1,1],[1,2],[2,1],[2,2]] [1,2].product([3,4],[5,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]] [1,2].product() #=> [[1],[2]] [1,2].product([]) #=> [] ;T;[o;H ;II" overload;F;J0;;;K0;#I"product(other_ary, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"other_ary;T0[I"...;T0; @o;H ;II" overload;F;J0;;;K0;#I"product(other_ary, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"p;T; @o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@yield [p] @return [Array];T;0; @;@F;Mi;N0;[[I"other_ary;T0[I"...;T0; @;[;I"Returns an array of all combinations of elements from all arrays. The length of the returned array is the product of the length of +self+ and the argument arrays. If given a block, #product will yield all combinations and return +self+ instead. [1,2,3].product([4,5]) #=> [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]] [1,2].product([1,2]) #=> [[1,1],[1,2],[2,1],[2,2]] [1,2].product([3,4],[5,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]] [1,2].product() #=> [[1],[2]] [1,2].product([]) #=> [] @overload product(other_ary, ...) @return [Array] @overload product(other_ary, ...) @yield [p] @return [Array];T;0; @;@F;Ao;B;CT;DiG;Ei[;!@T;"I"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; ; F; ;,;;;I"Array#take;F;[[I"n;T0;[[@i;T;;&;0;[;{;IC;"Returns first +n+ elements from the array. If a negative number is given, raises an ArgumentError. See also Array#drop a = [1, 2, 3, 4, 5, 0] a.take(3) #=> [1, 2, 3] ;T;[o;H ;II" overload;F;J0;;&;K0;#I" take(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"n;T0; @;[;I"Returns first +n+ elements from the array. If a negative number is given, raises an ArgumentError. See also Array#drop a = [1, 2, 3, 4, 5, 0] a.take(3) #=> [1, 2, 3] @overload take(n) @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#take_while;F;[;[[@i;T;;';0;[;{;IC;"!Passes elements to the block until the block returns +nil+ or +false+, then stops iterating and returns an array of all prior elements. If no block is given, an Enumerator is returned instead. See also Array#drop_while a = [1, 2, 3, 4, 5, 0] a.take_while {|i| i < 3} #=> [1, 2] ;T;[o;H ;II" overload;F;J0;;';K0;#I"take_while;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @%o;L ;II" return;F;JI";T;0;K[I" Array;T; @%;[;I"!@yield [obj] @return [Array];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;;';K0;#I"take_while;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @%;[;I"@return [Enumerator];T;0; @%;@F;Mi;N0;[; @%;[;I"Passes elements to the block until the block returns +nil+ or +false+, then stops iterating and returns an array of all prior elements. If no block is given, an Enumerator is returned instead. See also Array#drop_while a = [1, 2, 3, 4, 5, 0] a.take_while {|i| i < 3} #=> [1, 2] @overload take_while @yield [obj] @return [Array] @overload take_while @return [Enumerator];T;0; @%;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#drop;F;[[I"n;T0;[[@i;T;;(;0;[;{;IC;"Drops first +n+ elements from +ary+ and returns the rest of the elements in an array. If a negative number is given, raises an ArgumentError. See also Array#take a = [1, 2, 3, 4, 5, 0] a.drop(3) #=> [4, 5, 0] ;T;[o;H ;II" overload;F;J0;;(;K0;#I" drop(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @R;[;I"@return [Array];T;0; @R;@F;Mi;N0;[[I"n;T0; @R;[;I" Drops first +n+ elements from +ary+ and returns the rest of the elements in an array. If a negative number is given, raises an ArgumentError. See also Array#take a = [1, 2, 3, 4, 5, 0] a.drop(3) #=> [4, 5, 0] @overload drop(n) @return [Array];T;0; @R;@F;Ao;B;CT;Di;Ei;!@T;"I"+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 (result == Qnil) result = rb_ary_new(); return result; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Array#drop_while;F;[;[[@i;T;;);0;[;{;IC;"?Drops elements up to, but not including, the first element for which the block returns +nil+ or +false+ and returns an array containing the remaining elements. If no block is given, an Enumerator is returned instead. See also Array#take_while a = [1, 2, 3, 4, 5, 0] a.drop_while {|i| i < 3 } #=> [3, 4, 5, 0] ;T;[o;H ;II" overload;F;J0;;);K0;#I"drop_while;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @qo;L ;II" return;F;JI";T;0;K[I" Array;T; @q;[;I"!@yield [obj] @return [Array];T;0; @q;@F;Mi;N0;[; @qo;H ;II" overload;F;J0;;);K0;#I"drop_while;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @q;[;I"@return [Enumerator];T;0; @q;@F;Mi;N0;[; @q;[;I"Drops elements up to, but not including, the first element for which the block returns +nil+ or +false+ and returns an array containing the remaining elements. If no block is given, an Enumerator is returned instead. See also Array#take_while a = [1, 2, 3, 4, 5, 0] a.drop_while {|i| i < 3 } #=> [3, 4, 5, 0] @overload drop_while @yield [obj] @return [Array] @overload drop_while @return [Enumerator];T;0; @q;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#bsearch;F;[;[[@i@ ;T;: bsearch;0;[;{;IC;"'By using binary search, finds a value from this array which meets the given condition in O(log n) where n is the size of the array. You can use this method in two modes: a find-minimum mode and a find-any mode. In either case, the elements of the array must be monotone (or sorted) with respect to the block. In find-minimum mode (this is a good choice for typical use cases), the block must always return true or false, and there must be an index i (0 <= i <= ary.size) so that: - the block returns false for any element whose index is less than i, and - the block returns true for any element whose index is greater than or equal to i. This method returns the i-th element. If i is equal to ary.size, it returns nil. ary = [0, 4, 7, 10, 12] ary.bsearch {|x| x >= 4 } #=> 4 ary.bsearch {|x| x >= 6 } #=> 7 ary.bsearch {|x| x >= -1 } #=> 0 ary.bsearch {|x| x >= 100 } #=> nil In find-any mode (this behaves like libc's bsearch(3)), the block must always return a number, and there must be two indices i and j (0 <= i <= j <= ary.size) so that: - the block returns a positive number for ary[k] if 0 <= k < i, - the block returns zero for ary[k] if i <= k < j, and - the block returns a negative number for ary[k] if j <= k < ary.size. Under this condition, this method returns any element whose index is within i...j. If i is equal to j (i.e., there is no element that satisfies the block), this method returns nil. ary = [0, 4, 7, 10, 12] # try to find v such that 4 <= v < 8 ary.bsearch {|x| 1 - x / 4 } #=> 4 or 7 # try to find v such that 8 <= v < 10 ary.bsearch {|x| 4 - x / 2 } #=> nil You must not mix the two modes at a time; the block must always return either true/false, or always return a number. It is undefined which value is actually picked up at each iteration. ;T;[o;H ;II" overload;F;J0;;;K0;#I" bsearch;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"x;T; @;[;I"@yield [x];T;0; @;@F;Mi;N0;[; @;[;I"HBy using binary search, finds a value from this array which meets the given condition in O(log n) where n is the size of the array. You can use this method in two modes: a find-minimum mode and a find-any mode. In either case, the elements of the array must be monotone (or sorted) with respect to the block. In find-minimum mode (this is a good choice for typical use cases), the block must always return true or false, and there must be an index i (0 <= i <= ary.size) so that: - the block returns false for any element whose index is less than i, and - the block returns true for any element whose index is greater than or equal to i. This method returns the i-th element. If i is equal to ary.size, it returns nil. ary = [0, 4, 7, 10, 12] ary.bsearch {|x| x >= 4 } #=> 4 ary.bsearch {|x| x >= 6 } #=> 7 ary.bsearch {|x| x >= -1 } #=> 0 ary.bsearch {|x| x >= 100 } #=> nil In find-any mode (this behaves like libc's bsearch(3)), the block must always return a number, and there must be two indices i and j (0 <= i <= j <= ary.size) so that: - the block returns a positive number for ary[k] if 0 <= k < i, - the block returns zero for ary[k] if i <= k < j, and - the block returns a negative number for ary[k] if j <= k < ary.size. Under this condition, this method returns any element whose index is within i...j. If i is equal to j (i.e., there is no element that satisfies the block), this method returns nil. ary = [0, 4, 7, 10, 12] # try to find v such that 4 <= v < 8 ary.bsearch {|x| 1 - x / 4 } #=> 4 or 7 # try to find v such that 8 <= v < 10 ary.bsearch {|x| 4 - x / 2 } #=> nil You must not mix the two modes at a time; the block must always return either true/false, or always return a number. It is undefined which value is actually picked up at each iteration. @overload bsearch @yield [x];T;0; @;@F;Ao;B;CT;Di ;Ei= ;!@T;"I"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; ; F; ;,;;;I"Array#bsearch_index;F;[;[[@iX ;T;:bsearch_index;0;[;{;IC;"By using binary search, finds an index of a value from this array which meets the given condition in O(log n) where n is the size of the array. It supports two modes, depending on the nature of the block. They are exactly the same as in the case of the #bsearch method, with the only difference being that this method returns the index of the element instead of the element itself. For more details consult the documentation for #bsearch. ;T;[o;H ;II" overload;F;J0;;;K0;#I"bsearch_index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"x;T; @o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @;[;I"&@yield [x] @return [Integer, nil];T;0; @;@F;Mi;N0;[; @;[;I"By using binary search, finds an index of a value from this array which meets the given condition in O(log n) where n is the size of the array. It supports two modes, depending on the nature of the block. They are exactly the same as in the case of the #bsearch method, with the only difference being that this method returns the index of the element instead of the element itself. For more details consult the documentation for #bsearch. @overload bsearch_index @yield [x] @return [Integer, nil];T;0; @;@F;Ao;B;CT;DiK ;EiV ;!@T;"I"Kstatic 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 (v == Qfalse || v == Qnil) { 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; ; F; ;,;;;I"Array#any?;F;[[@0;[[@i.;T;;;0;[;{;IC;"See also Enumerable#any?;T;[o;H ;II" overload;F;J0;;;K0;#I" any?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"#@yield [obj] @return [Boolean];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"any?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" pattern;T0; @;[;I"}See also Enumerable#any? @overload any? @yield [obj] @return [Boolean] @overload any?(pattern) @return [Boolean];T;0; @;@F;Ao;B;CT;Di&;Ei-;Mi;!@T;"I"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; ; F; ;,;;;I"Array#all?;F;[[@0;[[@iR;T;;;0;[;{;IC;"See also Enumerable#all?;T;[o;H ;II" overload;F;J0;;;K0;#I" all?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @ o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"#@yield [obj] @return [Boolean];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I"all?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" pattern;T0; @ ;[;I"}See also Enumerable#all? @overload all? @yield [obj] @return [Boolean] @overload all?(pattern) @return [Boolean];T;0; @ ;@F;Ao;B;CT;DiJ;EiQ;Mi;!@T;"I"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; ; F; ;,;;;I"Array#none?;F;[[@0;[[@iv;T;;;0;[;{;IC;"See also Enumerable#none?;T;[o;H ;II" overload;F;J0;;;K0;#I" none?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @:o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @:;[;I"#@yield [obj] @return [Boolean];T;0; @:;@F;Mi;N0;[; @:o;H ;II" overload;F;J0;;;K0;#I"none?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @:;[;I"@return [Boolean];T;0; @:;@F;Mi;N0;[[I" pattern;T0; @:;[;I"{See also Enumerable#none? @overload none? @yield [obj] @return [Boolean] @overload none?(pattern) @return [Boolean];T;0; @:;@F;Ao;B;CT;Din;Eiu;Mi;!@T;"I"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; ; F; ;,;;;I"Array#one?;F;[[@0;[[@i;T;;;0;[;{;IC;"See also Enumerable#one?;T;[o;H ;II" overload;F;J0;;;K0;#I" one?;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @jo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @j;[;I"#@yield [obj] @return [Boolean];T;0; @j;@F;Mi;N0;[; @jo;H ;II" overload;F;J0;;;K0;#I"one?(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @j;[;I"@return [Boolean];T;0; @j;@F;Mi;N0;[[I" pattern;T0; @j;[;I"}See also Enumerable#one? @overload one? @yield [obj] @return [Boolean] @overload one?(pattern) @return [Boolean];T;0; @j;@F;Ao;B;CT;Di;Ei;Mi;!@T;"I"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; ; F; ;,;;;I"Array#dig;F;[[@0;[[@i;T;;;0;[;{;IC;"Extracts the nested value specified by the sequence of idx objects by calling +dig+ at each step, returning +nil+ if any intermediate step is +nil+. a = [[1, [2, 3]]] a.dig(0, 1, 1) #=> 3 a.dig(1, 2, 3) #=> nil a.dig(0, 0, 0) #=> TypeError: Integer does not have #dig method [42, {foo: :bar}].dig(1, :foo) #=> :bar ;T;[o;H ;II" overload;F;J0;;;K0;#I"dig(idx, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"idx;T0[I"...;T0; @;[;I"Extracts the nested value specified by the sequence of idx objects by calling +dig+ at each step, returning +nil+ if any intermediate step is +nil+. a = [[1, [2, 3]]] a.dig(0, 1, 1) #=> 3 a.dig(1, 2, 3) #=> nil a.dig(0, 0, 0) #=> TypeError: Integer does not have #dig method [42, {foo: :bar}].dig(1, :foo) #=> :bar @overload dig(idx, ...) @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I"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; ; F; ;,;;;I"Array#sum;F;[[@0;[[@i;T;;|;0;[;{;IC;"0Returns the sum of elements. For example, [e1, e2, e3].sum returns init + e1 + e2 + e3. If a block is given, the block is applied to each element before addition. If ary is empty, it returns init. [].sum #=> 0 [].sum(0.0) #=> 0.0 [1, 2, 3].sum #=> 6 [3, 5.5].sum #=> 8.5 [2.5, 3.0].sum(0.0) {|e| e * e } #=> 15.25 [Object.new].sum #=> TypeError The (arithmetic) mean value of an array can be obtained as follows. mean = ary.sum(0.0) / ary.length This method can be used for non-numeric objects by explicit init argument. ["a", "b", "c"].sum("") #=> "abc" [[1], [[2]], [3]].sum([]) #=> [1, [2], 3] However, Array#join and Array#flatten is faster than Array#sum for array of strings and array of arrays. ["a", "b", "c"].join #=> "abc" [[1], [[2]], [3]].flatten(1) #=> [1, [2], 3] Array#sum method may not respect method redefinition of "+" methods such as Integer#+. ;T;[o;H ;II" overload;F;J0;;|;K0;#I"sum(init=0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I" init;TI"0;T; @o;H ;II" overload;F;J0;;|;K0;#I"sum(init=0);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"e;T; @o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"!@yield [e] @return [Numeric];T;0; @;@F;Mi;N0;[[I" init;TI"0;T; @;[;I"Returns the sum of elements. For example, [e1, e2, e3].sum returns init + e1 + e2 + e3. If a block is given, the block is applied to each element before addition. If ary is empty, it returns init. [].sum #=> 0 [].sum(0.0) #=> 0.0 [1, 2, 3].sum #=> 6 [3, 5.5].sum #=> 8.5 [2.5, 3.0].sum(0.0) {|e| e * e } #=> 15.25 [Object.new].sum #=> TypeError The (arithmetic) mean value of an array can be obtained as follows. mean = ary.sum(0.0) / ary.length This method can be used for non-numeric objects by explicit init argument. ["a", "b", "c"].sum("") #=> "abc" [[1], [[2]], [3]].sum([]) #=> [1, [2], 3] However, Array#join and Array#flatten is faster than Array#sum for array of strings and array of arrays. ["a", "b", "c"].join #=> "abc" [[1], [[2]], [3]].flatten(1) #=> [1, [2], 3] Array#sum method may not respect method redefinition of "+" methods such as Integer#+. @overload sum(init=0) @return [Numeric] @overload sum(init=0) @yield [e] @return [Numeric];T;0; @;@F;Ao;B;CT;Di;Ei;!@T;"I" 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_TYPE_P(e, T_BIGNUM)) 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 http://link.springer.com/article/10.1007/s00607-005-0139-x */ double f, c; f = NUM2DBL(v); c = 0.0; goto has_float_value; for (; i < RARRAY_LEN(ary); i++) { double x, t; 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_TYPE_P(e, T_BIGNUM)) 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; ; F; ;,;;;I"Array#__resize__;F;[[I"len;T0;[[I"%ext/-test-/array/resize/resize.c;Ti;T;:__resize__;0;[;{;IC;" ;T;[;[;@;0; @;!@T;"I"mstatic VALUE ary_resize(VALUE ary, VALUE len) { rb_ary_resize(ary, NUM2LONG(len)); return ary; };T;#I"static VALUE;T;$T;&@T;'IC;[;&@T;(IC;[@C;&@T;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{ @:;i@ ;@;@{;;.[;[[@iz;F;;;;0;;;[;{;IC;"iArrays are ordered, integer-indexed collections of any object. Array indexing starts at 0, as in C or Java. A negative index is assumed to be relative to the end of the array---that is, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on. == Creating Arrays A new array can be created by using the literal constructor []. Arrays 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 explicitly 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] ;T;[;[;I"kArrays are ordered, integer-indexed collections of any object. Array indexing starts at 0, as in C or Java. A negative index is assumed to be relative to the end of the array---that is, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on. == Creating Arrays A new array can be created by using the literal constructor []. Arrays 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 explicitly 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] ;T;0; @T;@F;Ao;B;CT;Di;Eiq;!@;I" Array;F;1@251, :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;H ;II" overload;F;J0;;3;K0;#I" stat;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;3;K0;#I"stat(hsh);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I"hsh;T0; @o;H ;II" overload;F;J0;;3;K0;#I"stat(Symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @;[;I"@return [Numeric];T;0; @;@F;Mi;N0;[[I" Symbol;T0; @;[;I"Returns a Hash containing implementation-dependent counters inside the VM. This hash includes information about method/constant cache serials: { :global_method_state=>251, :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;Ao;B;CT;Di;Ei;!@;"I"xstatic VALUE vm_stat(int argc, VALUE *argv, VALUE self) { static VALUE sym_global_method_state, sym_global_constant_state, sym_class_serial; 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_method_state == 0) { #define S(s) sym_##s = ID2SYM(rb_intern_const(#s)) S(global_method_state); S(global_constant_state); S(class_serial); #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_method_state, ruby_vm_global_method_state); SET(global_constant_state, ruby_vm_global_constant_state); SET(class_serial, ruby_vm_class_serial); #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; ;IC;[o; ; F; ;;;;I"RubyVM::MJIT.enabled?;F;[;[[@i ;T;;;0;[;{;IC;"#Returns true if JIT is enabled;T;[o;L ;II" return;F;J@;0;K[@; @L;[;I"#Returns true if JIT is enabled;T;0; @L;@F;Ao;B;CT;Di ;Ei ;Mi;!@J;"I"Tstatic VALUE mjit_enabled_p(void) { return mjit_enabled ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"RubyVM::MJIT.pause;F;[;[[@i ;T;: pause;0;[;{;IC;" ;T;[;[;@;0; @];!@J;"I"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; ; F; ;;;;I"RubyVM::MJIT.resume;F;[;[;F;: resume;;0;[;{;IC;" ;T;[;[;@;0; @i;!@J;$T;&@J;'IC;[;&@J;(IC;[;&@J;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@im ;F;: MJIT;;0;;;[;{;IC;" ;T;[;[;@;0; @J;Mi;!@;I"RubyVM::MJIT;Fo; ; F; ;;;;I"$RubyVM.USAGE_ANALYSIS_INSN_STOP;F;[;[[@i= ;T;:USAGE_ANALYSIS_INSN_STOP;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"7static VALUE usage_analysis_insn_stop(VALUE self);;T;#I"7static VALUE usage_analysis_insn_stop(VALUE self);;T;$To; ; F; ;;;;I"'RubyVM.USAGE_ANALYSIS_OPERAND_STOP;F;[;[[@i> ;T;: USAGE_ANALYSIS_OPERAND_STOP;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I":static VALUE usage_analysis_operand_stop(VALUE self);;T;#I":static VALUE usage_analysis_operand_stop(VALUE self);;T;$To; ; F; ;;;;I"(RubyVM.USAGE_ANALYSIS_REGISTER_STOP;F;[;[[@i? ;T;:!USAGE_ANALYSIS_REGISTER_STOP;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I";static VALUE usage_analysis_register_stop(VALUE self);;T;#I";static VALUE usage_analysis_register_stop(VALUE self);;T;$To;9;[[@i ;F;: OPTS;;;;;;[;{;IC;"/RubyVM::OPTS, which shows vm build options ;T;[;[;I"/RubyVM::OPTS, which shows vm build options;T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;I"RubyVM::OPTS;F; #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; i :SCOPE call = root.children[2] call.type # => :OPCALL ;T;[o;H ;II" overload;F;J0;;s;K0;#I" type;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"Returns the type of this node as a symbol. root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") root.type # => :SCOPE call = root.children[2] call.type # => :OPCALL @overload type;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_ast_node_type(VALUE self) { struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); return rb_sym_intern_ascii_cstr(node_type_to_str(data->node)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"2RubyVM::AbstractSyntaxTree::Node#first_lineno;F;[;[[@i;T;:first_lineno;0;[;{;IC;"DThe line number in the source code where this AST's text began. ;T;[o;H ;II" overload;F;J0;;;K0;#I"first_lineno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ ;[;I"@return [Integer];T;0; @ ;@F;Mi;N0;[; @ ;[;I"qThe line number in the source code where this AST's text began. @overload first_lineno @return [Integer];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_ast_node_first_lineno(VALUE self) { struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); return INT2NUM(nd_first_lineno(data->node)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"2RubyVM::AbstractSyntaxTree::Node#first_column;F;[;[[@i;T;:first_column;0;[;{;IC;"FThe column number in the source code where this AST's text began. ;T;[o;H ;II" overload;F;J0;;;K0;#I"first_column;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @';[;I"@return [Integer];T;0; @';@F;Mi;N0;[; @';[;I"sThe column number in the source code where this AST's text began. @overload first_column @return [Integer];T;0; @';@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_ast_node_first_column(VALUE self) { struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); return INT2NUM(nd_first_column(data->node)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"1RubyVM::AbstractSyntaxTree::Node#last_lineno;F;[;[[@i;T;:last_lineno;0;[;{;IC;"DThe line number in the source code where this AST's text ended. ;T;[o;H ;II" overload;F;J0;;;K0;#I"last_lineno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @B;[;I"@return [Integer];T;0; @B;@F;Mi;N0;[; @B;[;I"pThe line number in the source code where this AST's text ended. @overload last_lineno @return [Integer];T;0; @B;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_ast_node_last_lineno(VALUE self) { struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); return INT2NUM(nd_last_lineno(data->node)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"1RubyVM::AbstractSyntaxTree::Node#last_column;F;[;[[@i;T;:last_column;0;[;{;IC;"FThe column number in the source code where this AST's text ended. ;T;[o;H ;II" overload;F;J0;;;K0;#I"last_column;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @];[;I"@return [Integer];T;0; @];@F;Mi;N0;[; @];[;I"rThe column number in the source code where this AST's text ended. @overload last_column @return [Integer];T;0; @];@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_ast_node_last_column(VALUE self) { struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); return INT2NUM(nd_last_column(data->node)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I".RubyVM::AbstractSyntaxTree::Node#children;F;[;[[@i;T;: children;0;[;{;IC;"Returns AST nodes under this one. Each kind of node has different children, depending on what kind of node it is. The returned array may contain other nodes or nil. ;T;[o;H ;II" overload;F;J0;;;K0;#I" children;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @x;[;I"@return [Array];T;0; @x;@F;Mi;N0;[; @x;[;I"Returns AST nodes under this one. Each kind of node has different children, depending on what kind of node it is. The returned array may contain other nodes or nil. @overload children @return [Array];T;0; @x;@F;Ao;B;CT;Div;Ei};!@;"I"static VALUE rb_ast_node_children(VALUE self) { struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); return node_children(data->ast, data->node); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"-RubyVM::AbstractSyntaxTree::Node#inspect;F;[;[[@i;T;;i;0;[;{;IC;"?Returns debugging information about this node as a string. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"fReturns debugging information about this node as a string. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_ast_node_inspect(VALUE self) { VALUE str; VALUE cname; struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); cname = rb_class_path(rb_obj_class(self)); str = rb_str_new2("#<"); rb_str_append(str, cname); rb_str_catf(str, ":%s@%d:%d-%d:%d>", node_type_to_str(data->node), nd_first_lineno(data->node), nd_first_column(data->node), nd_last_lineno(data->node), nd_last_column(data->node)); return str; };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;: Node;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"%RubyVM::AbstractSyntaxTree::Node;F;1@ # ;T;[o;H ;II" overload;F;J0;:%RubyVM::AbstractSyntaxTree.parse;K0;#I"-RubyVM::AbstractSyntaxTree.parse(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"%RubyVM::AbstractSyntaxTree::Node;T; @;[;I"/@return [RubyVM::AbstractSyntaxTree::Node];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"qParses the given string into an abstract syntax tree, returning the root node of that tree. SyntaxError is raised if the given string is invalid syntax. RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") # => # @overload RubyVM::AbstractSyntaxTree.parse(string) @return [RubyVM::AbstractSyntaxTree::Node];T;0; @;@F;Ao;B;CT;DiQ;Ei[;!@;"I"_static VALUE rb_ast_s_parse(VALUE module, VALUE str) { return rb_ast_parse_str(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"*RubyVM::AbstractSyntaxTree.parse_file;F;[[I" path;T0;[[@iz;T;:parse_file;0;[;{;IC;"WReads the file from pathname, then parses it like ::parse, returning the root node of the abstract syntax tree. SyntaxError is raised if pathname's contents are not valid Ruby syntax. RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb") # => # ;T;[o;H ;II" overload;F;J0;:*RubyVM::AbstractSyntaxTree.parse_file;K0;#I"4RubyVM::AbstractSyntaxTree.parse_file(pathname);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"%RubyVM::AbstractSyntaxTree::Node;T; @;[;I"/@return [RubyVM::AbstractSyntaxTree::Node];T;0; @;@F;Mi;N0;[[I" pathname;T0; @;[;I" Reads the file from pathname, then parses it like ::parse, returning the root node of the abstract syntax tree. SyntaxError is raised if pathname's contents are not valid Ruby syntax. RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb") # => # @overload RubyVM::AbstractSyntaxTree.parse_file(pathname) @return [RubyVM::AbstractSyntaxTree::Node];T;0; @;@F;Ao;B;CT;Dim;Eix;!@;"I"gstatic VALUE rb_ast_s_parse_file(VALUE module, VALUE path) { return rb_ast_parse_file(path); };T;#I"static VALUE;T;$To; ; F; ;;;;I""RubyVM::AbstractSyntaxTree.of;F;[[I" body;T0;[[@i;T;:of;0;[;{;IC;"LReturns AST nodes of the given proc or method. RubyVM::AbstractSyntaxTree.of(proc {1 + 2}) # => # def hello puts "hello, world" end RubyVM::AbstractSyntaxTree.of(method(:hello)) # => # ;T;[o;H ;II" overload;F;J0;:"RubyVM::AbstractSyntaxTree.of;K0;#I"(RubyVM::AbstractSyntaxTree.of(proc);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"%RubyVM::AbstractSyntaxTree::Node;T; @;[;I"/@return [RubyVM::AbstractSyntaxTree::Node];T;0; @;@F;Mi;N0;[[I" proc;T0; @o;H ;II" overload;F;J0;;;K0;#I"*RubyVM::AbstractSyntaxTree.of(method);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"%RubyVM::AbstractSyntaxTree::Node;T; @;[;I"/@return [RubyVM::AbstractSyntaxTree::Node];T;0; @;@F;Mi;N0;[[I" method;T0; @;[;I" Returns AST nodes of the given proc or method. RubyVM::AbstractSyntaxTree.of(proc {1 + 2}) # => # def hello puts "hello, world" end RubyVM::AbstractSyntaxTree.of(method(:hello)) # => # @overload RubyVM::AbstractSyntaxTree.of(proc) @return [RubyVM::AbstractSyntaxTree::Node] @overload RubyVM::AbstractSyntaxTree.of(method) @return [RubyVM::AbstractSyntaxTree::Node];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_ast_s_of(VALUE module, VALUE body) { VALUE path, node, lines; int node_id; 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 { iseq = rb_method_iseq(body); } if (!iseq) return Qnil; path = rb_iseq_path(iseq); node_id = iseq->body->location.node_id; if (!NIL_P(lines = script_lines(path))) { node = rb_ast_parse_array(lines); } else if (RSTRING_LEN(path) == 2 && memcmp(RSTRING_PTR(path), "-e", 2) == 0) { node = rb_ast_parse_str(rb_e_script); } else { node = rb_ast_parse_file(path); } return node_find(node, node_id); };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;:AbstractSyntaxTree;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"RubyVM::AbstractSyntaxTree;Fo; ;IC;[ o; ; F; ;;;;I"*RubyVM::InstructionSequence.iseq_load;T;[[@0;[[I"%ext/-test-/iseq_load/iseq_load.c;Ti ;T;:iseq_load;0;[;{;IC;" ;T;[;[;@;0; @:;!@8;"I"static VALUE iseq_load(int argc, VALUE *argv, VALUE self) { VALUE data, opt = Qnil; rb_scan_args(argc, argv, "11", &data, &opt); return rb_iseq_load(data, 0, opt); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"(RubyVM::InstructionSequence#inspect;T;[;[[I" iseq.c;Ti;T;;i;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; @H;@F;Ao;B;CT;Di;Ei;!@8;"I"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; ; F; ;,;;;I"'RubyVM::InstructionSequence#disasm;T;[;[[@Mi;T;: disasm;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;H ;II" overload;F;J0;;;K0;#I" disasm;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @W;[;I"@return [String];T;0; @W;@F;Mi;N0;[; @Wo;H ;II" overload;F;J0;:disassemble;K0;#I"disassemble;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @W;[;I"@return [String];T;0; @W;@F;Mi;N0;[; @W;[;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; @W;@F;Ao;B;CT;Diu;Ei;!@8;"I"\static VALUE iseqw_disasm(VALUE self) { return rb_iseq_disasm(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I",RubyVM::InstructionSequence#disassemble;T;[;[[@Mi;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;H ;II" overload;F;J0;;;K0;#I" disasm;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"disassemble;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;@{;0; @;@F;Ao;B;CT;Diu;Ei;!@8;"I"\static VALUE iseqw_disasm(VALUE self) { return rb_iseq_disasm(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"%RubyVM::InstructionSequence#to_a;T;[;[[@Mi;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;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@8;"I"static VALUE iseqw_to_a(VALUE self) { const rb_iseq_t *iseq = iseqw_check(self); rb_secure(1); return iseq_data_to_ary(iseq); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"%RubyVM::InstructionSequence#eval;T;[;[[@Mi;T;;;0;[;{;IC;"|Evaluates the instruction sequence and returns the result. RubyVM::InstructionSequence.compile("1 + 2").eval #=> 3 ;T;[o;H ;II" overload;F;J0;;;K0;#I" eval;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"Evaluates the instruction sequence and returns the result. RubyVM::InstructionSequence.compile("1 + 2").eval #=> 3 @overload eval @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@8;"I"jstatic VALUE iseqw_eval(VALUE self) { rb_secure(1); return rb_iseq_eval(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"*RubyVM::InstructionSequence#to_binary;T;[[@0;[[@Mi ;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;H ;II" overload;F;J0;;;K0;#I" to_binary(extra_data = nil);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Diq ;Ei ;!@8;"I"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; ; F; ;;;;I"1RubyVM::InstructionSequence.load_from_binary;T;[[I"str;T0;[[@Mi ;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;H ;II" overload;F;J0;:1RubyVM::InstructionSequence.load_from_binary;K0;#I"9RubyVM::InstructionSequence.load_from_binary(binary);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@8;"I"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; ; F; ;;;;I" 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;Ao;B;CT;Di;Ei%;!@8;"I"Xstatic VALUE iseqw_path(VALUE self) { return rb_iseq_path(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I".RubyVM::InstructionSequence#absolute_path;T;[;[[@Mi=;T;;;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; @=;@F;Ao;B;CT;Di-;Ei;;!@8;"I"estatic VALUE iseqw_absolute_path(VALUE self) { return rb_iseq_realpath(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&RubyVM::InstructionSequence#label;T;[;[[@MiZ;T;;;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; @K;@F;Ao;B;CT;DiC;EiY;!@8;"I"Zstatic VALUE iseqw_label(VALUE self) { return rb_iseq_label(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"+RubyVM::InstructionSequence#base_label;T;[;[[@Mit;T;;;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; @Y;@F;Ao;B;CT;Di`;Eis;!@8;"I"dstatic VALUE iseqw_base_label(VALUE self) { return rb_iseq_base_label(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"-RubyVM::InstructionSequence#first_lineno;T;[;[[@Mi;T;;;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; @g;@F;Ao;B;CT;Diz;Ei;!@8;"I"hstatic VALUE iseqw_first_lineno(VALUE self) { return rb_iseq_first_lineno(iseqw_check(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"-RubyVM::InstructionSequence#trace_points;T;[;[[@Mi;T;:trace_points;0;[;{;IC;"cReturn trace points in the instruction sequence. Return an array of [line, event_symbol] pair. ;T;[o;H ;II" overload;F;J0;;;K0;#I"trace_points;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @u;[;I"@return [Array];T;0; @u;@F;Mi;N0;[; @u;[;I"Return trace points in the instruction sequence. Return an array of [line, event_symbol] pair. @overload trace_points @return [Array];T;0; @u;@F;Ao;B;CT;Di;Ei;!@8;"I"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; ; F; ;,;;;I"+RubyVM::InstructionSequence#each_child;T;[;[[@Mi;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;H ;II" overload;F;J0;;;K0;#I"each_child;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"child_iseq;T; @;[;I"@yield [child_iseq];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@8;"I"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; ; F; ;,;;;I"-RubyVM::InstructionSequence#marshal_dump;T;[;[;F;;e;;0;[;{;IC;" ;T;[;[;@;0; @;!@8;$To; ; F; ;,;;;I"-RubyVM::InstructionSequence#marshal_load;T;[;[;F;;f;;0;[;{;IC;" ;T;[;[;@;0; @;!@8;$To; ; F; ;;;;I"%RubyVM::InstructionSequence.load;T;[[@0;[[@Mid;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc: ;T;0; @;@F;Ao;B;CT;Dia;Eib;!@8;"I"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; ; F; ;;;;I"(RubyVM::InstructionSequence.compile;T;[[@0;[[@MiG;T;;;0;[;{;IC;";Takes +source+, a String of Ruby code and compiles it to an InstructionSequence. Optionally takes +file+, +path+, and +line+ which describe the filename, absolute path and first line number of the ruby code in +source+ which are metadata attached to the returned +iseq+. +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") #=> @> ;T;[o;H ;II" overload;F;J0;;;K0;#I"7compile(source[, file[, path[, line[, options]]]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I".source[, file[, path[, line[, options]]]];T0; @o;H ;II" overload;F;J0;; ;K0;#I"3new(source[, file[, path[, line[, options]]]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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 filename, absolute path and first line number of the ruby code in +source+ which are metadata attached to the returned +iseq+. +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") #=> @> @overload compile(source[, file[, path[, line[, options]]]]) @overload new(source[, file[, path[, line[, options]]]]);T;0; @;@F;Ao;B;CT;Di2;EiD;!@8;"I"static VALUE iseqw_s_compile(int argc, VALUE *argv, VALUE self) { VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil; int i; rb_secure(1); 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, 0, opt)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"$RubyVM::InstructionSequence.new;T;[[@0;[[@MiG;T;; ;0;[;{;IC;";Takes +source+, a String of Ruby code and compiles it to an InstructionSequence. Optionally takes +file+, +path+, and +line+ which describe the filename, absolute path and first line number of the ruby code in +source+ which are metadata attached to the returned +iseq+. +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") #=> @> ;T;[o;H ;II" overload;F;J0;;;K0;#I"7compile(source[, file[, path[, line[, options]]]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I".source[, file[, path[, line[, options]]]];T0; @o;H ;II" overload;F;J0;; ;K0;#I"3new(source[, file[, path[, line[, options]]]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I".source[, file[, path[, line[, options]]]];T0; @;[;@;0; @;@F;Ao;B;CT;Di2;EiD;!@8;"I"static VALUE iseqw_s_compile(int argc, VALUE *argv, VALUE self) { VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil; int i; rb_secure(1); 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, 0, opt)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"-RubyVM::InstructionSequence.compile_file;T;[[@0;[[@Miv;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;H ;II" overload;F;J0;;;K0;#I""compile_file(file[, options]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dib;Eis;!@8;"I"Gstatic 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; rb_secure(1); 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_parser_compile_file_path(parser, file, f, NUM2INT(line)); 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, ISEQ_TYPE_TOP, &option)); rb_ast_dispose(ast); return ret; };T;#I"static VALUE;T;$To; ; F; ;;;;I"/RubyVM::InstructionSequence.compile_option;T;[;[[@Mi;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;H ;II" overload;F;J0;;;K0;#I"compile_option;T;IC;";T;[;[;I";T;0; @*;@F;Mi;N0;[; @*;[;I"Returns a hash of default options used by the Ruby iseq compiler. For details, see InstructionSequence.compile_option=. @overload compile_option;T;0; @*;@F;Ao;B;CT;Di;Ei;!@8;"I"{static VALUE iseqw_s_compile_option_get(VALUE self) { return make_compile_option_value(&COMPILE_OPTION_DEFAULT); };T;#I"static VALUE;T;$To; ; F; ;;;;I"0RubyVM::InstructionSequence.compile_option=;T;[[I"opt;T0;[[@Mi;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;H ;II" overload;F;J0;;;K0;#I"compile_option=(options);T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[[I" options;T0; @@;[;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; @@;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE iseqw_s_compile_option_set(VALUE self, VALUE opt) { rb_compile_option_t option; rb_secure(1); make_compile_option(&option, opt); COMPILE_OPTION_DEFAULT = option; return opt; };T;#I"static VALUE;T;$To; ; F; ;;;;I"'RubyVM::InstructionSequence.disasm;T;[[I" body;T0;[[@Mii ;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;H ;II" overload;F;J0;;;K0;#I"disasm(body);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Z;[;I"@return [String];T;0; @Z;@F;Mi;N0;[[I" body;T0; @Zo;H ;II" overload;F;J0;;;K0;#I"disassemble(body);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Z;[;I"@return [String];T;0; @Z;@F;Mi;N0;[[I" body;T0; @Z;[;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; @Z;@F;Ao;B;CT;Di5 ;Eih ;!@8;"I"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; ; F; ;;;;I",RubyVM::InstructionSequence.disassemble;T;[[I" body;T0;[[@Mii ;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;H ;II" overload;F;J0;;;K0;#I"disasm(body);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" body;T0; @o;H ;II" overload;F;J0;;;K0;#I"disassemble(body);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" body;T0; @;[;@;0; @;@F;Ao;B;CT;Di5 ;Eih ;!@8;"I"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; ; F; ;;;;I"#RubyVM::InstructionSequence.of;T;[[I" body;T0;[[@Mi ;T;;;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;Ao;B;CT;Di;Ei ;!@8;"I"static VALUE iseqw_s_of(VALUE klass, VALUE body) { const rb_iseq_t *iseq = NULL; rb_secure(1); 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;$T;&@8;'IC;[;&@8;(IC;[;&@8;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Mi, [@MiD ;T;:InstructionSequence;;0;;;[;{;IC;"The InstructionSequence class represents a compiled sequence of instructions for the Ruby Virtual Machine. 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 the Ruby VM 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.;T;[;[;I" The InstructionSequence class represents a compiled sequence of instructions for the Ruby Virtual Machine. 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 the Ruby VM 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. ;T;0; @8;@F;Ao;B;CT;Di, ;Ei< ;Mi;!o;2 ;30;40;50;: RubyVM;!@;7@;F0;I" RubyVM::InstructionSequence;T;1@<;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iL [@iS ;T;;;;0;;;[;{;IC;"The RubyVM module provides some access to Ruby internals. This module is for very limited purposes, such as debugging, prototyping, and research. Normal users must not use it.;T;[;[;I" The RubyVM module provides some access to Ruby internals. This module is for very limited purposes, such as debugging, prototyping, and research. Normal users must not use it. ;T;0; @;@F;Ao;B;CT;DiL ;EiP ;Mi;!@;I" RubyVM;F;1@false, the range will include the end object; otherwise, it will be excluded. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"'new(begin, end, exclude_end=false);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"Constructs a range using the given +begin+ and +end+. If the +exclude_end+ parameter is omitted or is false, the range will include the end object; otherwise, it will be excluded. @overload new(begin, end, exclude_end=false);T;0; @;@F;Ao;B;CT;DiJ;EiO;!@;"I"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; ; F; ;,;;;I"Range#initialize_copy;F;[[I" orig;T0;[[@i_;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @ ;@F;Ao;B;CT;Di^;Ei^;!@;"I"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; ; F; ;,;;;I" Range#==;F;[[I"obj;T0;[[@i;T;;S;0;[;{;IC;",Returns true only if +obj+ is a Range, has equivalent begin and end items (by comparing them with ==), and has the same #exclude_end? setting as the range. (0..2) == (0..2) #=> true (0..2) == Range.new(0,2) #=> true (0..2) == (0...2) #=> false ;T;[o;H ;II" overload;F;J0;;S;K0;#I" ==(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ ;[;I"UReturns true only if +obj+ is a Range, has equivalent begin and end items (by comparing them with ==), and has the same #exclude_end? setting as the range. (0..2) == (0..2) #=> true (0..2) == Range.new(0,2) #=> true (0..2) == (0...2) #=> false @overload ==(obj) @return [Boolean];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Range#===;F;[[I"val;T0;[[@i;T;;O;0;[;{;IC;"`Returns true if +obj+ is an element of the range, false otherwise. Conveniently, === is the comparison operator used by case statements. case 79 when 1..50 then print "low\n" when 51..75 then print "medium\n" when 76..100 then print "high\n" end produces: high ;T;[o;H ;II" overload;F;J0;;O;K0;#I" ===(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @? ;[;I"@return [Boolean];T;0; @? ;@F;Mi;N0;[[I"obj;T0; @? ;[;I"Returns true if +obj+ is an element of the range, false otherwise. Conveniently, === is the comparison operator used by case statements. case 79 when 1..50 then print "low\n" when 51..75 then print "medium\n" when 76..100 then print "high\n" end produces: high @overload ===(obj) @return [Boolean];T;0; @? ;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE range_eqq(VALUE range, VALUE val) { VALUE ret = range_include_internal(range, val); if (ret != Qundef) return ret; return r_cover_p(range, RANGE_BEG(range), RANGE_END(range), val); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#eql?;F;[[I"obj;T0;[[@i;T;;R;0;[;{;IC;"1Returns true only if +obj+ is a Range, has equivalent begin and end items (by comparing them with eql?), and has the same #exclude_end? setting as the range. (0..2).eql?(0..2) #=> true (0..2).eql?(Range.new(0,2)) #=> true (0..2).eql?(0...2) #=> false;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @^ ;[;I"@return [Boolean];T;0; @^ ;@F;Mi;N0;[[I"obj;T0; @^ ;[;I"\Returns true only if +obj+ is a Range, has equivalent begin and end items (by comparing them with eql?), and has the same #exclude_end? setting as the range. (0..2).eql?(0..2) #=> true (0..2).eql?(Range.new(0,2)) #=> true (0..2).eql?(0...2) #=> false @overload eql?(obj) @return [Boolean];T;0; @^ ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Range#hash;F;[;[[@i;T;;U;0;[;{;IC;"Compute a hash-code for this range. Two ranges with equal begin and end points (using eql?), and the same #exclude_end? value will generate the same hash-code. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @} ;[;I"@return [Integer];T;0; @} ;@F;Mi;N0;[; @} ;[;I"Compute a hash-code for this range. Two ranges with equal begin and end points (using eql?), and the same #exclude_end? value will generate the same hash-code. See also Object#hash. @overload hash @return [Integer];T;0; @} ;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Range#each;F;[;[[@i8;T;;;0;[;{;IC;"Iterates over the elements of range, passing each in turn to the block. The +each+ method can only be used if the begin object of the range supports the +succ+ method. A TypeError is raised if the object does not have +succ+ method defined (like Float). If no block is given, an enumerator is returned instead. (10..15).each {|n| print n, ' ' } # prints: 10 11 12 13 14 15 (2.5..5).each {|n| print n, ' ' } # raises: TypeError: can't iterate from Float ;T;[o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @ ;[;I"@yield [ i ];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[; @ ;[;I"Iterates over the elements of range, passing each in turn to the block. The +each+ method can only be used if the begin object of the range supports the +succ+ method. A TypeError is raised if the object does not have +succ+ method defined (like Float). If no block is given, an enumerator is returned instead. (10..15).each {|n| print n, ' ' } # prints: 10 11 12 13 14 15 (2.5..5).each {|n| print n, ' ' } # raises: TypeError: can't iterate from Float @overload each @yield [ i ] @overload each;T;0; @ ;@F;Ao;B;CT;Di#;Ei5;!@;"I" static VALUE range_each(VALUE range) { VALUE beg, end; long i, lim; RETURN_SIZED_ENUMERATOR(range, 0, 0, range_enum_size); beg = RANGE_BEG(range); end = RANGE_END(range); if (FIXNUM_P(beg) && NIL_P(end)) { fixnum_endless: i = FIX2LONG(beg); while (FIXABLE(i)) { rb_yield(LONG2FIX(i++)); } beg = LONG2NUM(i); bignum_endless: for (;; beg = rb_big_plus(beg, INT2FIX(1))) rb_yield(beg); } else if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */ fixnum_loop: lim = FIX2LONG(end); if (!EXCL(range)) lim += 1; for (i = FIX2LONG(beg); i < lim; i++) { rb_yield(LONG2FIX(i)); } } 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)) goto fixnum_endless; if (FIXNUM_P(end)) goto fixnum_loop; } else { if (NIL_P(end)) goto bignum_endless; 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; ; F; ;,;;;I"Range#step;F;[[@0;[[@i;T;;;0;[;{;IC;"Iterates over the range, passing each nth element to the block. If begin and end are numeric, +n+ is added for each iteration. Otherwise step invokes succ to iterate through range elements. If no block is given, an enumerator is returned instead. Especially, the enumerator is an Enumerator::ArithmeticSequence if begin and end of the range are numeric. range = Xs.new(1)..Xs.new(10) range.step(2) {|x| puts x} puts range.step(3) {|x| puts x} produces: 1 x 3 xxx 5 xxxxx 7 xxxxxxx 9 xxxxxxxxx 1 x 4 xxxx 7 xxxxxxx 10 xxxxxxxxxx See Range for the definition of class Xs. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"step(n=1);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @ ;[;I"@yield [ obj ];T;0; @ ;@F;Mi;N0;[[I"n;TI"1;T; @ o;H ;II" overload;F;J0;;;K0;#I"step(n=1);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;TI"1;T; @ o;H ;II" overload;F;J0;;;K0;#I"step(n=1);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;TI"1;T; @ o;H ;II" overload;F;J0;;*;K0;#I" %(n);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;T0; @ o;H ;II" overload;F;J0;;*;K0;#I" %(n);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;T0; @ ;[;I"Iterates over the range, passing each nth element to the block. If begin and end are numeric, +n+ is added for each iteration. Otherwise step invokes succ to iterate through range elements. If no block is given, an enumerator is returned instead. Especially, the enumerator is an Enumerator::ArithmeticSequence if begin and end of the range are numeric. range = Xs.new(1)..Xs.new(10) range.step(2) {|x| puts x} puts range.step(3) {|x| puts x} produces: 1 x 3 xxx 5 xxxxx 7 xxxxxxx 9 xxxxxxxxx 1 x 4 xxxx 7 xxxxxxx 10 xxxxxxxxxx See Range for the definition of class Xs. @overload step(n=1) @yield [ obj ] @overload step(n=1) @overload step(n=1) @overload %(n) @overload %(n);T;0; @ ;@F;Ao;B;CT;Di];Ei;!@;"I" 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(b, rb_cNumeric) && (NIL_P(e) || rb_obj_is_kind_of(e, rb_cNumeric))) { 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); 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 */ VALUE iter[2]; iter[0] = INT2FIX(1); iter[1] = step; 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)) { VALUE iter[2]; b = tmp; iter[0] = INT2FIX(1); iter[1] = step; 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 { VALUE args[2]; if (!discrete_object_p(b)) { rb_raise(rb_eTypeError, "can't iterate from %s", rb_obj_classname(b)); } args[0] = INT2FIX(1); args[1] = step; range_each_func(range, step_i, (VALUE)args); } } return range; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Range#%;F;[[I" step;T0;[[@i;T;;*;0;[;{;IC;"Iterates over the range, passing each nth element to the block. If begin and end are numeric, +n+ is added for each iteration. Otherwise step invokes succ to iterate through range elements. If no block is given, an enumerator is returned instead. Especially, the enumerator is an Enumerator::ArithmeticSequence if begin and end of the range are numeric. range = Xs.new(1)..Xs.new(10) range.step(2) {|x| puts x} puts range.step(3) {|x| puts x} produces: 1 x 3 xxx 5 xxxxx 7 xxxxxxx 9 xxxxxxxxx 1 x 4 xxxx 7 xxxxxxx 10 xxxxxxxxxx See Range for the definition of class Xs. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"step(n=1);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @ ;[;I"@yield [ obj ];T;0; @ ;@F;Mi;N0;[[I"n;TI"1;T; @ o;H ;II" overload;F;J0;;;K0;#I"step(n=1);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;TI"1;T; @ o;H ;II" overload;F;J0;;;K0;#I"step(n=1);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;TI"1;T; @ o;H ;II" overload;F;J0;;*;K0;#I" %(n);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;T0; @ o;H ;II" overload;F;J0;;*;K0;#I" %(n);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"n;T0; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di];Ei;!@;"I"istatic VALUE range_percent_step(VALUE range, VALUE step) { return range_step(1, &step, range); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#bsearch;F;[;[[@i;T;;;0;[;{;IC;""By using binary search, finds a value in range which meets the given condition in O(log n) where n is the size of the range. You can use this method in two use cases: a find-minimum mode and a find-any mode. In either case, the elements of the range must be monotone (or sorted) with respect to the block. In find-minimum mode (this is a good choice for typical use case), the block must return true or false, and there must be a value x so that: - the block returns false for any value which is less than x, and - the block returns true for any value which is greater than or equal to x. If x is within the range, this method returns the value x. Otherwise, it returns nil. ary = [0, 4, 7, 10, 12] (0...ary.size).bsearch {|i| ary[i] >= 4 } #=> 1 (0...ary.size).bsearch {|i| ary[i] >= 6 } #=> 2 (0...ary.size).bsearch {|i| ary[i] >= 8 } #=> 3 (0...ary.size).bsearch {|i| ary[i] >= 100 } #=> nil (0.0...Float::INFINITY).bsearch {|x| Math.log(x) >= 0 } #=> 1.0 In find-any mode (this behaves like libc's bsearch(3)), the block must return a number, and there must be two values x and y (x <= y) so that: - the block returns a positive number for v if v < x, - the block returns zero for v if x <= v < y, and - the block returns a negative number for v if y <= v. This method returns any value which is within the intersection of the given range and x...y (if any). If there is no value that satisfies the condition, it returns nil. ary = [0, 100, 100, 100, 200] (0..4).bsearch {|i| 100 - ary[i] } #=> 1, 2 or 3 (0..4).bsearch {|i| 300 - ary[i] } #=> nil (0..4).bsearch {|i| 50 - ary[i] } #=> nil You must not mix the two modes at a time; the block must always return either true/false, or always return a number. It is undefined which value is actually picked up at each iteration. ;T;[o;H ;II" overload;F;J0;;;K0;#I" bsearch;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @M ;[;I"@yield [obj];T;0; @M ;@F;Mi;N0;[; @M ;[;I"EBy using binary search, finds a value in range which meets the given condition in O(log n) where n is the size of the range. You can use this method in two use cases: a find-minimum mode and a find-any mode. In either case, the elements of the range must be monotone (or sorted) with respect to the block. In find-minimum mode (this is a good choice for typical use case), the block must return true or false, and there must be a value x so that: - the block returns false for any value which is less than x, and - the block returns true for any value which is greater than or equal to x. If x is within the range, this method returns the value x. Otherwise, it returns nil. ary = [0, 4, 7, 10, 12] (0...ary.size).bsearch {|i| ary[i] >= 4 } #=> 1 (0...ary.size).bsearch {|i| ary[i] >= 6 } #=> 2 (0...ary.size).bsearch {|i| ary[i] >= 8 } #=> 3 (0...ary.size).bsearch {|i| ary[i] >= 100 } #=> nil (0.0...Float::INFINITY).bsearch {|x| Math.log(x) >= 0 } #=> 1.0 In find-any mode (this behaves like libc's bsearch(3)), the block must return a number, and there must be two values x and y (x <= y) so that: - the block returns a positive number for v if v < x, - the block returns zero for v if x <= v < y, and - the block returns a negative number for v if y <= v. This method returns any value which is within the intersection of the given range and x...y (if any). If there is no value that satisfies the condition, it returns nil. ary = [0, 100, 100, 100, 200] (0..4).bsearch {|i| 100 - ary[i] } #=> 1, 2 or 3 (0..4).bsearch {|i| 300 - ary[i] } #=> nil (0..4).bsearch {|i| 50 - ary[i] } #=> nil You must not mix the two modes at a time; the block must always return either true/false, or always return a number. It is undefined which value is actually picked up at each iteration. @overload bsearch @yield [obj];T;0; @M ;@F;Ao;B;CT;DiX;Ei;!@;"I"X 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_TYPE_P(beg, T_FLOAT) || RB_TYPE_P(end, T_FLOAT)) { int64_t low = double_as_int64(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 { rb_raise(rb_eTypeError, "can't do binary search for %s", rb_obj_classname(beg)); } return range; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#begin;F;[;[[@i;T;;D;0;[;{;IC;"[Returns the object that defines the beginning of the range. (1..10).begin #=> 1 ;T;[o;H ;II" overload;F;J0;;D;K0;#I" begin;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @h ;[;I"@return [Object];T;0; @h ;@F;Mi;N0;[; @h ;[;I"{Returns the object that defines the beginning of the range. (1..10).begin #=> 1 @overload begin @return [Object];T;0; @h ;@F;Ao;B;CT;Di;Ei;!@;"I"Kstatic VALUE range_begin(VALUE range) { return RANGE_BEG(range); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#end;F;[;[[@i;T;;E;0;[;{;IC;"mReturns the object that defines the end of the range. (1..10).end #=> 10 (1...10).end #=> 10 ;T;[o;H ;II" overload;F;J0;;E;K0;#I"end;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Returns the object that defines the end of the range. (1..10).end #=> 10 (1...10).end #=> 10 @overload end @return [Object];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"Istatic VALUE range_end(VALUE range) { return RANGE_END(range); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#first;F;[[@0;[[@i;T;;;0;[;{;IC;"Returns the first object in the range, or an array of the first +n+ elements. (10..20).first #=> 10 (10..20).first(3) #=> [10, 11, 12] ;T;[o;H ;II" overload;F;J0;;;K0;#I" first;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" first(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"n;T0; @ ;[;I"Returns the first object in the range, or an array of the first +n+ elements. (10..20).first #=> 10 (10..20).first(3) #=> [10, 11, 12] @overload first @return [Object] @overload first(n) @return [Array];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"2static VALUE range_first(int argc, VALUE *argv, VALUE range) { VALUE n, ary[2]; 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; ; F; ;,;;;I"Range#last;F;[[@0;[[@i;T;;;0;[;{;IC;"NReturns the last object in the range, or an array of the last +n+ elements. Note that with no arguments +last+ will return the object that defines the end of the range even if #exclude_end? is +true+. (10..20).last #=> 20 (10...20).last #=> 20 (10..20).last(3) #=> [18, 19, 20] (10...20).last(3) #=> [17, 18, 19] ;T;[o;H ;II" overload;F;J0;;;K0;#I" last;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" last(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"n;T0; @ ;[;I"Returns the last object in the range, or an array of the last +n+ elements. Note that with no arguments +last+ will return the object that defines the end of the range even if #exclude_end? is +true+. (10..20).last #=> 20 (10...20).last #=> 20 (10..20).last(3) #=> [18, 19, 20] (10...20).last(3) #=> [17, 18, 19] @overload last @return [Object] @overload last(n) @return [Array];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE range_last(int argc, VALUE *argv, VALUE range) { 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); return rb_ary_last(argc, argv, rb_Array(range)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#min;F;[[@0;[[@i;T;;;0;[;{;IC;"?Returns the minimum value in the range. Returns +nil+ if the begin value of the range is larger than the end value. Returns +nil+ if the begin value of an exclusive range is equal to the end value. Can be given an optional block to override the default comparison method a <=> b. (10..20).min #=> 10 ;T;[ o;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @ o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"$@yield [ a,b ] @return [Object];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" min(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"n;T0; @ o;H ;II" overload;F;J0;;;K0;#I" min(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @ o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"#@yield [ a,b ] @return [Array];T;0; @ ;@F;Mi;N0;[[I"n;T0; @ ;[;I"Returns the minimum value in the range. Returns +nil+ if the begin value of the range is larger than the end value. Returns +nil+ if the begin value of an exclusive range is equal to the end value. Can be given an optional block to override the default comparison method a <=> b. (10..20).min #=> 10 @overload min @return [Object] @overload min @yield [ a,b ] @return [Object] @overload min(n) @return [Array] @overload min(n) @yield [ a,b ] @return [Array];T;0; @ ;@F;Ao;B;CT;Di ;Ei ;!@;"I"]static VALUE range_min(int argc, VALUE *argv, VALUE 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; ; F; ;,;;;I"Range#max;F;[[@0;[[@iH;T;;;0;[;{;IC;"<Returns the maximum value in the range. Returns +nil+ if the begin value of the range larger than the end value. Returns +nil+ if the begin value of an exclusive range is equal to the end value. Can be given an optional block to override the default comparison method a <=> b. (10..20).max #=> 20 ;T;[ o;H ;II" overload;F;J0;;;K0;#I"max;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @G ;[;I"@return [Object];T;0; @G ;@F;Mi;N0;[; @G o;H ;II" overload;F;J0;;;K0;#I"max;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @G o;L ;II" return;F;JI";T;0;K[I" Object;T; @G ;[;I"$@yield [ a,b ] @return [Object];T;0; @G ;@F;Mi;N0;[; @G o;H ;II" overload;F;J0;;;K0;#I" max(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @G ;[;I"@return [Object];T;0; @G ;@F;Mi;N0;[[I"n;T0; @G o;H ;II" overload;F;J0;;;K0;#I" max(n);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"a;TI"b;T; @G o;L ;II" return;F;JI";T;0;K[I" Object;T; @G ;[;I"$@yield [ a,b ] @return [Object];T;0; @G ;@F;Mi;N0;[[I"n;T0; @G ;[;I"Returns the maximum value in the range. Returns +nil+ if the begin value of the range larger than the end value. Returns +nil+ if the begin value of an exclusive range is equal to the end value. Can be given an optional block to override the default comparison method a <=> b. (10..20).max #=> 20 @overload max @return [Object] @overload max @yield [ a,b ] @return [Object] @overload max(n) @return [Object] @overload max(n) @yield [ a,b ] @return [Object];T;0; @G ;@F;Ao;B;CT;Di7;EiJ;!@;"I"Nstatic 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"); } if (rb_block_given_p() || (EXCL(range) && !nm) || argc) { return rb_call_super(argc, argv); } else { struct cmp_opt_data cmp_opt = { 0, 0 }; VALUE b = RANGE_BEG(range); int c = 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; ; F; ;,;;;I"Range#size;F;[;[[@i;T;;;0;[;{;IC;"Returns the number of elements in the range. Both the begin and the end of the Range must be Numeric, otherwise nil is returned. (10..20).size #=> 11 ('a'..'z').size #=> nil (-Float::INFINITY..Float::INFINITY).size #=> Infinity ;T;[o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @ ;[;I"@return [Numeric];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Returns the number of elements in the range. Both the begin and the end of the Range must be Numeric, otherwise nil is returned. (10..20).size #=> 11 ('a'..'z').size #=> nil (-Float::INFINITY..Float::INFINITY).size #=> Infinity @overload size @return [Numeric];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"nstatic 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); } } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#to_a;F;[;[[@i;T;;;0;[;{;IC;"Returns an array containing the items in the range. (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7] (1..).to_a #=> RangeError: cannot convert endless range to an array ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" entries;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Returns an array containing the items in the range. (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7] (1..).to_a #=> RangeError: cannot convert endless range to an array @overload to_a @return [Array] @overload entries @return [Array];T;0; @ ;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"Range#entries;F;[;[[@i;T;;;0;[;{;IC;"Returns an array containing the items in the range. (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7] (1..).to_a #=> RangeError: cannot convert endless range to an array ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I" entries;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"Range#to_s;F;[;[[@i;T;;h;0;[;{;IC;"fConvert this range object to a printable form (using #to_s to convert the begin and end objects). ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Convert this range object to a printable form (using #to_s to convert the begin and end objects). @overload to_s @return [String];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"2static 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); OBJ_INFECT(str, range); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#inspect;F;[;[[@i;T;;i;0;[;{;IC;"uConvert this range object to a printable form (using inspect to convert the begin and end objects). ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Convert this range object to a printable form (using inspect to convert the begin and end objects). @overload inspect @return [String];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"gstatic VALUE range_inspect(VALUE range) { return rb_exec_recursive(inspect_range, range, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#exclude_end?;F;[;[[@iq;T;:exclude_end?;0;[;{;IC;"Returns true if the range excludes its end value. (1..5).exclude_end? #=> false (1...5).exclude_end? #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I"exclude_end?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @: ;[;I"@return [Boolean];T;0; @: ;@F;Mi;N0;[; @: ;[;I"Returns true if the range excludes its end value. (1..5).exclude_end? #=> false (1...5).exclude_end? #=> true @overload exclude_end? @return [Boolean];T;0; @: ;@F;Ao;B;CT;Dig;Ein;Mi;!@;"I"_static VALUE range_exclude_end_p(VALUE range) { return EXCL(range) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#member?;F;[[I"val;T0;[[@i;T;;;0;[;{;IC;"0Returns true if +obj+ is an element of the range, false otherwise. If begin and end are numeric, comparison is done according to the magnitude of the values. ("a".."z").include?("g") #=> true ("a".."z").include?("A") #=> false ("a".."z").include?("cc") #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I"member?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @U ;[;I"@return [Boolean];T;0; @U ;@F;Mi;N0;[[I"obj;T0; @U o;H ;II" overload;F;J0;;U;K0;#I"include?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @U ;[;I"@return [Boolean];T;0; @U ;@F;Mi;N0;[[I"obj;T0; @U ;[;I"Returns true if +obj+ is an element of the range, false otherwise. If begin and end are numeric, comparison is done according to the magnitude of the values. ("a".."z").include?("g") #=> true ("a".."z").include?("A") #=> false ("a".."z").include?("cc") #=> false @overload member?(obj) @return [Boolean] @overload include?(obj) @return [Boolean];T;0; @U ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE range_include(VALUE range, VALUE val) { VALUE ret = range_include_internal(range, val); if (ret != Qundef) return ret; return rb_call_super(1, &val); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#include?;F;[[I"val;T0;[[@i;T;;U;0;[;{;IC;"0Returns true if +obj+ is an element of the range, false otherwise. If begin and end are numeric, comparison is done according to the magnitude of the values. ("a".."z").include?("g") #=> true ("a".."z").include?("A") #=> false ("a".."z").include?("cc") #=> false;T;[o;H ;II" overload;F;J0;;;K0;#I"member?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ o;H ;II" overload;F;J0;;U;K0;#I"include?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE range_include(VALUE range, VALUE val) { VALUE ret = range_include_internal(range, val); if (ret != Qundef) return ret; return rb_call_super(1, &val); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Range#cover?;F;[[I"val;T0;[[@i`;T;: cover?;0;[;{;IC;"Returns true if +obj+ is between the begin and end of the range. This tests begin <= obj <= end when #exclude_end? is +false+ and begin <= obj < end when #exclude_end? is +true+. If called with a Range argument, returns true when the given range is covered by the receiver, by comparing the begin and end values. If the argument can be treated as a sequence, this method treats it that way. In the specific case of (a..b).cover?(c...d) with a <= c && b < d, the end of the sequence must be calculated, which may exhibit poor performance if c is non-numeric. Returns false if the begin value of the range is larger than the end value. ("a".."z").cover?("c") #=> true ("a".."z").cover?("5") #=> false ("a".."z").cover?("cc") #=> true (1..5).cover?(2..3) #=> true (1..5).cover?(0..6) #=> false (1..5).cover?(1...6) #=> true;T;[o;H ;II" overload;F;J0;;;K0;#I"cover?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"obj;T0; @ o;H ;II" overload;F;J0;;;K0;#I"cover?(range);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" range;T0; @ ;[;I"Returns true if +obj+ is between the begin and end of the range. This tests begin <= obj <= end when #exclude_end? is +false+ and begin <= obj < end when #exclude_end? is +true+. If called with a Range argument, returns true when the given range is covered by the receiver, by comparing the begin and end values. If the argument can be treated as a sequence, this method treats it that way. In the specific case of (a..b).cover?(c...d) with a <= c && b < d, the end of the sequence must be calculated, which may exhibit poor performance if c is non-numeric. Returns false if the begin value of the range is larger than the end value. ("a".."z").cover?("c") #=> true ("a".."z").cover?("5") #=> false ("a".."z").cover?("cc") #=> true (1..5).cover?(2..3) #=> true (1..5).cover?(0..6) #=> false (1..5).cover?(1...6) #=> true @overload cover?(obj) @return [Boolean] @overload cover?(range) @return [Boolean];T;0; @ ;@F;Ao;B;CT;DiC;Ei^;Mi;!@;"I"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;$T;&@;'IC;[;&@;(IC;[o;2 ;30;40;50;;1;!@;7@C;F0;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i$;F;;B;;0;;;[;{;IC;"+ A Range represents an interval---a set of values with a beginning and an end. Ranges may be constructed using the s..e and s...e literals, or with Range::new. Ranges constructed using .. run from the beginning to the end inclusively. Those created using ... exclude the end value. When used as an iterator, ranges return each value in the sequence. (-1..-5).to_a #=> [] (-5..-1).to_a #=> [-5, -4, -3, -2, -1] ('a'..'e').to_a #=> ["a", "b", "c", "d", "e"] ('a'...'e').to_a #=> ["a", "b", "c", "d"] == Endless Ranges An "endless range" represents a semi-infinite range. Literal notation for an endless range is: (1..) # or similarly (1...) Which is equivalent to (1..nil) # or similarly (1...nil) Range.new(1, nil) # or Range.new(1, nil, true) Endless ranges are useful, for example, for idiomatic slicing of arrays: [1, 2, 3, 4, 5][2...] # => [3, 4, 5] Some implementation details: * +end+ of endless range is +nil+; * +each+ of endless range enumerates infinite sequence (may be useful in combination with Enumerable#take_while or similar methods); * (1..) and (1...) are not equal, although technically representing the same sequence. == Custom Objects in Ranges Ranges can be constructed using any objects that can be compared using the <=> operator. Methods that treat the range as a sequence (#each and methods inherited from Enumerable) expect the begin object to implement a succ method to return the next object in sequence. The #step and #include? methods require the begin object to implement succ or to be numeric. In the Xs class below both <=> and succ are implemented so Xs can be used to construct ranges. Note that the Comparable module is included so the == method is defined in terms of <=>. class Xs # represent a string of 'x's include Comparable attr :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 An example of using Xs to construct a range: r = Xs.new(3)..Xs.new(6) #=> xxx..xxxxxx r.to_a #=> [xxx, xxxx, xxxxx, xxxxxx] r.member?(Xs.new(5)) #=> true ;T;[;[;I"- A Range represents an interval---a set of values with a beginning and an end. Ranges may be constructed using the s..e and s...e literals, or with Range::new. Ranges constructed using .. run from the beginning to the end inclusively. Those created using ... exclude the end value. When used as an iterator, ranges return each value in the sequence. (-1..-5).to_a #=> [] (-5..-1).to_a #=> [-5, -4, -3, -2, -1] ('a'..'e').to_a #=> ["a", "b", "c", "d", "e"] ('a'...'e').to_a #=> ["a", "b", "c", "d"] == Endless Ranges An "endless range" represents a semi-infinite range. Literal notation for an endless range is: (1..) # or similarly (1...) Which is equivalent to (1..nil) # or similarly (1...nil) Range.new(1, nil) # or Range.new(1, nil, true) Endless ranges are useful, for example, for idiomatic slicing of arrays: [1, 2, 3, 4, 5][2...] # => [3, 4, 5] Some implementation details: * +end+ of endless range is +nil+; * +each+ of endless range enumerates infinite sequence (may be useful in combination with Enumerable#take_while or similar methods); * (1..) and (1...) are not equal, although technically representing the same sequence. == Custom Objects in Ranges Ranges can be constructed using any objects that can be compared using the <=> operator. Methods that treat the range as a sequence (#each and methods inherited from Enumerable) expect the begin object to implement a succ method to return the next object in sequence. The #step and #include? methods require the begin object to implement succ or to be numeric. In the Xs class below both <=> and succ are implemented so Xs can be used to construct ranges. Note that the Comparable module is included so the == method is defined in terms of <=>. class Xs # represent a string of 'x's include Comparable attr :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 An example of using Xs to construct a range: r = Xs.new(3)..Xs.new(6) #=> xxx..xxxxxx r.to_a #=> [xxx, xxxx, xxxxx, xxxxxx] r.member?(Xs.new(5)) #=> true ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I" Range;F;1@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; ; F; ;,;;;I"Method#eql?;F;[[I" other;T0;[[@i;T;;R;0;[;{;IC;"Two method objects are equal if they are bound to the same object and refer to the same method definition and their owners are the same class or module.;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other_meth);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"other_meth;T0; @ o;H ;II" overload;F;J0;;S;K0;#I"==(other_meth);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I"other_meth;T0; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di;Ei;Mi;!@ ;"I"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; ; F; ;,;;;I"Method#hash;F;[;[[@i;T;;U;0;[;{;IC;"TReturns a hash value corresponding to the method object. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @M ;[;I"@return [Integer];T;0; @M ;@F;Mi;N0;[; @M ;[;I"yReturns a hash value corresponding to the method object. See also Object#hash. @overload hash @return [Integer];T;0; @M ;@F;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;,;;;I"Method#clone;F;[;[[@i;T;;X;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;H ;II" overload;F;J0;;X;K0;#I" clone;T;IC;";T;[;[;I";T;0; @h ;@F;Mi;N0;[; @h ;[;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; @h ;@F;Ao;B;CT;Di;Ei;!@ ;"I"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->me, rb_method_entry_clone(orig->me)); return clone; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#call;F;[[@0;[[@iD;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;H ;II" overload;F;J0;;;K0;#I"call(args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @~ ;[;I"@return [Object];T;0; @~ ;@F;Mi;N0;[[I" args;T0[I"...;T0; @~ o;H ;II" overload;F;J0;;;K0;#I"[](args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @~ ;[;I"@return [Object];T;0; @~ ;@F;Mi;N0;[[I" args;T0[I"...;T0; @~ ;[;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] @overload [](args, ...) @return [Object];T;0; @~ ;@F;Ao;B;CT;Di7;EiB;!@ ;"I"VALUE rb_method_call(int argc, const VALUE *argv, VALUE method) { VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil; return rb_method_call_with_block(argc, argv, method, procval); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Method#===;F;[[@0;[[@iD;T;;O;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;H ;II" overload;F;J0;;;K0;#I"call(args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I" args;T0[I"...;T0; @ o;H ;II" overload;F;J0;;;K0;#I"[](args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[I" args;T0[I"...;T0; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di7;EiB;!@ ;"I"VALUE rb_method_call(int argc, const VALUE *argv, VALUE method) { VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil; return rb_method_call_with_block(argc, argv, method, procval); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Method#curry;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I" curry;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @ ;[;I"@return [Proc];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;;K0;#I"curry(arity);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @ ;[;I"@return [Proc];T;0; @ ;@F;Mi;N0;[[I" arity;T0; @ ;[;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; @ ;@F;Ao;B;CT;Di ;Ei ;!@ ;"I"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; ; F; ;,;;;I"Method#<<;F;[[I"g;T0;[[@iL ;T;;Q;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;H ;II" overload;F;J0;;Q;K0;#I" <<(g);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @ ;[;I"@return [Proc];T;0; @ ;@F;Mi;N0;[[I"g;T0; @ ;[;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; @ ;@F;Ao;B;CT;Di< ;EiJ ;!@ ;"I"static VALUE rb_method_compose_to_left(VALUE self, VALUE g) { VALUE proc = method_to_proc(self); return proc_compose_to_left(proc, g); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#>>;F;[[I"g;T0;[[@ic ;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 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) #=> 8 ;T;[o;H ;II" overload;F;J0;;;K0;#I" >>(g);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @);[;I"@return [Proc];T;0; @);@F;Mi;N0;[[I"g;T0; @);[;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 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) #=> 8 @overload >>(g) @return [Proc];T;0; @);@F;Ao;B;CT;DiS ;Eia ;!@ ;"I"static VALUE rb_method_compose_to_right(VALUE self, VALUE g) { VALUE proc = method_to_proc(self); return proc_compose_to_right(proc, g); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#[];F;[[@0;[[@iD;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;H ;II" overload;F;J0;;;K0;#I"call(args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @H;[;I"@return [Object];T;0; @H;@F;Mi;N0;[[I" args;T0[I"...;T0; @Ho;H ;II" overload;F;J0;;;K0;#I"[](args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @H;[;I"@return [Object];T;0; @H;@F;Mi;N0;[[I" args;T0[I"...;T0; @H;[;@ ;0; @H;@F;Ao;B;CT;Di7;EiB;!@ ;"I"VALUE rb_method_call(int argc, const VALUE *argv, VALUE method) { VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil; return rb_method_call_with_block(argc, argv, method, procval); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Method#arity;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" arity;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @x;[;I"@return [Integer];T;0; @x;@F;Mi;N0;[; @x;[;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; @x;@F;Ao;B;CT;DiQ ;Eiy ;!@ ;"I"kstatic VALUE method_arity_m(VALUE method) { int n = method_arity(method); return INT2FIX(n); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#inspect;F;[;[[@iA ;T;;i;0;[;{;IC;"UReturns 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+). ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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+). @overload to_s @return [String] @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di3 ;Ei? ;!@ ;"I"static 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)); OBJ_INFECT_RAW(str, method); mklass = data->klass; 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 { 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)"); } rb_str_buf_cat2(str, ">"); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#to_s;F;[;[[@iA ;T;;h;0;[;{;IC;"UReturns 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+). ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di3 ;Ei? ;!@ ;"I"static 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)); OBJ_INFECT_RAW(str, method); mklass = data->klass; 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 { 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)"); } rb_str_buf_cat2(str, ">"); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#to_proc;F;[;[[@i ;T;;;0;[;{;IC;"EReturns a Proc object corresponding to this method. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_proc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @;[;I"@return [Proc];T;0; @;@F;Mi;N0;[; @;[;I"jReturns a Proc object corresponding to this method. @overload to_proc @return [Proc];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@ ;"I"rstatic 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_iterate(mlambda, 0, bmcall, method); GetProcPtr(procval, proc); proc->is_from_method = 1; return procval; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#receiver;F;[;[[@i4;T;: receiver;0;[;{;IC;"_Returns the bound receiver of the method object. (1..3).method(:map).receiver # => 1..3 ;T;[o;H ;II" overload;F;J0;;;K0;#I" receiver;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"Returns the bound receiver of the method object. (1..3).method(:map).receiver # => 1..3 @overload receiver @return [Object];T;0; @;@F;Ao;B;CT;Di+;Ei1;!@ ;"I"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; ; F; ;,;;;I"Method#name;F;[;[[@iD;T;;>;0;[;{;IC;"$Returns the name of the method. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"5Returns the name of the method. @overload name;T;0; @;@F;Ao;B;CT;Di=;Ei@;!@ ;"I"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; ; F; ;,;;;I"Method#original_name;F;[;[[@iZ;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;H ;II" overload;F;J0;;;K0;#I"original_name;T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[; @.;[;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; @.;@F;Ao;B;CT;DiM;EiV;!@ ;"I"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; ; F; ;,;;;I"Method#owner;F;[;[[@im;T;: owner;0;[;{;IC;"xReturns the class or module that defines the method. See also receiver. (1..3).method(:map).owner #=> Enumerable ;T;[o;H ;II" overload;F;J0;;;K0;#I" owner;T;IC;";T;[;[;I";T;0; @D;@F;Mi;N0;[; @D;[;I"Returns the class or module that defines the method. See also receiver. (1..3).method(:map).owner #=> Enumerable @overload owner;T;0; @D;@F;Ao;B;CT;Dic;Eii;!@ ;"I"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; ; F; ;,;;;I"Method#unbind;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" unbind;T;IC;";T;[;[;I";T;0; @Z;@F;Mi;N0;[; @Z;[;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; @Z;@F;Ao;B;CT;Di;Ei;!@ ;"I"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->me, rb_method_entry_clone(orig->me)); OBJ_INFECT(method, obj); return method; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#source_location;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"source_location;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I" Array;TI" Integer;T; @p;[;I"@return [Array, Integer]];T;0; @p;@F;Mi;N0;[; @p;[;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; @p;@F;Ao;B;CT;Di ;Ei ;!@ ;"I"fVALUE rb_method_location(VALUE method) { return method_def_location(rb_method_def(method)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Method#parameters;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"parameters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di ;Ei& ;!@ ;"I"static VALUE rb_method_parameters(VALUE method) { const rb_iseq_t *iseq = rb_method_iseq(method); if (!iseq) { return rb_unnamed_parameters(method_arity(method)); } return rb_iseq_parameters(iseq, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Method#super_method;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"super_method;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@ ;"I"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; super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass)); mid = data->me->called_id; if (!super_class) return Qnil; me = (rb_method_entry_t *)rb_callable_method_entry_without_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;$T;&@ ;'IC;[;&@ ;(IC;[;&@ ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;;i;;0;;;[;{;IC;"z******************************************************************** 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"{******************************************************************** 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; @ ;@F;Ao;B;CT;Di;Ei;Mi;!@;I" Method;F;1@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; ; F; ;,;;;I"UnboundMethod#eql?;F;[[I" other;T0;[[@i;T;;R;0;[;{;IC;"Two method objects are equal if they are bound to the same object and refer to the same method definition and their owners are the same class or module.;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other_meth);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"other_meth;T0; @o;H ;II" overload;F;J0;;S;K0;#I"==(other_meth);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"other_meth;T0; @;[;@ ;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"UnboundMethod#hash;F;[;[[@i;T;;U;0;[;{;IC;"TReturns a hash value corresponding to the method object. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @+;[;I"@return [Integer];T;0; @+;@F;Mi;N0;[; @+;[;@d ;0; @+;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"UnboundMethod#clone;F;[;[[@i;T;;X;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;H ;II" overload;F;J0;;X;K0;#I" clone;T;IC;";T;[;[;I";T;0; @E;@F;Mi;N0;[; @E;[;@z ;0; @E;@F;Ao;B;CT;Di;Ei;!@;"I"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->me, rb_method_entry_clone(orig->me)); return clone; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UnboundMethod#arity;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" arity;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Z;[;I"@return [Integer];T;0; @Z;@F;Mi;N0;[; @Z;[;@;0; @Z;@F;Ao;B;CT;DiQ ;Eiy ;!@;"I"kstatic VALUE method_arity_m(VALUE method) { int n = method_arity(method); return INT2FIX(n); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UnboundMethod#inspect;F;[;[[@iA ;T;;i;0;[;{;IC;"UReturns 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+). ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @t;[;I"@return [String];T;0; @t;@F;Mi;N0;[; @to;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @t;[;I"@return [String];T;0; @t;@F;Mi;N0;[; @t;[;@;0; @t;@F;Ao;B;CT;Di3 ;Ei? ;!@;"I"static 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)); OBJ_INFECT_RAW(str, method); mklass = data->klass; 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 { 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)"); } rb_str_buf_cat2(str, ">"); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UnboundMethod#to_s;F;[;[[@iA ;T;;h;0;[;{;IC;"UReturns 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+). ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di3 ;Ei? ;!@;"I"static 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)); OBJ_INFECT_RAW(str, method); mklass = data->klass; 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 { 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)"); } rb_str_buf_cat2(str, ">"); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UnboundMethod#name;F;[;[[@iD;T;;>;0;[;{;IC;"$Returns the name of the method. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;@*;0; @;@F;Ao;B;CT;Di=;Ei@;!@;"I"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; ; F; ;,;;;I" UnboundMethod#original_name;F;[;[[@iZ;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;H ;II" overload;F;J0;;;K0;#I"original_name;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;@@;0; @;@F;Ao;B;CT;DiM;EiV;!@;"I"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; ; F; ;,;;;I"UnboundMethod#owner;F;[;[[@im;T;;;0;[;{;IC;"xReturns the class or module that defines the method. See also receiver. (1..3).method(:map).owner #=> Enumerable ;T;[o;H ;II" overload;F;J0;;;K0;#I" owner;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;@V;0; @;@F;Ao;B;CT;Dic;Eii;!@;"I"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; ; F; ;,;;;I"UnboundMethod#bind;F;[[I" recv;T0;[[@i;T;: bind;0;[;{;IC;"FBind 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;H ;II" overload;F;J0;;;K0;#I"bind(obj);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I"\Bind 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; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE umethod_bind(VALUE method, VALUE recv) { struct METHOD *data, *bound; VALUE methclass, klass; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); methclass = data->me->owner; if (!RB_TYPE_P(methclass, T_MODULE) && methclass != CLASS_OF(recv) && !rb_obj_is_kind_of(recv, methclass)) { if (FL_TEST(methclass, FL_SINGLETON)) { rb_raise(rb_eTypeError, "singleton method called for a different object"); } else { rb_raise(rb_eTypeError, "bind argument must be an instance of % "PRIsVALUE, methclass); } } klass = CLASS_OF(recv); 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, data->klass); RB_OBJ_WRITE(method, &bound->me, rb_method_entry_clone(data->me)); if (RB_TYPE_P(bound->me->owner, T_MODULE)) { VALUE ic = rb_class_search_ancestor(klass, bound->me->owner); if (ic) { klass = ic; } else { klass = rb_include_class_new(methclass, klass); } RB_OBJ_WRITE(method, &bound->me, rb_method_entry_complement_defined_class(bound->me, bound->me->called_id, klass)); } return method; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""UnboundMethod#source_location;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"source_location;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I" Array;TI" Integer;T; @;[;I"@return [Array, Integer]];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"fVALUE rb_method_location(VALUE method) { return method_def_location(rb_method_def(method)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"UnboundMethod#parameters;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"parameters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @6;[;I"@return [Array];T;0; @6;@F;Mi;N0;[; @6;[;@;0; @6;@F;Ao;B;CT;Di ;Ei& ;!@;"I"static VALUE rb_method_parameters(VALUE method) { const rb_iseq_t *iseq = rb_method_iseq(method); if (!iseq) { return rb_unnamed_parameters(method_arity(method)); } return rb_iseq_parameters(iseq, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UnboundMethod#super_method;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"super_method;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @P;[;@;0; @P;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass)); mid = data->me->called_id; if (!super_class) return Qnil; me = (rb_method_entry_t *)rb_callable_method_entry_without_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;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:UnboundMethod;;0;;;[;{;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;I"UnboundMethod;F;1@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; @w;@F;Ao;B;CT;Dij ;Ei ;Mi;!@;I"LocalJumpError;F;1o;2 ;30;40;50;;;!@;7@7;F;o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@iy ;T;:SystemStackError;;0;;;[;{;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; @;@F;Ao;B;CT;Di ;Ei ;!@;I"SystemStackError;F;1o;2 ;30;40;50;;#;!@;7@K;F;o; ;IC;[o; ; F; ;;;;I" Proc.new;F;[[@0;[[@i;T;; ;0;[;{;IC;"PCreates a new Proc object, bound to the current context. Proc::new may be called without a block only within a method with an attached block, in which case that block is converted to the Proc object. def proc_from Proc.new end proc = proc_from { "hello" } proc.call #=> "hello" ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"...;T; @o;L ;II" return;F;JI";T;0;K[I" Proc;T; @;[;I" @yield [...] @return [Proc];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @;[;I"@return [Proc];T;0; @;@F;Mi;N0;[; @;[;I"Creates a new Proc object, bound to the current context. Proc::new may be called without a block only within a method with an attached block, in which case that block is converted to the Proc object. def proc_from Proc.new end proc = proc_from { "hello" } proc.call #=> "hello" @overload new @yield [...] @return [Proc] @overload new @return [Proc];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_proc_s_new(int argc, VALUE *argv, VALUE klass) { VALUE block = proc_new(klass, FALSE); rb_obj_call_init(block, argc, argv); return block; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Proc#call;F;[[@0;[[@iV;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; @;@F;Ao;B;CT;Di/;EiP;!@;"I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Proc#[];F;[[@0;[[@iV;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;[;[;@ ;0; @;@F;Ao;B;CT;Di/;EiP;!@;"I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Proc#===;F;[[@0;[[@iV;T;;O;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; @;@F;Ao;B;CT;Di#;Ei*;!@;"I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Proc#yield;F;[[@0;[[@iV;T;: yield;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;[;[;@ ;0; @.;@F;Ao;B;CT;Di/;EiP;!@;"I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Proc#to_proc;F;[;[[@i;T;;;0;[;{;IC;"Part of the protocol for converting objects to Proc objects. Instances of class Proc simply return themselves. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_proc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @<;[;I"@return [Proc];T;0; @<;@F;Mi;N0;[; @<;[;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; @<;@F;Ao;B;CT;Di;Ei;!@;"I"?static VALUE proc_to_proc(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Proc#arity;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" arity;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @W;[;I"@return [Integer];T;0; @W;@F;Mi;N0;[; @W;[;I"8Returns 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; @W;@F;Ao;B;CT;Di;Ei;!@;"I"lstatic VALUE proc_arity(VALUE self) { int arity = rb_proc_arity(self); return INT2FIX(arity); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Proc#clone;F;[;[[@i;T;;X;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @r;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE proc_clone(VALUE self) { VALUE procval = rb_proc_dup(self); CLONESETUP(procval, self); return procval; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Proc#dup;F;[;[[@i;T;;Y;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I" VALUE 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); RB_GC_GUARD(self); /* for: body = rb_proc_dup(body) */ return procval; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Proc#hash;F;[;[[@i;T;;U;0;[;{;IC;"LReturns a hash value corresponding to proc body. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"qReturns a hash value corresponding to proc body. See also Object#hash. @overload hash @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Proc#to_s;F;[;[[@i ;T;;h;0;[;{;IC;"iReturns the unique identifier for this proc, along with an indication of where the proc was defined. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; ; F; ;,;;;I"Proc#inspect;F;[;[[@ik ;F;;i;;0;[;{;@;!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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;#@;$T@o; ; F; ;,;;;I"Proc#lambda?;F;[;[[@i;T;: lambda?;0;[;{;IC;"J Returns +true+ for a Proc object for which argument handling is rigid. Such procs are typically generated by +lambda+. 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;H ;II" overload;F;J0;;;K0;#I" lambda?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"s Returns +true+ for a Proc object for which argument handling is rigid. Such procs are typically generated by +lambda+. 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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"VALUE rb_proc_lambda_p(VALUE procval) { rb_proc_t *proc; GetProcPtr(procval, proc); return proc->is_lambda ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Proc#binding;F;[;[[@i ;T;;;0;[;{;IC;"Returns the binding associated with prc. def fred(param) proc {} end b = fred(99) eval("param", b.binding) #=> 99 ;T;[o;H ;II" overload;F;J0;;;K0;#I" binding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Binding;T; @;[;I"@return [Binding];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; 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_symbol: goto error; 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; } else { error: rb_raise(rb_eArgError, "Can't create Binding from C level Proc"); 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; ; F; ;,;;;I"Proc#curry;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I" curry;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @;[;I"@return [Proc];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"curry(arity);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @;[;I"@return [Proc];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I" Proc#<<;F;[[I"g;T0;[[@i ;T;;Q;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 ;T;[o;H ;II" overload;F;J0;;Q;K0;#I" <<(g);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @+;[;I"@return [Proc];T;0; @+;@F;Mi;N0;[[I"g;T0; @+;[;I"5Returns 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 @overload <<(g) @return [Proc];T;0; @+;@F;Ao;B;CT;Di ;Ei ;!@;"I"static VALUE proc_compose_to_left(VALUE self, VALUE g) { VALUE proc, args, procs[2]; rb_proc_t *procp; int is_lambda; procs[0] = self; procs[1] = g; args = rb_ary_tmp_new_from_values(0, 2, procs); GetProcPtr(self, procp); is_lambda = procp->is_lambda; proc = rb_proc_new(compose, args); GetProcPtr(proc, procp); procp->is_lambda = is_lambda; return proc; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Proc#>>;F;[[I"g;T0;[[@i' ;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) #=> 8 ;T;[o;H ;II" overload;F;J0;;;K0;#I" >>(g);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @J;[;I"@return [Proc];T;0; @J;@F;Mi;N0;[[I"g;T0; @J;[;I"4Returns 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) #=> 8 @overload >>(g) @return [Proc];T;0; @J;@F;Ao;B;CT;Di ;Ei% ;!@;"I"static VALUE proc_compose_to_right(VALUE self, VALUE g) { VALUE proc, args, procs[2]; rb_proc_t *procp; int is_lambda; procs[0] = g; procs[1] = self; args = rb_ary_tmp_new_from_values(0, 2, procs); GetProcPtr(self, procp); is_lambda = procp->is_lambda; proc = rb_proc_new(compose, args); GetProcPtr(proc, procp); procp->is_lambda = is_lambda; return proc; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Proc#source_location;F;[;[[@iy;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;H ;II" overload;F;J0;;;K0;#I"source_location;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I" Array;TI" Integer;T; @i;[;I"@return [Array, Integer]];T;0; @i;@F;Mi;N0;[; @i;[;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; @i;@F;Ao;B;CT;Diq;Eiv;!@;"I"`VALUE rb_proc_location(VALUE self) { return iseq_location(rb_proc_get_iseq(self, 0)); };T;#I" VALUE;T;$To; ; F; ;,;;;I"Proc#parameters;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"parameters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@;h;.[;[[@i [@iQ ;T;;;;0;;;[;{;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 literal 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+ means exit from this lambda; * In regular procs, +return+ means exit from embracing method (and will throw +LocalJumpError+ if invoked outside the method); * 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: 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, 2] [[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 con be consumed by iterators. class Greater def initialize(greating) @greating = greating end def to_proc proc {|name| "#{@greating}, #{name}!" } end end hi = Greater.new("Hi") hey = Greater.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];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 literal 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+ means exit from this lambda; * In regular procs, +return+ means exit from embracing method (and will throw +LocalJumpError+ if invoked outside the method); * 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: 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, 2] [[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 con be consumed by iterators. class Greater def initialize(greating) @greating = greating end def to_proc proc {|name| "#{@greating}, #{name}!" } end end hi = Greater.new("Hi") hey = Greater.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] ;T;0; @;@F;Ao;B;CT;Di ;EiG ;Mi;!@;I" Proc;F;1@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; ; F; ;,;;;I"Binding#eval;F;[[@0;[[@ii;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;H ;II" overload;F;J0;;;K0;#I"(eval(string [, filename [,lineno]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiY;Eif;!@;"I"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; ; F; ;,;;;I"Binding#local_variables;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I"local_variables;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Binding#local_variable_get;F;[[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;H ;II" overload;F;J0;;;K0;#I"local_variable_get(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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) { sym = ID2SYM(lid); undefined: rb_name_err_raise("local variable `%1$s' is not defined for %2$s", bindval, sym); } return *ptr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Binding#local_variable_set;F;[[I"sym;T0[I"val;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"$local_variable_set(symbol, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @(;[;I"@return [Object];T;0; @(;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"Hstatic 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)); } RB_OBJ_WRITE(env, ptr, val); return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"$Binding#local_variable_defined?;F;[[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;H ;II" overload;F;J0;;;K0;#I"$local_variable_defined?(symbol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @K;[;I"@return [Object];T;0; @K;@F;Mi;N0;[[I" symbol;T0; @K;[;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; @K;@F;Ao;B;CT;Di);Ei8;Mi;!@;"I"cstatic 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 get_local_variable_ptr(&env, lid) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Binding#receiver;F;[;[[@iN;T;;;0;[;{;IC;"6Returns the bound receiver of the binding object. ;T;[o;H ;II" overload;F;J0;;;K0;#I" receiver;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @j;[;I"@return [Object];T;0; @j;@F;Mi;N0;[; @j;[;I"^Returns the bound receiver of the binding object. @overload receiver @return [Object];T;0; @j;@F;Ao;B;CT;DiH;EiL;!@;"I"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; ; F; ;,;;;I"Binding#source_location;F;[;[[@i\;T;;;0;[;{;IC;"LReturns the Ruby source filename and line number of the binding object. ;T;[o;H ;II" overload;F;J0;;;K0;#I"source_location;T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I" Array;TI" Integer;T; @;[;I"@return [Array, Integer]];T;0; @;@F;Mi;N0;[; @;[;I"Returns the Ruby source filename and line number of the binding object. @overload source_location @return [Array, Integer]];T;0; @;@F;Ao;B;CT;DiV;EiZ;!@;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i ;F;: Binding;;0;;;[;{;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. 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. 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; @;@F;Ao;B;CT;Di ;Ei ;!@;I" Binding;F;1@<@o; ;IC;[ o; ; F; ;,;;;I""UncaughtThrowError#initialize;F;[[@0;[[@&i;T;;;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"UncaughtThrowError#tag;F;[;[[@&i;T;:tag;0;[;{;IC;"0Return the tag object which was called for. ;T;[o;H ;II" overload;F;J0;;;K0;#I"tag;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"SReturn the tag object which was called for. @overload tag @return [Object];T;0; @;@F;Ao;B;CT;Di ;Ei;!@;"I"Xstatic VALUE uncaught_throw_tag(VALUE exc) { return rb_ivar_get(exc, id_tag); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UncaughtThrowError#value;F;[;[[@&i;T;;/;0;[;{;IC;"2Return the return value which was called for. ;T;[o;H ;II" overload;F;J0;;/;K0;#I" value;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"WReturn the return value which was called for. @overload value @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"\static VALUE uncaught_throw_value(VALUE exc) { return rb_ivar_get(exc, id_value); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UncaughtThrowError#to_s;F;[;[[@&i,;T;;h;0;[;{;IC;"6Returns formatted message with the inspected tag. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"ZReturns formatted message with the inspected tag. @overload to_s @return [String];T;0; @;@F;Ao;B;CT;Di%;Ei);!@;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@&i[@&i;T;:UncaughtThrowError;;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;[;[;@;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;I"UncaughtThrowError;F;1o;2 ;30;40;50;:ArgumentError;!@;7o; ;IC;[;&@&;'IC;[;&@&;(IC;[;&@&;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iF[@i ;T;;;;0;;;[;{;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;Ao;B;CT;DiF;EiY;!@;I"ArgumentError;F;1@7;F;o; ;IC;[o; ;IC;[ o; ; F; ;,;;;I"!Enumerator::Chain#initialize;F;[[I" enums;T0;[[@i ;T;;;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;H ;II" overload;F;J0;:Enumerator::Chain.new;K0;#I""Enumerator::Chain.new(*enums);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @>;[;I"@return [Enumerator];T;0; @>;@F;Mi;N0;[[I" *enums;T0; @>;[;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;Ao;B;CT;Di ;Ei ;!@<;"I"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; ; F; ;,;;;I"&Enumerator::Chain#initialize_copy;F;[[I" orig;T0;[[@i ;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @];@F;Ao;B;CT;Di ;Ei ;!@<;"I"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; ; F; ;,;;;I"Enumerator::Chain#each;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"each(*args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"...;T; @mo;L ;II" return;F;JI";T;0;K[I" Object;T; @m;[;I""@yield [...] @return [Object];T;0; @m;@F;Mi;N0;[[I" *args;T0; @mo;H ;II" overload;F;J0;;;K0;#I"each(*args);T;IC;";T;[;[;I";T;0; @m;@F;Mi;N0;[[I" *args;T0; @m;[;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; @m;@F;Ao;B;CT;Di ;Ei ;!@<;"I" 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_block_call(RARRAY_AREF(enums, i), id_each, argc, argv, enum_chain_yield_block, block); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Chain#size;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"Float::INFINITY;TI"nil;T; @;[;I"-@return [Integer, Float::INFINITY, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@<;"I"nstatic VALUE enum_chain_size(VALUE obj) { return enum_chain_total_size(enum_chain_ptr(obj)->enums); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Chain#rewind;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" rewind;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di7 ;Ei= ;!@<;"I"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; ; F; ;,;;;I"Enumerator::Chain#inspect;F;[;[[@if ;T;;i;0;[;{;IC;"9Returns a printable version of the enumerator chain. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"`Returns a printable version of the enumerator chain. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di` ;Eid ;!@<;"I"mstatic VALUE enum_chain_inspect(VALUE obj) { return rb_exec_recursive(inspect_enum_chain, obj, 0); };T;#I"static VALUE;T;$T;&@<;'IC;[;&@<;(IC;[;&@<;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@is [@i9 ;T;: Chain;;0;;;[;{;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;Ao;B;CT;Dis ;Eiy ;Mi;!o;2 ;30;40;50;:Enumerator;!@;7@:;F0;I"Enumerator::Chain;F;1@:o; ;IC;[o; ; F; ;,;;;I")Enumerator::ArithmeticSequence#begin;F;[;[;F;;D;;0;[;{;IC;" ;T;[;[;@;0; @;!@;$To; ; F; ;,;;;I"'Enumerator::ArithmeticSequence#end;F;[;[;F;;E;;0;[;{;IC;" ;T;[;[;@;0; @ ;!@;$To; ; F; ;,;;;I"0Enumerator::ArithmeticSequence#exclude_end?;F;[;[;F;;;;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;Mi;!@;$To; ; F; ;,;;;I"(Enumerator::ArithmeticSequence#step;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @ ;!@;$To; ; F; ;,;;;I")Enumerator::ArithmeticSequence#first;F;[[@0;[[@i ;T;;;0;[;{;IC;"aReturns the first number in this arithmetic sequence, or an array of the first +n+ elements. ;T;[o;H ;II" overload;F;J0;;;K0;#I" first;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;TI"nil;T; @);[;I"@return [Numeric, nil];T;0; @);@F;Mi;N0;[; @)o;H ;II" overload;F;J0;;;K0;#I" first(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @);[;I"@return [Array];T;0; @);@F;Mi;N0;[[I"n;T0; @);[;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;Ao;B;CT;Di ;Ei ;!@;"I" 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(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; ; F; ;,;;;I"(Enumerator::ArithmeticSequence#last;F;[[@0;[[@i ;T;;;0;[;{;IC;"_Returns the last number in this arithmetic sequence, or an array of the last +n+ elements. ;T;[o;H ;II" overload;F;J0;;;K0;#I" last;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;TI"nil;T; @U;[;I"@return [Numeric, nil];T;0; @U;@F;Mi;N0;[; @Uo;H ;II" overload;F;J0;;;K0;#I" last(n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @U;[;I"@return [Array];T;0; @U;@F;Mi;N0;[[I"n;T0; @U;[;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; @U;@F;Ao;B;CT;Di~ ;Ei ;!@;"I"`static 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 = rb_int_idiv(rb_int_minus(e, b), s); if (rb_num_negative_int_p(len_1)) { if (argc == 0) { return Qnil; } return rb_ary_new_capa(0); } last = rb_int_plus(b, rb_int_mul(s, len_1)); if ((last_is_adjusted = arith_seq_exclude_end_p(self) && rb_equal(last, e))) { last = rb_int_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; ; F; ;,;;;I"+Enumerator::ArithmeticSequence#inspect;F;[;[[@i ;T;;i;0;[;{;IC;":Convert this arithmetic sequence to a printable form. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"aConvert this arithmetic sequence to a printable form. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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, ", "); OBJ_INFECT(str, arg); } 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; ; F; ;,;;;I"&Enumerator::ArithmeticSequence#==;F;[[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;H ;II" overload;F;J0;;S;K0;#I" ==(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@;"I")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; ; F; ;,;;;I"'Enumerator::ArithmeticSequence#===;F;[[I" other;T0;[[@i ;T;;O;0;[;{;IC;"Returns true only if +obj+ is an Enumerator::ArithmeticSequence, has equivalent begin, end, step, and exclude_end? settings. ;T;[o;H ;II" overload;F;J0;;S;K0;#I" ==(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I")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; ; F; ;,;;;I"(Enumerator::ArithmeticSequence#eql?;F;[[I" other;T0;[[@i ;T;;R;0;[;{;IC;"Returns true only if +obj+ is an Enumerator::ArithmeticSequence, has equivalent begin, end, step, and exclude_end? settings.;T;[o;H ;II" overload;F;J0;;S;K0;#I" ==(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;@;0; @;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I")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; ; F; ;,;;;I"(Enumerator::ArithmeticSequence#hash;F;[;[[@i0 ;T;;U;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;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di& ;Ei. ;!@;"I"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; ; F; ;,;;;I"(Enumerator::ArithmeticSequence#each;F;[;[[@iP ;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @;[;I"@yield [i];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"0 @overload each @yield [i] @overload each;T;0; @;@F;Ao;B;CT;DiK ;EiN ;!@;"I"8static 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 = rb_int_idiv(rb_int_minus(e, c), s); last = rb_int_plus(c, rb_int_mul(s, len_1)); if (x && rb_equal(last, e)) { last = rb_int_minus(last, s); } if (rb_num_negative_int_p(s)) { while (NUM_GE(c, last)) { rb_yield(c); c = rb_int_plus(c, s); } } else { while (NUM_GE(last, c)) { rb_yield(c); c = rb_int_plus(c, s); } } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"(Enumerator::ArithmeticSequence#size;F;[;[[@i ;T;;;0;[;{;IC;"|Returns the number of elements in this arithmetic sequence if it is a finite sequence. Otherwise, returns nil. ;T;[o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;TI"nil;T; @5;[;I"@return [Numeric, nil];T;0; @5;@F;Mi;N0;[; @5;[;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; @5;@F;Ao;B;CT;Di ;Ei ;!@;"I"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 = arith_seq_float_step_size(NUM2DBL(b), ee, NUM2DBL(s), x); if (isinf(n)) return DBL2NUM(n); if (POSFIXABLE(n)) return LONG2FIX(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; ; F; ;;;;I"/Enumerator::ArithmeticSequence.__extract__;T;[[I"obj;T0;[[I"+ext/-test-/arith_seq/extract/extract.c;Ti;T;:__extract__;0;[;{;IC;" ;T;[;[;@;0; @Q;!o;2 ;3@;4I"#Enumerator::ArithmeticSequence;T;50;:ArithmeticSequence;!o;2 ;30;40;50;;;!@;7@:;F0;7@;F0;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@iC ;T;;;;0;;;[;{;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.;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. ;T;0; @;@F;Ao;B;CT;Di ;Ei ;Mi;!@`;I"#Enumerator::ArithmeticSequence;F;1@:o; ; F; ;,;;;I"Enumerator#initialize;F;[[@0;[[@i;T;;;0;[;{;IC;"Creates a new Enumerator object, which can be used as an Enumerable. In the first form, 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 p 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. In the second, deprecated, form, a generated Enumerator iterates over the given object using the given method with the given arguments passed. Use of this form is discouraged. Use Kernel#enum_for or Kernel#to_enum instead. e = Enumerator.new(ObjectSpace, :each_object) #-> ObjectSpace.enum_for(:each_object) e.select { |obj| obj.is_a?(Class) } #=> array of all classes ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(size = nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" yielder;T; @u;[;I"@yield [yielder];T;0; @u;@F;Mi;N0;[[I" size;TI"nil;T; @uo;H ;II" overload;F;J0;; ;K0;#I"$new(obj, method = :each, *args);T;IC;";T;[;[;I";T;0; @u;@F;Mi;N0;[[I"obj;T0[I" method;TI" :each;T[I" *args;T0; @u;[;I"&Creates a new Enumerator object, which can be used as an Enumerable. In the first form, 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 p 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. In the second, deprecated, form, a generated Enumerator iterates over the given object using the given method with the given arguments passed. Use of this form is discouraged. Use Kernel#enum_for or Kernel#to_enum instead. e = Enumerator.new(ObjectSpace, :each_object) #-> ObjectSpace.enum_for(:each_object) e.select { |obj| obj.is_a?(Class) } #=> array of all classes @overload new(size = nil) @yield [yielder] @overload new(obj, method = :each, *args);T;0; @u;@F;Ao;B;CT;Din;Ei;!@:;"I"fstatic VALUE enumerator_initialize(int argc, VALUE *argv, VALUE obj) { VALUE recv, meth = sym_each; VALUE size = Qnil; if (rb_block_given_p()) { rb_check_arity(argc, 0, 1); recv = generator_init(generator_allocate(rb_cGenerator), rb_block_proc()); if (argc) { if (NIL_P(argv[0]) || rb_respond_to(argv[0], id_call) || (RB_TYPE_P(argv[0], T_FLOAT) && RFLOAT_VALUE(argv[0]) == HUGE_VAL)) { size = argv[0]; } else { size = rb_to_int(argv[0]); } argc = 0; } } else { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); rb_warn("Enumerator.new without a block is deprecated; use Object#to_enum"); recv = *argv++; if (--argc) { meth = *argv++; --argc; } } return enumerator_init(obj, recv, meth, argc, argv, 0, size); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator#initialize_copy;F;[[I" orig;T0;[[@i;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@:;"I"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; ; F; ;,;;;I"Enumerator#each;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"elm;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I""@yield [elm] @return [Object];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"each(*appending_args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"elm;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I""@yield [elm] @return [Object];T;0; @;@F;Mi;N0;[[I"*appending_args;T0; @o;H ;II" overload;F;J0;;;K0;#I"each(*appending_args);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"*appending_args;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei!;!@:;"I"?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; ; F; ;,;;;I"Enumerator#each_with_index;F;[;[[@io;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;H ;II" overload;F;J0;;;K0;#I"each_with_index;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" (*args);TI"idx;T; @;[;I"@yield [(*args), idx];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"each_with_index;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Die;Eim;!@:;"I"kstatic VALUE enumerator_each_with_index(VALUE obj) { return enumerator_with_index(0, NULL, obj); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Enumerator#each_with_object;F;[[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;H ;II" overload;F;J0;;$;K0;#I"each_with_object(obj);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" (*args);TI"obj;T; @#;[;I"@yield [(*args), obj];T;0; @#;@F;Mi;N0;[[I"obj;T0; @#o;H ;II" overload;F;J0;;$;K0;#I"each_with_object(obj);T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[[I"obj;T0; @#o;H ;II" overload;F;J0;:with_object;K0;#I"with_object(obj);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" (*args);TI"obj;T; @#;[;I"@yield [(*args), obj];T;0; @#;@F;Mi;N0;[[I"obj;T0; @#o;H ;II" overload;F;J0;;;K0;#I"with_object(obj);T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[[I"obj;T0; @#;[;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; @#;@F;Ao;B;CT;Di~;Ei;!@:;"I"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; ; F; ;,;;;I"Enumerator#with_index;F;[[@0;[[@iZ;T;: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;H ;II" overload;F;J0;;;K0;#I"with_index(offset = 0);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" (*args);TI"idx;T; @g;[;I"@yield [(*args), idx];T;0; @g;@F;Mi;N0;[[I" offset;TI"0;T; @go;H ;II" overload;F;J0;;;K0;#I"with_index(offset = 0);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I" offset;TI"0;T; @g;[;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; @g;@F;Ao;B;CT;DiN;EiX;!@:;"I"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; ; F; ;,;;;I"Enumerator#with_object;F;[[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;H ;II" overload;F;J0;;$;K0;#I"each_with_object(obj);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" (*args);TI"obj;T; @;[;I"@yield [(*args), obj];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;$;K0;#I"each_with_object(obj);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;;K0;#I"with_object(obj);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" (*args);TI"obj;T; @;[;I"@yield [(*args), obj];T;0; @;@F;Mi;N0;[[I"obj;T0; @o;H ;II" overload;F;J0;;;K0;#I"with_object(obj);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;@c;0; @;@F;Ao;B;CT;Di~;Ei;!@:;"I"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; ; F; ;,;;;I"Enumerator#next_values;F;[;[[@i;T;:next_values;0;[;{;IC;"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. 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] Note that +next_values+ does not affect other non-external enumeration methods unless underlying iteration method itself has side-effect, e.g. IO#each_line. ;T;[o;H ;II" overload;F;J0;;;K0;#I"next_values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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. 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] Note that +next_values+ does not affect other non-external enumeration methods unless underlying iteration method itself has side-effect, e.g. IO#each_line. @overload next_values @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei ;!@:;"I" 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; ; F; ;,;;;I"Enumerator#peek_values;F;[;[[@iw;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. === 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;H ;II" overload;F;J0;;;K0;#I"peek_values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"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. === 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; @;@F;Ao;B;CT;Di[;Eit;!@:;"I"mstatic VALUE enumerator_peek_values_m(VALUE obj) { return rb_ary_dup(enumerator_peek_values(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator#next;F;[;[[@iI;T;;;0;[;{;IC;"Returns 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 Note that enumeration sequence by +next+ does not affect other non-external enumeration methods, unless the underlying iteration methods itself has side-effect, e.g. IO#each_line. ;T;[o;H ;II" overload;F;J0;;;K0;#I" next;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ ;[;I"@return [Object];T;0; @ ;@F;Mi;N0;[; @ ;[;I"Returns 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 Note that enumeration sequence by +next+ does not affect other non-external enumeration methods, unless the underlying iteration methods itself has side-effect, e.g. IO#each_line. @overload next @return [Object];T;0; @ ;@F;Ao;B;CT;Di3;EiF;!@:;"I"vstatic VALUE enumerator_next(VALUE obj) { VALUE vs = enumerator_next_values(obj); return ary2sv(vs, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator#peek;F;[;[[@i;T;: peek;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. === 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;H ;II" overload;F;J0;;;K0;#I" peek;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @&;[;I"@return [Object];T;0; @&;@F;Mi;N0;[; @&;[;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. === 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; @&;@F;Ao;B;CT;Di};Ei;!@:;"I"vstatic VALUE enumerator_peek(VALUE obj) { VALUE vs = enumerator_peek_values(obj); return ary2sv(vs, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator#feed;F;[[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;H ;II" overload;F;J0;:obj;K0;#I"obj;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @A;[;I"@return [nil];T;0; @A;@F;Mi;N0;[; @A;[;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; @A;@F;Ao;B;CT;Di;Ei;!@:;"I"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; ; F; ;,;;;I"Enumerator#rewind;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" rewind;T;IC;";T;[;[;I";T;0; @^;@F;Mi;N0;[; @^;[;I"Rewinds the enumeration sequence to the beginning. If the enclosed object responds to a "rewind" method, it is called. @overload rewind;T;0; @^;@F;Ao;B;CT;Di;Ei;!@:;"I"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; ; F; ;,;;;I"Enumerator#inspect;F;[;[[@is;T;;i;0;[;{;IC;"-Creates a printable version of e. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @t;[;I"@return [String];T;0; @t;@F;Mi;N0;[; @t;[;I"TCreates a printable version of e. @overload inspect @return [String];T;0; @t;@F;Ao;B;CT;Dil;Eip;!@:;"I"mstatic VALUE enumerator_inspect(VALUE obj) { return rb_exec_recursive(inspect_enumerator, obj, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator#size;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"Float::INFINITY;TI"nil;T; @;[;I"-@return [Integer, Float::INFINITY, nil];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Diy;Ei;!@:;"I"ystatic 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(e->size, id_call, argc, argv); if (size != Qundef) return size; return e->size; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator#+;F;[[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;H ;II" overload;F;J0;;(;K0;#I" +(enum);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" enum;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei ;!@:;"I"static VALUE enumerator_plus(VALUE obj, VALUE eobj) { VALUE enums = rb_ary_new_from_args(2, obj, eobj); return enum_chain_initialize(enum_chain_allocate(rb_cEnumChain), enums); };T;#I"static VALUE;T;$To; ;IC;[ o; ; F; ;,;;;I" Enumerator::Lazy#initialize;F;[[@0;[[@iD;T;;;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 method +filter_map+ in both lazy and non-lazy fashions: module Enumerable def filter_map(&block) map(&block).compact end end class Enumerator::Lazy def filter_map Lazy.new(self) do |yielder, *values| result = yield *values yielder << result if result end end end (1..Float::INFINITY).lazy.filter_map{|i| i*i if i.even?}.first(5) # => [4, 16, 36, 64, 100] ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(obj, size=nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" yielder;TI" *values;T; @;[;I"@yield [yielder, *values];T;0; @;@F;Mi;N0;[[I"obj;T0[I" size;TI"nil;T; @;[;I"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 method +filter_map+ in both lazy and non-lazy fashions: module Enumerable def filter_map(&block) map(&block).compact end end class Enumerator::Lazy def filter_map Lazy.new(self) do |yielder, *values| result = yield *values yielder << result if result end end end (1..Float::INFINITY).lazy.filter_map{|i| i*i if i.even?}.first(5) # => [4, 16, 36, 64, 100] @overload new(obj, size=nil) @yield [yielder, *values];T;0; @;@F;Ao;B;CT;Di(;EiB;!@;"I"3static 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); rb_ivar_set(self, id_receiver, obj); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Lazy#to_enum;F;[[@0;[[@i;T;;{;0;[;{;IC;"^Similar to Kernel#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 Kernel#to_enum: # See Kernel#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;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;|;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @;[;I"@yield [*args];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @o;H ;II" overload;F;J0;;|;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @;[;I"@yield [*args];T;0; @;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @;[;I"(Similar to Kernel#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 Kernel#to_enum: # See Kernel#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; @;@F;Ao;B;CT;Di;Ei;!@;"I"0static VALUE lazy_to_enum(int argc, VALUE *argv, VALUE self) { VALUE lazy, meth = sym_each; if (argc > 0) { --argc; meth = *argv++; } lazy = lazy_to_enum_i(self, meth, argc, argv, 0); if (rb_block_given_p()) { enumerator_ptr(lazy)->size = rb_block_proc(); } return lazy; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Lazy#enum_for;F;[[@0;[[@i;T;;|;0;[;{;IC;"^Similar to Kernel#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 Kernel#to_enum: # See Kernel#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;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @7o;H ;II" overload;F;J0;;|;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @7o;H ;II" overload;F;J0;;{;K0;#I"#to_enum(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @7;[;I"@yield [*args];T;0; @7;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @7o;H ;II" overload;F;J0;;|;K0;#I"$enum_for(method = :each, *args);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" *args;T; @7;[;I"@yield [*args];T;0; @7;@F;Mi;N0;[[I" method;TI" :each;T[I" *args;T0; @7;[;@3;0; @7;@F;Ao;B;CT;Di;Ei;!@;"I"0static VALUE lazy_to_enum(int argc, VALUE *argv, VALUE self) { VALUE lazy, meth = sym_each; if (argc > 0) { --argc; meth = *argv++; } lazy = lazy_to_enum_i(self, meth, argc, argv, 0); if (rb_block_given_p()) { enumerator_ptr(lazy)->size = rb_block_proc(); } return lazy; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Lazy#map;F;[;[[@i%;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#collect;F;[;[[@i%;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#flat_map;F;[;[[@iz;T;;;0;[;{;IC;"^Returns a new lazy enumerator with the concatenated results of running block once for every element in lazy. ["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: a) x responds to both each and force, which means that x is a lazy enumerator. b) 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;H ;II" overload;F;J0;;;K0;#I"collect_concat;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @;[;I"@yield [obj];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" flat_map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @;[;I"@yield [obj];T;0; @;@F;Mi;N0;[; @;[;I"Returns a new lazy enumerator with the concatenated results of running block once for every element in lazy. ["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: a) x responds to both each and force, which means that x is a lazy enumerator. b) 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; @;@F;Ao;B;CT;Dic;Eiy;!@;"I" 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_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, lazy_flat_map_proc, 0), Qnil, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"$Enumerator::Lazy#collect_concat;F;[;[[@iz;T;;;0;[;{;IC;"^Returns a new lazy enumerator with the concatenated results of running block once for every element in lazy. ["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: a) x responds to both each and force, which means that x is a lazy enumerator. b) 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;H ;II" overload;F;J0;;;K0;#I"collect_concat;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @;[;I"@yield [obj];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" flat_map;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"obj;T; @;[;I"@yield [obj];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Dic;Eiy;!@;"I" 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_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, lazy_flat_map_proc, 0), Qnil, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Lazy#select;F;[;[[@i;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#find_all;F;[;[[@i;T;; ;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#filter;F;[;[[@i;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#reject;F;[;[[@i;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#grep;F;[[I" pattern;T0;[[@i;T;; ;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#grep_v;F;[[I" pattern;T0;[[@i;T;; ;0;[;{;IC;" ;T;[;[;@;0; @(;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#zip;F;[[@0;[[@i@;T;;%;0;[;{;IC;" ;T;[;[;@;0; @6;!@;"I"static VALUE lazy_zip(int argc, VALUE *argv, VALUE obj) { VALUE ary, v; long i; rb_block_call_func *func = lazy_zip_arrays_func; 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); func = lazy_zip_func; break; } rb_ary_push(ary, v); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, func, ary), ary, lazy_receiver_size); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Lazy#take;F;[[I"n;T0;[[@i;T;;&;0;[;{;IC;" ;T;[;[;@;0; @C;!@;"I"~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; ; F; ;,;;;I" Enumerator::Lazy#take_while;F;[;[[@i;T;;';0;[;{;IC;" ;T;[;[;@;0; @Q;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#drop;F;[[I"n;T0;[[@i;T;;(;0;[;{;IC;" ;T;[;[;@;0; @];!@;"I"-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; ; F; ;,;;;I" Enumerator::Lazy#drop_while;F;[;[[@i;T;;);0;[;{;IC;" ;T;[;[;@;0; @k;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#lazy;F;[;[[@i8 ;T;;;0;[;{;IC;" ;T;[;[;@;0; @w;!@;"I":static VALUE lazy_lazy(VALUE obj) { return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Lazy#chunk;F;[[@0;[[@i2 ;T;;+;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I""Enumerator::Lazy#slice_before;F;[[@0;[[@i2 ;T;;,;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!Enumerator::Lazy#slice_after;F;[[@0;[[@i2 ;T;;-;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Enumerator::Lazy#slice_when;F;[[@0;[[@i2 ;T;;.;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!Enumerator::Lazy#chunk_while;F;[[@0;[[@i2 ;T;;/;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Lazy#uniq;F;[;[[@i* ;T;;0;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"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; ; F; ;,;;;I"Enumerator::Lazy#to_a;F;[;[[@ic;T;;;0;[;{;IC;"@Expands +lazy+ enumerator to an array. See Enumerable#to_a. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;: force;K0;#I" force;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"Expands +lazy+ enumerator to an array. See Enumerable#to_a. @overload to_a @return [Array] @overload force @return [Array];T;0; o; ; F; ;,;;;I"Enumerator::Lazy#force;F;[;[[@i$ ;F;;;;0;[;{;@;!@;"I"+static VALUE lazy_to_a(VALUE self) { };T;#I"'static VALUE lazy_to_a(VALUE self);T;@F;Ao;B;CT;Di[;Eib;!@;"I"+static VALUE lazy_to_a(VALUE self) { };T;#@;$T@;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@;;.[;[[@i ;F;: Lazy;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@:;I"Enumerator::Lazy;F;1@:o; ;IC;[o; ; F; ;,;;;I"%Enumerator::Generator#initialize;F;[[@0;[[@i_;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di^;Ei^;!@;"I"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; ; F; ;,;;;I"*Enumerator::Generator#initialize_copy;F;[[I" orig;T0;[[@iz;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @ ;@F;Ao;B;CT;Diy;Eiy;!@;"I"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; ; F; ;,;;;I"Enumerator::Generator#each;F;[[@0;[[@i;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @0;@F;Ao;B;CT;Di;Ei;!@;"I"$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(ptr->proc, args); };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[@C;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i* ;F;:Generator;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@:;I"Enumerator::Generator;F;1@proc, args); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Enumerator::Yielder#<<;F;[[I"arg;T0;[[@i;T;;Q;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @n;@F;Ao;B;CT;Di;Ei;!@N;"I"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;$T;&@N;'IC;[;&@N;(IC;[;&@N;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i2 ;F;: Yielder;;0;;;[;{;IC;" ;T;[;[;@;0; @N;Mi;!@:;I"Enumerator::Yielder;F;1@<;&@:;'IC;[;&@:;(IC;[o;2 ;30;40;50;;1;!@;7@C;F0;&@:;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;;;;0;;;[;{;IC;"A class which allows both internal and external iteration. An Enumerator can be created by the following methods. - Kernel#to_enum - Kernel#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 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. - Kernel#to_enum - Kernel#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 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;Ao;B;CT;Di;Eio;Mi;!@;I"Enumerator;F;1@<@@C@ `o; ;IC;[&o;9;[[@diE[@fi1E;F;: Version;;;;;;[;{;IC;"version of Ripper ;T;[;[;I"version of Ripper;T;0; @;@F;Ao;B;CT;Di0E;Ei0E;!@;I"Ripper::Version;F;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; ; F; ;,;;;I"Ripper#parse;F;[;[[@diyD[@fiD;T;;;0;[;{;IC;"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; ; F; ;,;;;I"Ripper#column;F;[;[[@diD[@fiD;T;: column;0;[;{;IC;"MReturn column number of current parsing line. This number starts from 0. ;T;[o;H ;II" overload;F;J0;;;K0;#I" column;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"tReturn column number of current parsing line. This number starts from 0. @overload column @return [Integer];T;0; @;@F;Ao;B;CT;DiD;EiD;!@;"I"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; ; F; ;,;;;I"Ripper#filename;F;[;[[@diD[@fiD;T;: filename;0;[;{;IC;"%Return current parsing filename. ;T;[o;H ;II" overload;F;J0;;;K0;#I" filename;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"MReturn current parsing filename. @overload filename @return [String];T;0; @;@F;Ao;B;CT;DiD;EiD;!@;"I"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; ; F; ;,;;;I"Ripper#lineno;F;[;[[@diD[@fiD;T;;;0;[;{;IC;"KReturn line number of current parsing line. This number starts from 1. ;T;[o;H ;II" overload;F;J0;;;K0;#I" lineno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"rReturn line number of current parsing line. This number starts from 1. @overload lineno @return [Integer];T;0; @;@F;Ao;B;CT;DiD;EiD;!@;"I"_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; ; F; ;,;;;I"Ripper#state;F;[;[[@diD[@fiD;T;;;0;[;{;IC;"+Return scanner state of current token. ;T;[o;H ;II" overload;F;J0;;;K0;#I" state;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @:;[;I"@return [Integer];T;0; @:;@F;Mi;N0;[; @:;[;I"QReturn scanner state of current token. @overload state @return [Integer];T;0; @:;@F;Ao;B;CT;DiD;EiD;!@;"I"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; ; F; ;,;;;I"Ripper#end_seen?;F;[;[[@diB[@fiC;T;:end_seen?;0;[;{;IC;"9Return true if parsed source ended by +\_\_END\_\_+.;T;[o;H ;II" overload;F;J0;;;K0;#I"end_seen?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @V;[;I"@return [Boolean];T;0; @V;@F;Mi;N0;[; @V;[;I"cReturn true if parsed source ended by +\_\_END\_\_+. @overload end_seen? @return [Boolean];T;0; @V;@F;Ao;B;CT;DiB;EiC;Mi;!@;"I"VALUE rb_parser_end_seen_p(VALUE vparser) { struct parser_params *p; TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); return p->ruby__end__seen ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Ripper#encoding;F;[;[[@diB[@fiC;T;;;0;[;{;IC;"#Return encoding of the source. ;T;[o;H ;II" overload;F;J0;;;K0;#I" encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @r;[;I"@return [Encoding];T;0; @r;@F;Mi;N0;[; @r;[;I"MReturn encoding of the source. @overload encoding @return [Encoding];T;0; @r;@F;Ao;B;CT;Di C;EiC;!@;"I"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; ; F; ;,;;;I"Ripper#yydebug;F;[;[[@diC[@fi!C;T;: yydebug;0;[;{;IC;"Get yydebug. ;T;[o;H ;II" overload;F;J0;;;K0;#I" yydebug;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"9Get yydebug. @overload yydebug @return [Boolean];T;0; @;@F;Ao;B;CT;DiC;EiC;!@;"I"VALUE rb_parser_get_yydebug(VALUE self) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); return p->debug ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;,;;;I"Ripper#yydebug=;F;[[I" flag;T0;[[@diC[@fi0C;T;: yydebug=;0;[;{;IC;"Set yydebug. ;T;[o;H ;II" overload;F;J0;;;K0;#I"yydebug=(flag);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" flag;T0; @;[;I",Set yydebug. @overload yydebug=(flag);T;0; @;@F;Ao;B;CT;Di*C;Ei-C;!@;"I"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; ; F; ;,;;;I"Ripper#error?;F;[;[[@diB[@fiB;T;: error?;0;[;{;IC;"-Return true if parsed source has errors.;T;[o;H ;II" overload;F;J0;;;K0;#I" error?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"TReturn true if parsed source has errors. @overload error? @return [Boolean];T;0; @;@F;Ao;B;CT;DiB;EiB;Mi;!@;"I"static VALUE ripper_error_p(VALUE vparser) { struct parser_params *p; TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); return p->error_p ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Ripper.dedent_string;F;[[I" input;T0[I" width;T0;[[@diB0[@fic0;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;H ;II" overload;F;J0;;;K0;#I" dedent_string(input, width);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiZ0;Eia0;!@;"I"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; ; F; ;,;;;I"Ripper#dedent_string;F;[[I" input;T0[I" width;T0;[[@diB0[@fic0;T;;;0;[;{;IC;"USE OF RIPPER LIBRARY ONLY. Strips up to +width+ leading whitespaces from +input+, and returns the stripped column width. ;T;[o;H ;II" overload;F;J0;;;K0;#I" dedent_string(input, width);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" input;T0[I" width;T0; @;[;@;0; @;@F;Ao;B;CT;DiZ0;Eia0;!@;"I"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; ; F; ;;;;I"Ripper.lex_state_name;F;[[I" state;T0;[[@diD[@fiE;T;:lex_state_name;0;[;{;IC;"2Returns a string representation of lex_state. ;T;[o;H ;II" overload;F;J0;;;K0;#I"lex_state_name(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @(;[;I"@return [String];T;0; @(;@F;Mi;N0;[[I" integer;T0; @(;[;I"iReturns a string representation of lex_state. @overload lex_state_name(integer) @return [String];T;0; @(;@F;Ao;B;CT;DiE;EiE;!@;"I"ystatic VALUE ripper_lex_state_name(VALUE self, VALUE state) { return rb_parser_lex_state_name(NUM2INT(state)); };T;#I"static VALUE;T;$To;9;[[@fiJE;F;: EXPR_BEG;;;;;;[;{;IC;"#ignore newline, +/- is a sign. ;T;[;[;I"#ignore newline, +/- is a sign.;T;0; @H;@F;Ao;B;CT;DiIE;EiIE;!@;I"Ripper::EXPR_BEG;F;(EXPR_BEG | EXPR_MID | EXPR_CLASS) ;T;[;[;I":equals to (EXPR_BEG | EXPR_MID | EXPR_CLASS);T;0; @;@F;Ao;B;CT;DieE;EieE;!@;I"Ripper::EXPR_BEG_ANY;F;(EXPR_ARG | EXPR_CMDARG) ;T;[;[;I"0equals to (EXPR_ARG | EXPR_CMDARG);T;0; @;@F;Ao;B;CT;DigE;EigE;!@;I"Ripper::EXPR_ARG_ANY;F;(EXPR_END | EXPR_ENDARG | EXPR_ENDFN) ;T;[;[;I"=equals to (EXPR_END | EXPR_ENDARG | EXPR_ENDFN);T;0; @;@F;Ao;B;CT;DiiE;EiiE;!@;I"Ripper::EXPR_END_ANY;F; [#] ;T;[o;H ;II" overload;F;J0;;%;K0;#I" list;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @?;[;I"@return [Array];T;0; @?;@F;Mi;N0;[; @?;[;I"Returns an array of all existing Thread objects that belong to this group. ThreadGroup::Default.list #=> [#] @overload list @return [Array];T;0; @?;@F;Ao;B;CT;Di;Ei;!@=;"I"static VALUE thgroup_list(VALUE group) { VALUE ary = rb_ary_new(); rb_vm_t *vm = GET_THREAD()->vm; rb_thread_t *th = 0; list_for_each(&vm->living_threads, th, vmlt_node) { if (th->thgroup == group) { rb_ary_push(ary, th->self); } } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ThreadGroup#enclose;F;[;[[@1i;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;H ;II" overload;F;J0;;;K0;#I" enclose;T;IC;";T;[;[;I";T;0; @Z;@F;Mi;N0;[; @Z;[;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; @Z;@F;Ao;B;CT;Di;Ei;!@=;"I"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; ; F; ;,;;;I"ThreadGroup#enclosed?;F;[;[[@1i;T;:enclosed?;0;[;{;IC;"MReturns +true+ if the +thgrp+ is enclosed. See also ThreadGroup#enclose.;T;[o;H ;II" overload;F;J0;;;K0;#I"enclosed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @p;[;I"@return [Boolean];T;0; @p;@F;Mi;N0;[; @p;[;I"wReturns +true+ if the +thgrp+ is enclosed. See also ThreadGroup#enclose. @overload enclosed? @return [Boolean];T;0; @p;@F;Ao;B;CT;Di;Ei;Mi;!@=;"I"static VALUE thgroup_enclosed_p(VALUE group) { struct thgroup *data; TypedData_Get_Struct(group, struct thgroup, &thgroup_data_type, data); if (data->enclosed) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ThreadGroup#add;F;[[I" thread;T0;[[@1i";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;H ;II" overload;F;J0;;;K0;#I"add(thread);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@=;"I"Cstatic 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 (!target_th->thgroup) { return Qnil; } 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;9;[[@1i;;F;: Default;;;;;;[;{;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;thgroup;T;&@=;'IC;[;&@=;(IC;[;&@=;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@1i[@1i2;T;:ThreadGroup;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!@;I"ThreadGroup;F;1@encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. With no block, open is a synonym for Dir::new. If a block is present, it is passed aDir as a parameter. The directory is closed at the end of the block, and Dir::open returns the value of the block. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"open( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Dir;T; @;[;I"@return [Dir];T;0; @;@F;Mi;N0;[[I" string;T0; @o;H ;II" overload;F;J0;;;K0;#I""open( string, encoding: enc );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Dir;T; @;[;I"@return [Dir];T;0; @;@F;Mi;N0;[[I" string;T0[I"encoding:;TI"enc;T; @o;H ;II" overload;F;J0;;;K0;#I"open( string );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" aDir;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"%@yield [ aDir ] @return [Object];T;0; @;@F;Mi;N0;[[I" string;T0; @o;H ;II" overload;F;J0;;;K0;#I""open( string, encoding: enc );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" aDir;T; @o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"%@yield [ aDir ] @return [Object];T;0; @;@F;Mi;N0;[[I" string;T0[I"encoding:;TI"enc;T; @;[;I"mThe optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. With no block, open is a synonym for Dir::new. If a block is present, it is passed aDir as a parameter. The directory is closed at the end of the block, and Dir::open returns the value of the block. @overload open( string ) @return [Dir] @overload open( string, encoding: enc ) @return [Dir] @overload open( string ) @yield [ aDir ] @return [Object] @overload open( string, encoding: enc ) @yield [ aDir ] @return [Object];T;0; @;@F;Ao;B;CT;DiI;Ei\;!@;"I"8static VALUE dir_s_open(int argc, VALUE *argv, VALUE klass) { struct dir_data *dp; VALUE dir = TypedData_Make_Struct(klass, struct dir_data, &dir_data_type, dp); dir_initialize(argc, argv, dir); if (rb_block_given_p()) { return rb_ensure(rb_yield, dir, dir_close, dir); } return dir; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Dir.foreach;F;[[@0;[[@i ;T;;;0;[;{;IC;".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 ;T;[ o;H ;II" overload;F;J0;;;K0;#I"foreach( dirname );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" filename;T; @4 o;L ;II" return;F;JI";T;0;K[I"nil;T; @4 ;[;I"&@yield [ filename ] @return [nil];T;0; @4 ;@F;Mi;N0;[[I" dirname;T0; @4 o;H ;II" overload;F;J0;;;K0;#I"&foreach( dirname, encoding: enc );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" filename;T; @4 o;L ;II" return;F;JI";T;0;K[I"nil;T; @4 ;[;I"&@yield [ filename ] @return [nil];T;0; @4 ;@F;Mi;N0;[[I" dirname;T0[I"encoding:;TI"enc;T; @4 o;H ;II" overload;F;J0;;;K0;#I"foreach( dirname );T;IC;";T;[;[;I";T;0; @4 ;@F;Mi;N0;[[I" dirname;T0; @4 o;H ;II" overload;F;J0;;;K0;#I"&foreach( dirname, encoding: enc );T;IC;";T;[;[;I";T;0; @4 ;@F;Mi;N0;[[I" dirname;T0[I"encoding:;TI"enc;T; @4 ;[;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; @4 ;@F;Ao;B;CT;Diq ;Ei ;!@;"I"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; ; F; ;;;;I"Dir.entries;F;[[@0;[[@i ;T;;;0;[;{;IC;"gReturns 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;H ;II" overload;F;J0;;;K0;#I"entries( dirname );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I" dirname;T0; @ o;H ;II" overload;F;J0;;;K0;#I"&entries( dirname, encoding: enc );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I" dirname;T0[I"encoding:;TI"enc;T; @ ;[;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; @ ;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;;;;I"Dir.each_child;F;[[@0;[[@i ;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;H ;II" overload;F;J0;;;K0;#I"each_child( dirname );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" filename;T; @ o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"&@yield [ filename ] @return [nil];T;0; @ ;@F;Mi;N0;[[I" dirname;T0; @ o;H ;II" overload;F;J0;;;K0;#I")each_child( dirname, encoding: enc );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" filename;T; @ o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"&@yield [ filename ] @return [nil];T;0; @ ;@F;Mi;N0;[[I" dirname;T0[I"encoding:;TI"enc;T; @ o;H ;II" overload;F;J0;;;K0;#I"each_child( dirname );T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" dirname;T0; @ o;H ;II" overload;F;J0;;;K0;#I")each_child( dirname, encoding: enc );T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" dirname;T0[I"encoding:;TI"enc;T; @ ;[;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; @ ;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;;;;I"Dir.children;F;[[@0;[[@i ;T;;;0;[;{;IC;"uReturns 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;H ;II" overload;F;J0;;;K0;#I"children( dirname );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @!;[;I"@return [Array];T;0; @!;@F;Mi;N0;[[I" dirname;T0; @!o;H ;II" overload;F;J0;;;K0;#I"'children( dirname, encoding: enc );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @!;[;I"@return [Array];T;0; @!;@F;Mi;N0;[[I" dirname;T0[I"encoding:;TI"enc;T; @!;[;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; @!;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Dir#initialize;F;[[@0;[[@i ;T;;;0;[;{;IC;"Returns a new directory object for the named directory. The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Dir;T; @6!;[;I"@return [Dir];T;0; @6!;@F;Mi;N0;[[I" string;T0; @6!o;H ;II" overload;F;J0;; ;K0;#I"!new( string, encoding: enc );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Dir;T; @6!;[;I"@return [Dir];T;0; @6!;@F;Mi;N0;[[I" string;T0[I"encoding:;TI"enc;T; @6!;[;I"#Returns a new directory object for the named directory. The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. @overload new( string ) @return [Dir] @overload new( string, encoding: enc ) @return [Dir];T;0; @6!;@F;Ao;B;CT;Di;Ei ;!@;"I"static VALUE dir_initialize(int argc, VALUE *argv, VALUE dir) { struct dir_data *dp; rb_encoding *fsenc; VALUE dirname, opt, orig; static ID keyword_ids[1]; const char *path; if (!keyword_ids[0]) { keyword_ids[0] = rb_id_encoding(); } fsenc = rb_filesystem_encoding(); rb_scan_args(argc, argv, "1:", &dirname, &opt); if (!NIL_P(opt)) { VALUE enc; rb_get_kwargs(opt, keyword_ids, 0, 1, &enc); if (enc != Qundef && !NIL_P(enc)) { fsenc = rb_to_encoding(enc); } } FilePathValue(dirname); orig = rb_str_dup_frozen(dirname); dirname = rb_str_encode_ospath(dirname); dirname = rb_str_dup_frozen(dirname); TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dp); if (dp->dir) closedir(dp->dir); dp->dir = NULL; RB_OBJ_WRITE(dir, &dp->path, Qnil); dp->enc = fsenc; path = RSTRING_PTR(dirname); dp->dir = opendir_without_gvl(path); if (dp->dir == NULL) { int e = errno; if (rb_gc_for_fd(e)) { dp->dir = opendir_without_gvl(path); } #ifdef HAVE_GETATTRLIST else if (e == EIO) { u_int32_t attrbuf[1]; struct attrlist al = {ATTR_BIT_MAP_COUNT, 0}; if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW) == 0) { dp->dir = opendir_without_gvl(path); } } #endif if (dp->dir == NULL) { RB_GC_GUARD(dirname); rb_syserr_fail_path(e, orig); } } RB_OBJ_WRITE(dir, &dp->path, orig); return dir; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Dir#fileno;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" fileno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @f!;[;I"@return [Integer];T;0; @f!;@F;Mi;N0;[; @f!;[;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; @f!;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" Dir#path;F;[;[[@i;T;;;0;[;{;IC;"pReturns the path parameter passed to dir's constructor. d = Dir.new("..") d.path #=> ".." ;T;[o;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @!;[;I"@return [String, nil];T;0; @!;@F;Mi;N0;[; @!o;H ;II" overload;F;J0;;;K0;#I" to_path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @!;[;I"@return [String, nil];T;0; @!;@F;Mi;N0;[; @!;[;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; @!;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Dir#to_path;F;[;[[@i;T;;;0;[;{;IC;"pReturns the path parameter passed to dir's constructor. d = Dir.new("..") d.path #=> ".." ;T;[o;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @!;[;I"@return [String, nil];T;0; @!;@F;Mi;N0;[; @!o;H ;II" overload;F;J0;;;K0;#I" to_path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @!;[;I"@return [String, nil];T;0; @!;@F;Mi;N0;[; @!;[;@!;0; @!;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Dir#inspect;F;[;[[@i;T;;i;0;[;{;IC;"0Return a string describing this Dir object. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @!;[;I"@return [String];T;0; @!;@F;Mi;N0;[; @!;[;I"WReturn a string describing this Dir object. @overload inspect @return [String];T;0; @!;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" Dir#read;F;[;[[@i ;T;;;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;H ;II" overload;F;J0;;;K0;#I" read;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @!;[;I"@return [String, nil];T;0; @!;@F;Mi;N0;[; @!;[;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; @!;@F;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;,;;;I" Dir#each;F;[;[[@i;;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;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" filename;T; @ "o;L ;II" return;F;JI";T;0;K[I"Dir;T; @ ";[;I"$@yield [filename] @return [Dir];T;0; @ ";@F;Mi;N0;[; @ "o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @ ";@F;Mi;N0;[; @ ";[;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; @ ";@F;Ao;B;CT;Di';Ei:;!@;"I"~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; ; F; ;,;;;I"Dir#each_child;F;[;[[@i ;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;H ;II" overload;F;J0;;;K0;#I"each_child;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" filename;T; @3"o;L ;II" return;F;JI";T;0;K[I"nil;T; @3";[;I"&@yield [ filename ] @return [nil];T;0; @3";@F;Mi;N0;[; @3"o;H ;II" overload;F;J0;;;K0;#I"each_child;T;IC;";T;[;[;I";T;0; @3";@F;Mi;N0;[; @3";[;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 [nil] @overload each_child;T;0; @3";@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Dir#children;F;[;[[@i ;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;H ;II" overload;F;J0;;;K0;#I" children;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @[";[;I"@return [Array];T;0; @[";@F;Mi;N0;[; @[";[;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; @[";@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Dir#rewind;F;[;[[@i;T;;;0;[;{;IC;"Repositions dir to the first entry. d = Dir.new("testdir") d.read #=> "." d.rewind #=> # d.read #=> "." ;T;[o;H ;II" overload;F;J0;;;K0;#I" rewind;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Dir;T; @v";[;I"@return [Dir];T;0; @v";@F;Mi;N0;[; @v";[;I"Repositions dir to the first entry. d = Dir.new("testdir") d.read #=> "." d.rewind #=> # d.read #=> "." @overload rewind @return [Dir];T;0; @v";@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE dir_rewind(VALUE dir) { struct dir_data *dirp; GetDIR(dir, dirp); rewinddir(dirp->dir); return dir; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Dir#tell;F;[;[[@iq;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;H ;II" overload;F;J0;;;K0;#I"pos;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @";[;I"@return [Integer];T;0; @";@F;Mi;N0;[; @"o;H ;II" overload;F;J0;;;K0;#I" tell;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @";[;I"@return [Integer];T;0; @";@F;Mi;N0;[; @";[;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; @";@F;Ao;B;CT;Did;Eip;!@;"I"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; ; F; ;,;;;I" Dir#seek;F;[[I"pos;T0;[[@i;T;;;0;[;{;IC;"gSeeks 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;H ;II" overload;F;J0;;;K0;#I"seek( integer );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Dir;T; @";[;I"@return [Dir];T;0; @";@F;Mi;N0;[[I" integer;T0; @";[;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; @";@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" Dir#pos;F;[;[[@iq;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;H ;II" overload;F;J0;;;K0;#I"pos;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @";[;I"@return [Integer];T;0; @";@F;Mi;N0;[; @"o;H ;II" overload;F;J0;;;K0;#I" tell;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @";[;I"@return [Integer];T;0; @";@F;Mi;N0;[; @";[;@";0; @";@F;Ao;B;CT;Did;Eip;!@;"I"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; ; F; ;,;;;I" Dir#pos=;F;[[I"pos;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"pos=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @";[;I"@return [Integer];T;0; @";@F;Mi;N0;[[I" integer;T0; @";[;I"[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 #=> ".." @overload pos=(integer) @return [Integer];T;0; @";@F;Ao;B;CT;Di;Ei;!@;"I"_static VALUE dir_set_pos(VALUE dir, VALUE pos) { dir_seek(dir, pos); return pos; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Dir#close;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @#;[;I"@return [nil];T;0; @#;@F;Mi;N0;[; @#;[;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; @#;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Dir.chdir;F;[[@0;[[@i6;T;: chdir;0;[;{;IC;"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. 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;H ;II" overload;F;J0;;;K0;#I"chdir( [ string] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @9#;[;I"@return [0];T;0; @9#;@F;Mi;N0;[[I"[ string];T0; @9#o;H ;II" overload;F;J0;;;K0;#I"chdir( [ string] );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" path;T; @9#o;L ;II" return;F;JI";T;0;K[I" Object;T; @9#;[;I"%@yield [ path ] @return [Object];T;0; @9#;@F;Mi;N0;[[I"[ string];T0; @9#;[;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. 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; @9#;@F;Ao;B;CT;Di;Ei6;!@;"I"static 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_block_given_p() || rb_thread_current() != chdir_thread) 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; ; F; ;;;;I"Dir.getwd;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" getwd;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k#;[;I"@return [String];T;0; @k#;@F;Mi;N0;[; @k#o;H ;II" overload;F;J0;:pwd;K0;#I"pwd;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k#;[;I"@return [String];T;0; @k#;@F;Mi;N0;[; @k#;[;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; @k#;@F;Ao;B;CT;Di;Ei;!@;"I"Gstatic VALUE dir_s_getwd(VALUE dir) { return rb_dir_getwd(); };T;#I"static VALUE;T;$To; ; F; ;;;;I" Dir.pwd;F;[;[[@i;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;H ;II" overload;F;J0;;;K0;#I" getwd;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I"@return [String];T;0; @#;@F;Mi;N0;[; @#o;H ;II" overload;F;J0;;;K0;#I"pwd;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @#;[;I"@return [String];T;0; @#;@F;Mi;N0;[; @#;[;@#;0; @#;@F;Ao;B;CT;Di;Ei;!@;"I"Gstatic VALUE dir_s_getwd(VALUE dir) { return rb_dir_getwd(); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Dir.chroot;F;[[I" path;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"chroot( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @#;[;I"@return [0];T;0; @#;@F;Mi;N0;[[I" string;T0; @#;[;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; @#;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Dir.mkdir;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" mkdir( string [, integer] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @#;[;I"@return [0];T;0; @#;@F;Mi;N0;[[I"string[, integer];T0; @#;[;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; @#;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Dir.rmdir;F;[[I"dir;T0;[[@i;T;: rmdir;0;[;{;IC;"qDeletes the named directory. Raises a subclass of SystemCallError if the directory isn't empty. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @#;[;I"@return [0];T;0; @#;@F;Mi;N0;[[I" string;T0; @#o;H ;II" overload;F;J0;;;K0;#I"rmdir( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @#;[;I"@return [0];T;0; @#;@F;Mi;N0;[[I" string;T0; @#o;H ;II" overload;F;J0;;;K0;#I"unlink( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @#;[;I"@return [0];T;0; @#;@F;Mi;N0;[[I" string;T0; @#;[;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; @#;@F;Ao;B;CT;Di;Ei;!@;"I" 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; ; F; ;;;;I"Dir.delete;F;[[I"dir;T0;[[@i;T;;p;0;[;{;IC;"qDeletes the named directory. Raises a subclass of SystemCallError if the directory isn't empty. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @4$;[;I"@return [0];T;0; @4$;@F;Mi;N0;[[I" string;T0; @4$o;H ;II" overload;F;J0;;;K0;#I"rmdir( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @4$;[;I"@return [0];T;0; @4$;@F;Mi;N0;[[I" string;T0; @4$o;H ;II" overload;F;J0;;;K0;#I"unlink( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @4$;[;I"@return [0];T;0; @4$;@F;Mi;N0;[[I" string;T0; @4$;[;@0$;0; @4$;@F;Ao;B;CT;Di;Ei;!@;"I" 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; ; F; ;;;;I"Dir.unlink;F;[[I"dir;T0;[[@i;T;;;0;[;{;IC;"qDeletes the named directory. Raises a subclass of SystemCallError if the directory isn't empty. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @p$;[;I"@return [0];T;0; @p$;@F;Mi;N0;[[I" string;T0; @p$o;H ;II" overload;F;J0;;;K0;#I"rmdir( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @p$;[;I"@return [0];T;0; @p$;@F;Mi;N0;[[I" string;T0; @p$o;H ;II" overload;F;J0;;;K0;#I"unlink( string );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @p$;[;I"@return [0];T;0; @p$;@F;Mi;N0;[[I" string;T0; @p$;[;@0$;0; @p$;@F;Ao;B;CT;Di;Ei;!@;"I" 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; ; F; ;;;;I" Dir.home;F;[[@0;[[@i ;T;: home;0;[;{;IC;"OReturns the home directory of the current user or the named user if given. ;T;[o;H ;II" overload;F;J0;;;K0;#I" home();T;IC;";T;[;[;I";T;0; @$;@F;Mi;N0;[; @$o;H ;II" overload;F;J0;;;K0;#I"home("root");T;IC;";T;[;[;I";T;0; @$;@F;Mi;N0;[[" "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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;;;;I" Dir.glob;F;[[@0;[[@iI ;T;: glob;0;[;{;IC;"w Expands +pattern+, which is a pattern string or an Array of pattern strings, and returns an array containing the matching filenames. If a block is given, calls the block once for each matching filename, passing the filename as a parameter to the block. The optional +base+ keyword argument specifies the base directory for interpreting relative pathnames instead of the current working directory. As the results are not prefixed with the base directory name in this case, you will need to prepend the base directory name if you want real paths. Note that the pattern is not a regexp, it's closer to a shell glob. See File::fnmatch for the meaning of the +flags+ parameter. Case sensitivity depends on your system (File::FNM_CASEFOLD is ignored), as does the order in which the results are returned. *:: Matches any file. Can be restricted by other values in the glob. Equivalent to / .* /mx in regexp. *:: Matches all files c*:: Matches all files beginning with c *c:: Matches all files ending with c \*c\*:: Match all files that have c in them (including at the beginning or end). Note, this will not match Unix-like hidden files (dotfiles). In order to include those in the match results, you must use the File::FNM_DOTMATCH flag or something like "{*,.*}". **:: Matches directories recursively. ?:: Matches any one character. Equivalent to /.{1}/ in regexp. [set]:: Matches any one character in +set+. Behaves exactly like character sets in Regexp, including set negation ([^a-z]). {p,q}:: Matches either literal p or literal q. Equivalent to pattern alternation in regexp. Matching literals may be more than one character in length. More than two literals may be specified. \\ :: Escapes the next metacharacter. Note that this means you cannot use backslash on windows as part of a glob, i.e. Dir["c:\\foo*"] will not work, use Dir["c:/foo*"] instead. Examples: Dir["config.?"] #=> ["config.h"] Dir.glob("config.?") #=> ["config.h"] Dir.glob("*.[a-z][a-z]") #=> ["main.rb"] Dir.glob("*.[^r]*") #=> ["config.h"] Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"] Dir.glob("*") #=> ["config.h", "main.rb"] Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"] Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"] rbfiles = File.join("**", "*.rb") Dir.glob(rbfiles) #=> ["main.rb", # "lib/song.rb", # "lib/song/karaoke.rb"] Dir.glob(rbfiles, base: "lib") #=> ["song.rb", # "song/karaoke.rb"] libdirs = File.join("**", "lib") Dir.glob(libdirs) #=> ["lib"] librbfiles = File.join("**", "lib", "**", "*.rb") Dir.glob(librbfiles) #=> ["lib/song.rb", # "lib/song/karaoke.rb"] librbfiles = File.join("**", "lib", "*.rb") Dir.glob(librbfiles) #=> ["lib/song.rb"] ;T;[o;H ;II" overload;F;J0;;;K0;#I"+glob( pattern, [flags], [base: path] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @$;[;I"@return [Array];T;0; @$;@F;Mi;N0;[[I" pattern;T0[I" [flags];T0[I" [base:;TI" path];T; @$o;H ;II" overload;F;J0;;;K0;#I"+glob( pattern, [flags], [base: path] );T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" filename;T; @$o;L ;II" return;F;JI";T;0;K[I"nil;T; @$;[;I"$@yield [filename] @return [nil];T;0; @$;@F;Mi;N0;[[I" pattern;T0[I" [flags];T0[I" [base:;TI" path];T; @$;[;I"Expands +pattern+, which is a pattern string or an Array of pattern strings, and returns an array containing the matching filenames. If a block is given, calls the block once for each matching filename, passing the filename as a parameter to the block. The optional +base+ keyword argument specifies the base directory for interpreting relative pathnames instead of the current working directory. As the results are not prefixed with the base directory name in this case, you will need to prepend the base directory name if you want real paths. Note that the pattern is not a regexp, it's closer to a shell glob. See File::fnmatch for the meaning of the +flags+ parameter. Case sensitivity depends on your system (File::FNM_CASEFOLD is ignored), as does the order in which the results are returned. *:: Matches any file. Can be restricted by other values in the glob. Equivalent to / .* /mx in regexp. *:: Matches all files c*:: Matches all files beginning with c *c:: Matches all files ending with c \*c\*:: Match all files that have c in them (including at the beginning or end). Note, this will not match Unix-like hidden files (dotfiles). In order to include those in the match results, you must use the File::FNM_DOTMATCH flag or something like "{*,.*}". **:: Matches directories recursively. ?:: Matches any one character. Equivalent to /.{1}/ in regexp. [set]:: Matches any one character in +set+. Behaves exactly like character sets in Regexp, including set negation ([^a-z]). {p,q}:: Matches either literal p or literal q. Equivalent to pattern alternation in regexp. Matching literals may be more than one character in length. More than two literals may be specified. \\ :: Escapes the next metacharacter. Note that this means you cannot use backslash on windows as part of a glob, i.e. Dir["c:\\foo*"] will not work, use Dir["c:/foo*"] instead. Examples: Dir["config.?"] #=> ["config.h"] Dir.glob("config.?") #=> ["config.h"] Dir.glob("*.[a-z][a-z]") #=> ["main.rb"] Dir.glob("*.[^r]*") #=> ["config.h"] Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"] Dir.glob("*") #=> ["config.h", "main.rb"] Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"] Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"] rbfiles = File.join("**", "*.rb") Dir.glob(rbfiles) #=> ["main.rb", # "lib/song.rb", # "lib/song/karaoke.rb"] Dir.glob(rbfiles, base: "lib") #=> ["song.rb", # "song/karaoke.rb"] libdirs = File.join("**", "lib") Dir.glob(libdirs) #=> ["lib"] librbfiles = File.join("**", "lib", "**", "*.rb") Dir.glob(librbfiles) #=> ["lib/song.rb", # "lib/song/karaoke.rb"] librbfiles = File.join("**", "lib", "*.rb") Dir.glob(librbfiles) #=> ["lib/song.rb"] @overload glob( pattern, [flags], [base: path] ) @return [Array] @overload glob( pattern, [flags], [base: path] ) @yield [filename] @return [nil];T;0; @$;@F;Ao;B;CT;Di ;EiI ;!@;"I"Wstatic VALUE dir_s_glob(int argc, VALUE *argv, VALUE obj) { VALUE str, rflags, ary, opts, base; int flags; argc = rb_scan_args(argc, argv, "11:", &str, &rflags, &opts); if (argc == 2) flags = NUM2INT(rflags); else flags = 0; dir_glob_options(opts, &base, &flags); ary = rb_check_array_type(str); if (NIL_P(ary)) { ary = rb_push_glob(str, base, flags); } else { VALUE v = ary; ary = dir_globs(RARRAY_LEN(v), RARRAY_CONST_PTR(v), base, flags); RB_GC_GUARD(v); } if (rb_block_given_p()) { rb_ary_each(ary); return Qnil; } return ary; };T;#I"static VALUE;T;$To; ; F; ;;;;I" Dir.[];F;[[@0;[[@i ;T;;;0;[;{;IC;"VEquivalent to calling Dir.glob([string,...], 0). ;T;[o;H ;II" overload;F;J0;;;K0;#I"[]( string [, string ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ %;[;I"@return [Array];T;0; @ %;@F;Mi;N0;[[I"string[, string ...);T0; @ %;[;I"Equivalent to calling Dir.glob([string,...], 0). @overload []( string [, string ...) @return [Array];T;0; @ %;@F;Ao;B;CT;Di ;Ei ;!@;"I""static VALUE dir_s_aref(int argc, VALUE *argv, VALUE obj) { VALUE opts, base; argc = rb_scan_args(argc, argv, "*:", NULL, &opts); dir_glob_options(opts, &base, NULL); if (argc == 1) { return rb_push_glob(argv[0], base, 0); } return dir_globs(argc, argv, base, 0); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Dir.exist?;F;[;[[@i ;T;;s;0;[;{;IC;"^Returns true if the named file is a directory, false otherwise.;T;[o;H ;II" overload;F;J0;;s;K0;#I"exist?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @'%;[;I"@return [Boolean];T;0; @'%;@F;Mi;N0;[[I"file_name;T0; @'%;[;@;0; @'%;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I"(VALUE rb_file_directory_p(void) { };T;#I" VALUE;T;$To; ; F; ;;;;I"Dir.exists?;F;[[I" fname;T0;[[@i ;T;;t;0;[;{;IC;""Deprecated method. Don't use.;T;[o;H ;II" overload;F;J0;;t;K0;#I"exists?(file_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @C%;[;I"@return [Boolean];T;0; @C%;@F;Mi;N0;[[I"file_name;T0; @C%;[;I"UDeprecated method. Don't use. @overload exists?(file_name) @return [Boolean];T;0; @C%;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I"static VALUE rb_dir_exists_p(VALUE obj, VALUE fname) { rb_warning("Dir.exists? is a deprecated name, use Dir.exist? instead"); return rb_file_directory_p(obj, fname); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Dir.empty?;F;[[I" dirname;T0;[[@i ;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;H ;II" overload;F;J0;;;K0;#I"empty?(path_name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @b%;[;I"@return [Boolean];T;0; @b%;@F;Mi;N0;[[I"path_name;T0; @b%;[;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; @b%;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I"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;&@;'IC;[;&@;(IC;[@C;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iM ;F;:Dir;;0;;;[;{;IC;"Objects of class Dir are directory streams representing directories in the underlying file system. They provide a variety of ways to list directories and their contents. See also File. The directory used in these examples contains the two regular files (config.h and main.rb), the parent directory (..), and the directory itself (.). ;T;[;[;I"Objects of class Dir are directory streams representing directories in the underlying file system. They provide a variety of ways to list directories and their contents. See also File. The directory used in these examples contains the two regular files (config.h and main.rb), the parent directory (..), and the directory itself (.). ;T;0; @;@F;Ao;B;CT;Di? ;EiH ;!@;I"Dir;F;1@<@7o; ;IC;[;&@%;'IC;[;&@%;(IC;[;&@%;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@7i1;T;:ENV;;0;;;[;{;IC;";ENV is a hash-like accessor for environment variables. ;T;[;[;I"= ENV is a hash-like accessor for environment variables. ;T;0; @%;@F;Ao;B;CT;Di1;Ei3;!@;I"ENV;F;1o;2 ;30;40;50;;6;!@;7@<;F0o;9;[[I"version.c;Ti8;F;:RUBY_VERSION;;;;;;[;{;IC;" The running version of ruby ;T;[;[;I"!The running version of ruby ;T;0; @%;@F;Ao;B;CT;Di5;Ei6;!@;I"RUBY_VERSION;F;;!@;I"RUBY_PLATFORM;F;The version of the engine or interpreter this ruby uses. ;T;0; @%;@F;Ao;B;CT;DiS;EiT;!@;I"RUBY_ENGINE_VERSION;F;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;H ;II" overload;F;J0;;;K0;#I"call(args, ...);T;IC;";T;[;[;I";T;0; @&;@F;Mi;N0;[[I" args;T0[I"...;T0; @&o;H ;II" overload;F;J0;;;K0;#I"[](args, ...);T;IC;";T;[;[;I";T;0; @&;@F;Mi;N0;[[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;Ao;B;CT;Di1;Ei=;!@&;"I"'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.protect_tag != th->ec->protect_tag) { rb_raise(rb_eRuntimeError, "continuation called across stack rewinding barrier"); } 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); return Qnil; /* unreachable */ };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Continuation#[];F;[[@0;[[@iA;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;H ;II" overload;F;J0;;;K0;#I"call(args, ...);T;IC;";T;[;[;I";T;0; @<&;@F;Mi;N0;[[I" args;T0[I"...;T0; @<&o;H ;II" overload;F;J0;;;K0;#I"[](args, ...);T;IC;";T;[;[;I";T;0; @<&;@F;Mi;N0;[[I" args;T0[I"...;T0; @<&;[;@8&;0; @<&;@F;Ao;B;CT;Di1;Ei=;!@&;"I"'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.protect_tag != th->ec->protect_tag) { rb_raise(rb_eRuntimeError, "continuation called across stack rewinding barrier"); } 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); return Qnil; /* unreachable */ };T;#I"static VALUE;T;$T;&@&;'IC;[;&@&;(IC;[;&@&;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iy[@i[;T;:Continuation;;0;;;[;{;IC;"IContinuation 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 "\n#{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"K 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 "\n#{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;Ao;B;CT;Diy;Ei;Mi;!@;I"Continuation;F;1@resume is called next. Any arguments passed to the next resume will be the value that this Fiber.yield expression evaluates to. ;T;[o;H ;II" overload;F;J0;;;K0;#I"yield(args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @v&;[;I"@return [Object];T;0; @v&;@F;Mi;N0;[[I" args;T0[I"...;T0; @v&;[;I"yYields 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; @v&;@F;Ao;B;CT;Di;Ei;!@t&;"I"qstatic VALUE rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass) { return rb_fiber_yield(argc, argv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiber#initialize;F;[;[[@i;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @&;@F;Ao;B;CT;Di;Ei;!@t&;"I"astatic VALUE rb_fiber_init(VALUE fibval) { return fiber_init(fibval, rb_block_proc()); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiber#resume;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"resume(args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @&;[;I"@return [Object];T;0; @&;@F;Mi;N0;[[I" args;T0[I"...;T0; @&;[;I"qResumes 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;Ao;B;CT;Di;Ei;!@t&;"I"vstatic VALUE rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib) { return rb_fiber_resume(fib, argc, argv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiber#to_s;F;[;[[@i;T;;h;0;[;{;IC;"&Returns fiber information string. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[; @&;[;I"KReturns fiber information string. @overload to_s @return [String];T;0; o; ; F; ;,;;;I"Fiber#inspect;F;[;[[@iS;F;;i;;0;[;{;@&;!@t&;"I"static VALUE fiber_to_s(VALUE fibval) { const rb_fiber_t *fib = fiber_ptr(fibval); const rb_proc_t *proc; char status_info[0x10]; snprintf(status_info, 0x10, " (%s)", fiber_status_name(fib->status)); if (!rb_obj_is_proc(fib->first_proc)) { VALUE str = rb_any_to_s(fibval); 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(fib->first_proc, proc); return rb_block_to_s(fibval, &proc->block, status_info); };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei ;!@t&;"I"static VALUE fiber_to_s(VALUE fibval) { const rb_fiber_t *fib = fiber_ptr(fibval); const rb_proc_t *proc; char status_info[0x10]; snprintf(status_info, 0x10, " (%s)", fiber_status_name(fib->status)); if (!rb_obj_is_proc(fib->first_proc)) { VALUE str = rb_any_to_s(fibval); 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(fib->first_proc, proc); return rb_block_to_s(fibval, &proc->block, status_info); };T;#@&;$T@&o; ; F; ;,;;;I"Fiber#transfer;F;[[@0;[[@i;T;: transfer;0;[;{;IC;"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. You need to require 'fiber' before using this method. The fiber which receives the transfer call is treats it much like a resume call. Arguments passed to transfer are treated like those passed to resume. You cannot resume a fiber that transferred control to another one. This will cause a double resume error. You need to transfer control back to this fiber before it can yield and resume. Example: fiber1 = Fiber.new do puts "In Fiber 1" Fiber.yield end fiber2 = Fiber.new do puts "In Fiber 2" fiber1.transfer puts "Never see this message" end fiber3 = Fiber.new do puts "In Fiber 3" end fiber2.resume fiber3.resume produces In fiber 2 In fiber 1 In fiber 3 ;T;[o;H ;II" overload;F;J0;;*;K0;#I"transfer(args, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @&;[;I"@return [Object];T;0; @&;@F;Mi;N0;[[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. You need to require 'fiber' before using this method. The fiber which receives the transfer call is treats it much like a resume call. Arguments passed to transfer are treated like those passed to resume. You cannot resume a fiber that transferred control to another one. This will cause a double resume error. You need to transfer control back to this fiber before it can yield and resume. Example: fiber1 = Fiber.new do puts "In Fiber 1" Fiber.yield end fiber2 = Fiber.new do puts "In Fiber 2" fiber1.transfer puts "Never see this message" end fiber3 = Fiber.new do puts "In Fiber 3" end fiber2.resume fiber3.resume produces In fiber 2 In fiber 1 In fiber 3 @overload transfer(args, ...) @return [Object];T;0; @&;@F;Ao;B;CT;Di;Ei;!@t&;"I"static VALUE rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fibval) { rb_fiber_t *fib = fiber_ptr(fibval); fib->transferred = 1; return fiber_switch(fib, argc, argv, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiber#alive?;F;[;[[@i;T;;:;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. You need to require 'fiber' before using this method.;T;[o;H ;II" overload;F;J0;;:;K0;#I" alive?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @';[;I"@return [Boolean];T;0; @';@F;Mi;N0;[; @';[;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. You need to require 'fiber' before using this method. @overload alive? @return [Boolean];T;0; @';@F;Ao;B;CT;Di;Ei;Mi;!@t&;"I"pVALUE rb_fiber_alive_p(VALUE fibval) { return FIBER_TERMINATED_P(fiber_ptr(fibval)) ? Qfalse : Qtrue; };T;#I" VALUE;T;$To; ; F; ;;;;I"Fiber.current;F;[;[[@i;T;;";0;[;{;IC;"Returns the current fiber. You need to require 'fiber' before using this method. If you are not running in the context of a fiber this method will return the root fiber. ;T;[o;H ;II" overload;F;J0;;";K0;#I"current();T;IC;";T;[;[;I";T;0; @"';@F;Mi;N0;[; @"';[;I"Returns the current fiber. You need to require 'fiber' before using this method. If you are not running in the context of a fiber this method will return the root fiber. @overload current();T;0; @"';@F;Ao;B;CT;Di;Ei;!@t&;"I"Tstatic VALUE rb_fiber_s_current(VALUE klass) { return rb_fiber_current(); };T;#I"static VALUE;T;$T;&@t&;'IC;[;&@t&;(IC;[;&@t&;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@&;h;.[;[[@i_[@iL;T;: Fiber;;0;;;[;{;IC;"lFibers 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 14 puts fiber.resume 18 produces 12 14 FiberError: dead fiber called;T;[;[;I"o 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 14 puts fiber.resume 18 produces 12 14 FiberError: dead fiber called ;T;0; @t&;@F;Ao;B;CT;Di_;Ei;Mi;!@;I" Fiber;F;1@ 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; @J';@F;Ao;B;CT;Di/;Ei8;!@;I"FiberError;F;1o;2 ;30;40;50;;;!@;7@7;F;o; ;IC;[o; ; F; ;,;;;I"Warning#warn;F;[[I"str;T0;[[@i;T;;;0;[;{;IC;"eWrites warning message +msg+ to $stderr. This method is called by Ruby for all emitted warnings. ;T;[o;H ;II" overload;F;J0;;;K0;#I"warn(msg);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @a';[;I"@return [nil];T;0; @a';@F;Mi;N0;[[I"msg;T0; @a';[;I"Writes warning message +msg+ to $stderr. This method is called by Ruby for all emitted warnings. @overload warn(msg) @return [nil];T;0; @a';@F;Ao;B;CT;Di;Ei;!@_';"I"static VALUE rb_warning_s_warn(VALUE mod, VALUE str) { Check_Type(str, T_STRING); rb_must_asciicompat(str); rb_write_error_str(str); return Qnil; };T;#I"static VALUE;T;$To; ;IC;[o; ; F; ;,;;;I"Warning::buffer#write;F;[[@0;[[@i-;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @';@F;Ao;B;CT;Di,;Ei,;!@';"I"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;&@';'IC;[;&@';(IC;[;&@';)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i ;F;: buffer;;0;;;[;{;IC;" ;T;[;[;@;0; @';Mi;!@_';I"Warning::buffer;F;1@;&@_';'IC;[;&@_';(IC;[;&@_';)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;: Warning;;0;;;[;{;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. By overriding Warning.warn, you can change how warnings are handled by Ruby, either filtering some warnings, and/or outputting warnings somewhere other than $stderr. When Warning.warn is overridden, super can be called to get the default behavior of printing the warning to $stderr.;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. By overriding Warning.warn, you can change how warnings are handled by Ruby, either filtering some warnings, and/or outputting warnings somewhere other than $stderr. When Warning.warn is overridden, super can be called to get the default behavior of printing the warning to $stderr. ;T;0; @_';@F;Ao;B;CT;Di;Ei;Mi;!@;I" Warning;Fo; ;IC;[;&@';'IC;[;&@';(IC;[;&@';)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i@[@i ;T;: Errno;;0;;;[;{;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; @';@F;Ao;B;CT;Di@;Ei[;!@;I" Errno;F@7o; ;IC;[o; ; F; ;,;;;I"SystemExit#initialize;F;[[@0;[[@i3;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[;[;I";T;0; @';@F;Mi;N0;[; @'o;H ;II" overload;F;J0;; ;K0;#I"new(status);T;IC;";T;[;[;I";T;0; @';@F;Mi;N0;[[I" status;T0; @'o;H ;II" overload;F;J0;; ;K0;#I"new(status, msg);T;IC;";T;[;[;I";T;0; @';@F;Mi;N0;[[I" status;T0[I"msg;T0; @'o;H ;II" overload;F;J0;; ;K0;#I" new(msg);T;IC;";T;[;[;I";T;0; @';@F;Mi;N0;[[I"msg;T0; @';[;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; @';@F;Ao;B;CT;Di';Ei/;!@';"I"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; ; F; ;,;;;I"SystemExit#status;F;[;[[@ie;T;;5;0;[;{;IC;">Return the status value associated with this system exit. ;T;[o;H ;II" overload;F;J0;;5;K0;#I" status;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @';[;I"@return [Integer];T;0; @';@F;Mi;N0;[; @';[;I"eReturn the status value associated with this system exit. @overload status @return [Integer];T;0; @';@F;Ao;B;CT;Di^;Eib;!@';"I"Tstatic VALUE exit_status(VALUE exc) { return rb_attr_get(exc, id_status); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SystemExit#success?;F;[;[[@is;T;; ;0;[;{;IC;":Returns +true+ if exiting successful, +false+ if not.;T;[o;H ;II" overload;F;J0;; ;K0;#I" success?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @(;[;I"@return [Boolean];T;0; @(;@F;Mi;N0;[; @(;[;I"cReturns +true+ if exiting successful, +false+ if not. @overload success? @return [Boolean];T;0; @(;@F;Ao;B;CT;Dil;Eip;Mi;!@';"I" 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); if (WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$T;&@';'IC;[;&@';(IC;[;&@';)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@i ;T;:SystemExit;;0;;;[;{;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; @';@F;Ao;B;CT;Di ;Ei ;Mi;!@;I"SystemExit;F;1@Ko; ;IC;[o; ; F; ;,;;;I"SignalException#initialize;T;[[@0;[[@iP;T;;;0;[;{;IC;"XConstruct a new SignalException object. +sig_name+ should be a known signal name. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(sig_name);T;IC;";T;[;[;I";T;0; @I(;@F;Mi;N0;[[I" sig_name;T0; @I(o;H ;II" overload;F;J0;; ;K0;#I"new(sig_number [, name]);T;IC;";T;[;[;I";T;0; @I(;@F;Mi;N0;[[I"sig_number[, name];T0; @I(;[;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; @I(;@F;Ao;B;CT;DiG;EiL;!o;2 ;30;40;50;:SignalException;!@;7@G(;F0;"I"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; ; F; ;,;;;I"SignalException#signo;F;[;[[@i};T;: signo;0;[;{;IC;"Returns a signal number. ;T;[o;H ;II" overload;F;J0;;2;K0;#I" signo;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @m(;[;I"@return [Numeric];T;0; @m(;@F;Mi;N0;[; @m(;[;I"D Returns a signal number. @overload signo @return [Numeric];T;0; @m(;@F;Ao;B;CT;Div;Eiz;!@G(;"I"Wstatic VALUE esignal_signo(VALUE self) { return rb_ivar_get(self, id_signo); };T;#I"static VALUE;T;$T;&@G(;'IC;[;&@G(;(IC;[;&@G(;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;;1;;0;;;[;{;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; @G(;@F;Ao;B;CT;Di;Ei;Mi;!@;I"SignalException;F;1@Ko; ;IC;[o; ; F; ;,;;;I"Interrupt#initialize;F;[[@0;[[@i;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @(;@F;Ao;B;CT;Di;Ei;!@(;"I"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;&@(;'IC;[;&@(;(IC;[;&@(;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i"[@i ;T;:Interrupt;;0;;;[;{;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; @(;@F;Ao;B;CT;Di";Ei5;Mi;!@;I"Interrupt;F;1@G(o; ;IC;[;&@(;'IC;[;&@(;(IC;[;&@(;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i9[@i ;T;:TypeError;;0;;;[;{;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; @(;@F;Ao;B;CT;Di9;EiB;!@;I"TypeError;F;1@7@&@o; ;IC;[o; ; F; ;,;;;I"KeyError#initialize;F;[[@0;[[@i;T;;;0;[;{;IC;"SConstruct a new +KeyError+ exception with the given message, receiver and key. ;T;[o;H ;II" overload;F;J0;; ;K0;#I".new(message=nil, receiver: nil, key: nil);T;IC;";T;[;[;I";T;0; @(;@F;Mi;N0;[[I" message;TI"nil;T[I"receiver:;TI"nil;T[I" key:;TI"nil;T; @(;[;I"Construct a new +KeyError+ exception with the given message, receiver and key. @overload new(message=nil, receiver: nil, key: nil);T;0; @(;@F;Ao;B;CT;Di ;Ei;!@(;"I"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; ; F; ;,;;;I"KeyError#receiver;F;[;[[@i;T;;;0;[;{;IC;"AReturn the receiver associated with this KeyError exception. ;T;[o;H ;II" overload;F;J0;;;K0;#I" receiver;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @(;[;I"@return [Object];T;0; @(;@F;Mi;N0;[; @(;[;I"iReturn the receiver associated with this KeyError exception. @overload receiver @return [Object];T;0; @(;@F;Ao;B;CT;Di;Ei;!@(;"I"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; ; F; ;,;;;I"KeyError#key;F;[;[[@i;T;;;0;[;{;IC;"3Return the key caused this KeyError exception. ;T;[o;H ;II" overload;F;J0;;;K0;#I"key;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @);[;I"@return [Object];T;0; @);@F;Mi;N0;[; @);[;I"VReturn the key caused this KeyError exception. @overload key @return [Object];T;0; @);@F;Ao;B;CT;Di;Ei;!@(;"I"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;&@(;'IC;[;&@(;(IC;[;&@(;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ii[@i ;T;: KeyError;;0;;;[;{;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; @(;@F;Ao;B;CT;Dii;Eiq;Mi;!@;I" KeyError;F;1@@{o; ;IC;[;&@;);'IC;[;&@;);(IC;[;&@;);)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:ScriptError;;0;;;[;{;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; @;);@F;Ao;B;CT;Di;Ei;!@;I"ScriptError;F;1@Ko; ;IC;[o; ; F; ;,;;;I"SyntaxError#initialize;F;[[@0;[[@i4;T;;;0;[;{;IC;"'Construct a SyntaxError exception. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new([msg]);T;IC;";T;[;[;I";T;0; @Q);@F;Mi;N0;[[I" [msg];T0; @Q);[;I">Construct a SyntaxError exception. @overload new([msg]);T;0; @Q);@F;Ao;B;CT;Di-;Ei0;!@O);"I"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;&@O);'IC;[;&@O);(IC;[;&@O);)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:SyntaxError;;0;;;[;{;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; @O);@F;Ao;B;CT;Di;Ei;Mi;!@;I"SyntaxError;F;1@;)o; ;IC;[;&@|);'IC;[;&@|);(IC;[;&@|);)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:LoadError;;0;;;[;{;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; @|);@F;Ao;B;CT;Di;Ei;!@;I"LoadError;F;1@;)o; ;IC;[;&@);'IC;[;&@);(IC;[;&@);)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:NotImplementedError;;0;;;[;{;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; @);@F;Ao;B;CT;Di;Ei;!@;I"NotImplementedError;F;1@;)o; ;IC;[ o; ;IC;[ o; ; F; ;,;;;I"NameError::message#==;F;[[I" obj2;T0;[[@iO;T;;S;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @);@F;Ao;B;CT;DiN;EiN;!@);"I"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 65) { d = rb_any_to_s(obj); } singleton = (RSTRING_LEN(d) > 0 && RSTRING_PTR(d)[0] == '#'); d = QUOTE(d); break; } if (!singleton) { s = FAKE_CSTR(&s_str, ":"); c = rb_class_name(CLASS_OF(obj)); } else { c = s = FAKE_CSTR(&s_str, ""); } args[0] = QUOTE(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; ; F; ;,;;;I"NameError::message#_dump;F;[[I" limit;T0;[[@i;T;;d;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @);@F;Ao;B;CT;Di;Ei;!@);"I"fstatic VALUE name_err_mesg_dump(VALUE obj, VALUE limit) { return name_err_mesg_to_str(obj); };T;#I"static VALUE;T;$To; ; F; ;;;;I"NameError::message._load;F;[[I"str;T0;[[@i;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @);@F;Ao;B;CT;Di;Ei;!@);"I"Pstatic VALUE name_err_mesg_load(VALUE klass, VALUE str) { return str; };T;#I"static VALUE;T;$T;&@);'IC;[;&@);(IC;[;&@);)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i( [@i ;T;;;;0;;;[;{;IC;" :nodoc:;T;[;[;I" :nodoc: ;T;0; @);@F;Ao;B;CT;Di( ;Ei) ;Mi;!o;2 ;30;40;50;:NameError;!@;7@);F0;I"NameError::message;F;1@S6o; ; F; ;,;;;I"NameError#initialize;F;[[@0;[[@i;T;;;0;[;{;IC;"Construct a new NameError exception. If given the name parameter may subsequently be examined using the NameError#name method. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(msg [, name]);T;IC;";T;[;[;I";T;0; @);@F;Mi;N0;[[I"msg[, name];T0; @)o;H ;II" overload;F;J0;; ;K0;#I"!new(msg [, name], receiver:);T;IC;";T;[;[;I";T;0; @);@F;Mi;N0;[[I"msg[, name];T0[I"receiver:;TI";T; @);[;I"Construct a new NameError exception. If given the name parameter may subsequently be examined using the NameError#name method. @overload new(msg [, name]) @overload new(msg [, name], receiver:);T;0; @);@F;Ao;B;CT;Di;Ei;!@);"I"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; ; F; ;,;;;I"NameError#name;F;[;[[@i;T;;>;0;[;{;IC;">Return the name associated with this NameError exception. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @*;[;I"@return [String, nil];T;0; @*;@F;Mi;N0;[; @*;[;I"gReturn the name associated with this NameError exception. @overload name @return [String, nil];T;0; @*;@F;Ao;B;CT;Di;Ei;!@);"I"Vstatic VALUE name_err_name(VALUE self) { return rb_attr_get(self, id_name); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NameError#receiver;F;[;[[@i;T;;;0;[;{;IC;"BReturn the receiver associated with this NameError exception. ;T;[o;H ;II" overload;F;J0;;;K0;#I" receiver;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;*;[;I"@return [Object];T;0; @;*;@F;Mi;N0;[; @;*;[;I"jReturn the receiver associated with this NameError exception. @overload receiver @return [Object];T;0; @;*;@F;Ao;B;CT;Di;Ei;!@);"I"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; ; F; ;,;;;I"NameError#local_variables;F;[;[[@i;T;;;0;[;{;IC;"uReturn a list of the local variable names defined where this NameError exception was raised. Internal use only. ;T;[o;H ;II" overload;F;J0;;;K0;#I"local_variables;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @V*;[;I"@return [Array];T;0; @V*;@F;Mi;N0;[; @V*;[;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; @V*;@F;Ao;B;CT;Di;Ei;!@);"I"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;&@);'IC;[;&@);(IC;[;&@);)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;;:;;0;;;[;{;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; @);@F;Ao;B;CT;Di;Ei;Mi;!@;I"NameError;F;1@7o; ;IC;[o; ; F; ;,;;;I"NoMethodError#initialize;F;[[@0;[[@i ;T;;;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. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"*new([msg, *, name [, args [, priv]]]);T;IC;";T;[;[;I";T;0; @*;@F;Mi;N0;[[I"%[msg, *, name [, args [, priv]]];T0; @*;[;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. @overload new([msg, *, name [, args [, priv]]]);T;0; @*;@F;Ao;B;CT;Di;Ei;!@*;"I"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(argc, argv); return nometh_err_init_attr(self, args, priv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"NoMethodError#args;F;[;[[@i;T;: args;0;[;{;IC;"NReturn the arguments passed in as the third parameter to the constructor. ;T;[o;H ;II" overload;F;J0;;;;K0;#I" args;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @*;[;I"@return [Object];T;0; @*;@F;Mi;N0;[; @*;[;I"rReturn the arguments passed in as the third parameter to the constructor. @overload args @return [Object];T;0; @*;@F;Ao;B;CT;Di;Ei;!@*;"I"Xstatic VALUE nometh_err_args(VALUE self) { return rb_attr_get(self, id_args); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" NoMethodError#private_call?;F;[;[[@i;T;:private_call?;0;[;{;IC;"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; @*;@F;Ao;B;CT;Di;Ei;Mi;!@;I"NoMethodError;F;1@)o; ;IC;[;&@*;'IC;[;&@*;(IC;[;&@*;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:FrozenError;;0;;;[;{;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; @*;@F;Ao;B;CT;Di;Ei;!@;I"FrozenError;F;1o; ;IC;[;&@*;'IC;[;&@*;(IC;[;&@*;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:RuntimeError;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"RuntimeError;F;1@7@*o; ;IC;[;&@+;'IC;[;&@+;(IC;[;&@+;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:SecurityError;;0;;;[;{;IC;"%Raised when attempting a potential unsafe operation, typically when the $SAFE level is raised above 0. foo = "bar" proc = Proc.new do $SAFE = 3 foo.untaint end proc.call raises the exception: SecurityError: Insecure: Insecure operation `untaint' at level 3 ;T;[;[;I"' Raised when attempting a potential unsafe operation, typically when the $SAFE level is raised above 0. foo = "bar" proc = Proc.new do $SAFE = 3 foo.untaint end proc.call raises the exception: SecurityError: Insecure: Insecure operation `untaint' at level 3 ;T;0; @+;@F;Ao;B;CT;Di;Ei;!@;I"SecurityError;F;1@Ko; ;IC;[;&@"+;'IC;[;&@"+;(IC;[;&@"+;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i ;T;:NoMemoryError;;0;;;[;{;IC;")Raised when memory allocation fails. ;T;[;[;I"+ Raised when memory allocation fails. ;T;0; @"+;@F;Ao;B;CT;Di;Ei ;!@;I"NoMemoryError;F;1@Ko; ;IC;[o; ; F; ;,;;;I"SystemCallError#initialize;F;[[@0;[[@i;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(msg, errno);T;IC;";T;[;[;I";T;0; @8+;@F;Mi;N0;[[I"msg;T0[I" errno;T0; @8+;[;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; @8+;@F;Ao;B;CT;Di;Ei;!@6+;"I"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); OBJ_INFECT(errmsg, mesg); } mesg = errmsg; rb_call_super(1, &mesg); rb_ivar_set(self, id_errno, error); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SystemCallError#errno;F;[;[[@i;T;: errno;0;[;{;IC;"0Return this SystemCallError's error number. ;T;[o;H ;II" overload;F;J0;;B;K0;#I" errno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @S+;[;I"@return [Integer];T;0; @S+;@F;Mi;N0;[; @S+;[;I"VReturn this SystemCallError's error number. @overload errno @return [Integer];T;0; @S+;@F;Ao;B;CT;Di;Ei;!@6+;"I"Vstatic VALUE syserr_errno(VALUE self) { return rb_attr_get(self, id_errno); };T;#I"static VALUE;T;$To; ; F; ;;;;I"SystemCallError.===;F;[[I"exc;T0;[[@i;T;;O;0;[;{;IC;"{Return +true+ if the receiver is a generic +SystemCallError+, or if the error numbers +self+ and _other_ are the same. ;T;[o;H ;II" overload;F;J0;;O;K0;#I"===(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n+;[;I"@return [Boolean];T;0; @n+;@F;Mi;N0;[[I" other;T0; @n+;[;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; @n+;@F;Ao;B;CT;Di;Ei;!@6+;"I"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); if (FIXNUM_P(num) ? num == e : rb_equal(num, e)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$T;&@6+;'IC;[;&@6+;(IC;[;&@6+;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@i ;T;:SystemCallError;;0;;;[;{;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; @6+;@F;Ao;B;CT;Di ;Ei ;Mi;!@;I"SystemCallError;F;1@7@o; ;IC;[;&@+;'IC;[;&@+;(IC;[;&@+;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i! [@i ;T;: fatal;;0;;;[;{;IC;"~fatal is an Exception that is raised when Ruby has encountered a fatal error and must exit. You are not able to rescue fatal. ;T;[;[;I" fatal is an Exception that is raised when Ruby has encountered a fatal error and must exit. You are not able to rescue fatal. ;T;0; @+;@F;Ao;B;CT;Di! ;Ei$ ;!@;I" fatal;F;1@K@Ko; ;IC;[o; ; F; ;,;;;I"Num2int#NUM2SHORT;F;[[I"num;T0;[[I"!ext/-test-/num2int/num2int.c;Ti;T;:NUM2SHORT;0;[;{;IC;" ;T;[;[;I";F;0; @+;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2SHORT;F;@+;@+;T;;E;0;@+;{;IC;" ;T;[;[;@;0; @+;Mi;!@+;"@+;#@+;$To; ; F; ;,;;;I"Num2int#NUM2USHORT;F;[[I"num;T0;[[@+i;T;:NUM2USHORT;0;[;{;IC;" ;T;[;[;I";F;0; @+;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2USHORT;F;@+;@+;T;;F;0;@+;{;IC;" ;T;[;[;@;0; @+;Mi;!@+;"@+;#@+;$To; ; F; ;,;;;I"Num2int#NUM2INT;F;[[I"num;T0;[[@+i;T;: NUM2INT;0;[;{;IC;" ;T;[;[;I";F;0; @+;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2INT;F;@+;@+;T;;G;0;@+;{;IC;" ;T;[;[;@;0; @+;Mi;!@+;"@+;#@+;$To; ; F; ;,;;;I"Num2int#NUM2UINT;F;[[I"num;T0;[[@+i ;T;: NUM2UINT;0;[;{;IC;" ;T;[;[;I";F;0; @+;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2UINT;F;@+;@+;T;;H;0;@+;{;IC;" ;T;[;[;@;0; @,;Mi;!@+;"@,;#@,;$To; ; F; ;,;;;I"Num2int#NUM2LONG;F;[[I"num;T0;[[@+i(;T;: NUM2LONG;0;[;{;IC;" ;T;[;[;I";F;0; @ ,;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2LONG;F;@ ,;@,;T;;I;0;@,;{;IC;" ;T;[;[;@;0; @,;Mi;!@+;"@,;#@,;$To; ; F; ;,;;;I"Num2int#NUM2ULONG;F;[[I"num;T0;[[@+i0;T;:NUM2ULONG;0;[;{;IC;" ;T;[;[;I";F;0; @,;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2ULONG;F;@!,;@$,;T;;J;0;@&,;{;IC;" ;T;[;[;@;0; @.,;Mi;!@+;"@,,;#@-,;$To; ; F; ;,;;;I"Num2int#NUM2LL;F;[[I"num;T0;[[@+i9;T;: NUM2LL;0;[;{;IC;" ;T;[;[;I";F;0; @4,;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2LL;F;@6,;@9,;T;;K;0;@;,;{;IC;" ;T;[;[;@;0; @C,;Mi;!@+;"@A,;#@B,;$To; ; F; ;,;;;I"Num2int#NUM2ULL;F;[[I"num;T0;[[@+iA;T;: NUM2ULL;0;[;{;IC;" ;T;[;[;I";F;0; @I,;@F;N0;!@+;"I"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; ; T; ;;;;I"Num2int.NUM2ULL;F;@K,;@N,;T;;L;0;@P,;{;IC;" ;T;[;[;@;0; @X,;Mi;!@+;"@V,;#@W,;$To; ; F; ;,;;;I"Num2int#FIX2SHORT;F;[[I"num;T0;[[@+iJ;T;:FIX2SHORT;0;[;{;IC;" ;T;[;[;I";F;0; @^,;@F;N0;!@+;"I"static VALUE test_fix2short(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%d", FIX2SHORT(num)); return rb_str_new_cstr(buf); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Num2int.FIX2SHORT;F;@`,;@c,;T;;M;0;@e,;{;IC;" ;T;[;[;@;0; @m,;Mi;!@+;"@k,;#@l,;$To; ; F; ;,;;;I"Num2int#FIX2INT;F;[[I"num;T0;[[@+iR;T;: FIX2INT;0;[;{;IC;" ;T;[;[;I";F;0; @s,;@F;N0;!@+;"I"static VALUE test_fix2int(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%d", FIX2INT(num)); return rb_str_new_cstr(buf); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Num2int.FIX2INT;F;@u,;@x,;T;;N;0;@z,;{;IC;" ;T;[;[;@;0; @,;Mi;!@+;"@,;#@,;$To; ; F; ;,;;;I"Num2int#FIX2UINT;F;[[I"num;T0;[[@+iZ;T;: FIX2UINT;0;[;{;IC;" ;T;[;[;I";F;0; @,;@F;N0;!@+;"I"static VALUE test_fix2uint(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%u", FIX2UINT(num)); return rb_str_new_cstr(buf); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Num2int.FIX2UINT;F;@,;@,;T;;O;0;@,;{;IC;" ;T;[;[;@;0; @,;Mi;!@+;"@,;#@,;$To; ; F; ;,;;;I"Num2int#FIX2LONG;F;[[I"num;T0;[[@+ib;T;: FIX2LONG;0;[;{;IC;" ;T;[;[;I";F;0; @,;@F;N0;!@+;"I"static VALUE test_fix2long(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%ld", FIX2LONG(num)); return rb_str_new_cstr(buf); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Num2int.FIX2LONG;F;@,;@,;T;;P;0;@,;{;IC;" ;T;[;[;@;0; @,;Mi;!@+;"@,;#@,;$To; ; F; ;,;;;I"Num2int#FIX2ULONG;F;[[I"num;T0;[[@+ij;T;:FIX2ULONG;0;[;{;IC;" ;T;[;[;I";F;0; @,;@F;N0;!@+;"I"static VALUE test_fix2ulong(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%lu", FIX2ULONG(num)); return rb_str_new_cstr(buf); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Num2int.FIX2ULONG;F;@,;@,;T;;Q;0;@,;{;IC;" ;T;[;[;@;0; @,;Mi;!@+;"@,;#@,;$T;&@+;'IC;[;&@+;(IC;[;&@+;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@+iu;F;: Num2int;;0;;;[;{;IC;" ;T;[;[;@;0; @+;!@;I" Num2int;Fo; ;IC;[;&@,;'IC;[;&@,;(IC;[;&@,;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"-ext/-test-/memory_status/memory_status.c;Ti@;F;: Memory;;0;;;[;{;IC;" ;T;[;[;@;0; @,;!@;I" Memory;Fo; ;IC;[8o; ; F; ;;;;I"GDBM.open;F;[[@0;[[I"ext/gdbm/gdbm.c;Ti+;T;;;0;[;{;IC;"If called without a block, this is synonymous to GDBM::new. If a block is given, the new GDBM instance will be passed to the block as a parameter, and the corresponding database file will be closed after the execution of the block code has been finished. Example for an open call with a block: require 'gdbm' GDBM.open("fruitstore.db") do |gdbm| gdbm.each_pair do |key, value| print "#{key}: #{value}\n" end end ;T;[o;H ;II" overload;F;J0;;;K0;#I"-open(filename, mode = 0666, flags = nil);T;IC;";T;[;[;I";T;0; @,;@F;Mi;N0;[[I" filename;T0[I" mode;TI" 0666;T[I" flags;TI"nil;T; @,o;H ;II" overload;F;J0;;;K0;#I"-open(filename, mode = 0666, flags = nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" gdbm;T; @,;[;I"@yield [gdbm];T;0; @,;@F;Mi;N0;[[I" filename;T0[I" mode;TI" 0666;T[I" flags;TI"nil;T; @,;[;I")If called without a block, this is synonymous to GDBM::new. If a block is given, the new GDBM instance will be passed to the block as a parameter, and the corresponding database file will be closed after the execution of the block code has been finished. Example for an open call with a block: require 'gdbm' GDBM.open("fruitstore.db") do |gdbm| gdbm.each_pair do |key, value| print "#{key}: #{value}\n" end end @overload open(filename, mode = 0666, flags = nil) @overload open(filename, mode = 0666, flags = nil) @yield [gdbm];T;0; @,;@F;Ao;B;CT;Di;Ei);!@,;"I"(static VALUE fgdbm_s_open(int argc, VALUE *argv, VALUE klass) { VALUE obj = fgdbm_s_alloc(klass); if (NIL_P(fgdbm_initialize(argc, argv, obj))) { return Qnil; } if (rb_block_given_p()) { return rb_ensure(rb_yield, obj, fgdbm_close, obj); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#initialize;F;[[@0;[[@,i;T;;;0;[;{;IC;"Creates a new GDBM instance by opening a gdbm file named _filename_. If the file does not exist, a new file with file mode _mode_ will be created. _flags_ may be one of the following: * *READER* - open as a reader * *WRITER* - open as a writer * *WRCREAT* - open as a writer; if the database does not exist, create a new one * *NEWDB* - open as a writer; overwrite any existing databases The values *WRITER*, *WRCREAT* and *NEWDB* may be combined with the following values by bitwise or: * *SYNC* - cause all database operations to be synchronized to the disk * *NOLOCK* - do not lock the database file If no _flags_ are specified, the GDBM object will try to open the database file as a writer and will create it if it does not already exist (cf. flag WRCREAT). If this fails (for instance, if another process has already opened the database as a reader), it will try to open the database file as a reader (cf. flag READER). ;T;[o;H ;II" overload;F;J0;; ;K0;#I",new(filename, mode = 0666, flags = nil);T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[[I" filename;T0[I" mode;TI" 0666;T[I" flags;TI"nil;T; @-;[;I"Creates a new GDBM instance by opening a gdbm file named _filename_. If the file does not exist, a new file with file mode _mode_ will be created. _flags_ may be one of the following: * *READER* - open as a reader * *WRITER* - open as a writer * *WRCREAT* - open as a writer; if the database does not exist, create a new one * *NEWDB* - open as a writer; overwrite any existing databases The values *WRITER*, *WRCREAT* and *NEWDB* may be combined with the following values by bitwise or: * *SYNC* - cause all database operations to be synchronized to the disk * *NOLOCK* - do not lock the database file If no _flags_ are specified, the GDBM object will try to open the database file as a writer and will create it if it does not already exist (cf. flag WRCREAT). If this fails (for instance, if another process has already opened the database as a reader), it will try to open the database file as a reader (cf. flag READER). @overload new(filename, mode = 0666, flags = nil);T;0; @-;@F;Ao;B;CT;Di;Ei;!@,;"I"\static VALUE fgdbm_initialize(int argc, VALUE *argv, VALUE obj) { VALUE file, vmode, vflags; GDBM_FILE dbm; struct dbmdata *dbmp; int mode, flags = 0; TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp); if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) { mode = 0666; /* default value */ } else if (NIL_P(vmode)) { mode = -1; /* return nil if DB does not exist */ } else { mode = NUM2INT(vmode); } if (!NIL_P(vflags)) flags = NUM2INT(vflags); FilePathValue(file); #ifdef GDBM_CLOEXEC /* GDBM_CLOEXEC is available since gdbm 1.10. */ flags |= GDBM_CLOEXEC; #endif if (flags & RUBY_GDBM_RW_BIT) { flags &= ~RUBY_GDBM_RW_BIT; dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, flags, mode, MY_FATAL_FUNC); } else { dbm = 0; if (mode >= 0) dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, GDBM_WRCREAT|flags, mode, MY_FATAL_FUNC); if (!dbm) dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, GDBM_WRITER|flags, 0, MY_FATAL_FUNC); if (!dbm) dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, GDBM_READER|flags, 0, MY_FATAL_FUNC); } if (dbm) { rb_fd_fix_cloexec(gdbm_fdesc(dbm)); } if (!dbm) { if (mode == -1) return Qnil; if (gdbm_errno == GDBM_FILE_OPEN_ERROR || gdbm_errno == GDBM_CANT_BE_READER || gdbm_errno == GDBM_CANT_BE_WRITER) rb_sys_fail_str(file); else rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm); dbmp->di_dbm = dbm; dbmp->di_size = -1; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#close;F;[;[[@,i;T;;;0;[;{;IC;")Closes the associated database file. ;T;[o;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @>-;[;I"@return [nil];T;0; @>-;@F;Mi;N0;[; @>-;[;I"KCloses the associated database file. @overload close @return [nil];T;0; @>-;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_close(VALUE obj) { struct dbmdata *dbmp; GetDBM(obj, dbmp); gdbm_close(dbmp->di_dbm); dbmp->di_dbm = 0; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#closed?;F;[;[[@,i;T;;;0;[;{;IC;"BReturns true if the associated database file has been closed.;T;[o;H ;II" overload;F;J0;;;K0;#I" closed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Y-;[;I"@return [Boolean];T;0; @Y-;@F;Mi;N0;[; @Y-;[;I"jReturns true if the associated database file has been closed. @overload closed? @return [Boolean];T;0; @Y-;@F;Ao;B;CT;Di;Ei;Mi;!@,;"I"static VALUE fgdbm_closed(VALUE obj) { struct dbmdata *dbmp; TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp); if (dbmp->di_dbm == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" GDBM#[];F;[[I" keystr;T0;[[@,i;T;;;0;[;{;IC;"2Retrieves the _value_ corresponding to _key_. ;T;[o;H ;II" overload;F;J0;;;K0;#I" [](key);T;IC;";T;[;[;I";T;0; @t-;@F;Mi;N0;[[I"key;T0; @t-;[;I"FRetrieves the _value_ corresponding to _key_. @overload [](key);T;0; @t-;@F;Ao;B;CT;Di;Ei;!@,;"I"astatic VALUE fgdbm_aref(VALUE obj, VALUE keystr) { return rb_gdbm_fetch3(obj, keystr); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#fetch;F;[[@0;[[@,i;T;;;0;[;{;IC;"}Retrieves the _value_ corresponding to _key_. If there is no value associated with _key_, _default_ will be returned instead. ;T;[o;H ;II" overload;F;J0;;;K0;#I"fetch(key [, default]);T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[[I"key[, default];T0; @-;[;I"Retrieves the _value_ corresponding to _key_. If there is no value associated with _key_, _default_ will be returned instead. @overload fetch(key [, default]);T;0; @-;@F;Ao;B;CT;Di;Ei;!@,;"I"Jstatic VALUE fgdbm_fetch_m(int argc, VALUE *argv, VALUE obj) { VALUE keystr, valstr, ifnone; rb_scan_args(argc, argv, "11", &keystr, &ifnone); valstr = fgdbm_fetch(obj, keystr, ifnone); if (argc == 1 && !rb_block_given_p() && NIL_P(valstr)) rb_raise(rb_eIndexError, "key not found"); return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" GDBM#[]=;F;[[I" keystr;T0[I" valstr;T0;[[@,i;T;;+;0;[;{;IC;";Associates the value _value_ with the specified _key_. ;T;[o;H ;II" overload;F;J0;;+;K0;#I" []=(key);T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[[I"key;T0; @-o;H ;II" overload;F;J0;;;K0;#I"store(key, value);T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[[I"key;T0[I" value;T0; @-;[;I"lAssociates the value _value_ with the specified _key_. @overload []=(key) @overload store(key, value);T;0; @-;@F;Ao;B;CT;Di;Ei;!@,;"I"gstatic VALUE fgdbm_store(VALUE obj, VALUE keystr, VALUE valstr) { datum key, val; struct dbmdata *dbmp; GDBM_FILE dbm; rb_gdbm_modify(obj); ExportStringValue(keystr); ExportStringValue(valstr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_LENINT(valstr); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; if (gdbm_store(dbm, key, val, GDBM_REPLACE)) { if (errno == EPERM) rb_sys_fail(0); rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#store;F;[[I" keystr;T0[I" valstr;T0;[[@,i;T;;;0;[;{;IC;";Associates the value _value_ with the specified _key_. ;T;[o;H ;II" overload;F;J0;;+;K0;#I" []=(key);T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[[I"key;T0; @-o;H ;II" overload;F;J0;;;K0;#I"store(key, value);T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[[I"key;T0[I" value;T0; @-;[;@-;0; @-;@F;Ao;B;CT;Di;Ei;!@,;"I"gstatic VALUE fgdbm_store(VALUE obj, VALUE keystr, VALUE valstr) { datum key, val; struct dbmdata *dbmp; GDBM_FILE dbm; rb_gdbm_modify(obj); ExportStringValue(keystr); ExportStringValue(valstr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_LENINT(valstr); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; if (gdbm_store(dbm, key, val, GDBM_REPLACE)) { if (errno == EPERM) rb_sys_fail(0); rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#index;F;[[I" value;T0;[[@,i;T;;1;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @-;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_index(VALUE obj, VALUE value) { rb_warn("GDBM#index is deprecated; use GDBM#key"); return fgdbm_key(obj, value); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" GDBM#key;F;[[I" valstr;T0;[[@,i;T;;;0;[;{;IC;"Returns the _key_ for a given _value_. If several keys may map to the same value, the key that is found first will be returned. ;T;[o;H ;II" overload;F;J0;;;K0;#I"key(value);T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[[I" value;T0; @.;[;I"Returns the _key_ for a given _value_. If several keys may map to the same value, the key that is found first will be returned. @overload key(value);T;0; @.;@F;Ao;B;CT;Di;Ei;!@,;"I"estatic VALUE fgdbm_key(VALUE obj, VALUE valstr) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, valstr2; ExportStringValue(valstr); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { valstr2 = rb_gdbm_fetch2(dbm, keystr); if (!NIL_P(valstr2) && (int)RSTRING_LEN(valstr) == (int)RSTRING_LEN(valstr2) && memcmp(RSTRING_PTR(valstr), RSTRING_PTR(valstr2), (int)RSTRING_LEN(valstr)) == 0) { return keystr; } } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#select;F;[;[[@,i;T;;;0;[;{;IC;"dReturns a new array of all key-value pairs of the database for which _block_ evaluates to true. ;T;[o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @ .o;L ;II" return;F;JI";T;0;K[I" Array;T; @ .;[;I"(@yield [key, value] @return [Array];T;0; @ .;@F;Mi;N0;[; @ .;[;I"Returns a new array of all key-value pairs of the database for which _block_ evaluates to true. @overload select @yield [key, value] @return [Array];T;0; @ .;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_select(VALUE obj) { VALUE new = rb_ary_new(); GDBM_FILE dbm; struct dbmdata *dbmp; VALUE keystr; GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr)); VALUE v = rb_yield(assoc); if (RTEST(v)) { rb_ary_push(new, assoc); } GetDBM2(obj, dbmp, dbm); } return new; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#values_at;F;[[@0;[[@,i;T;;;0;[;{;IC;"IReturns an array of the values associated with each specified _key_. ;T;[o;H ;II" overload;F;J0;;;K0;#I"values_at(key, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @A.;[;I"@return [Array];T;0; @A.;@F;Mi;N0;[[I"key;T0[I"...;T0; @A.;[;I"{Returns an array of the values associated with each specified _key_. @overload values_at(key, ...) @return [Array];T;0; @A.;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_values_at(int argc, VALUE *argv, VALUE obj) { VALUE new = rb_ary_new2(argc); int i; for (i=0; idi_size > 0) return INT2FIX(dbmp->di_size); for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) { nextkey = gdbm_nextkey(dbm, key); free(key.dptr); i++; } dbmp->di_size = i; return INT2FIX(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#size;F;[;[[@,i;T;;;0;[;{;IC;"di_size > 0) return INT2FIX(dbmp->di_size); for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) { nextkey = gdbm_nextkey(dbm, key); free(key.dptr); i++; } dbmp->di_size = i; return INT2FIX(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#empty?;F;[;[[@,i8;T;;;0;[;{;IC;"+Returns true if the database is empty.;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @.;[;I"@return [Boolean];T;0; @.;@F;Mi;N0;[; @.;[;I"RReturns true if the database is empty. @overload empty? @return [Boolean];T;0; @.;@F;Ao;B;CT;Di2;Ei6;Mi;!@,;"I"static VALUE fgdbm_empty_p(VALUE obj) { datum key; struct dbmdata *dbmp; GDBM_FILE dbm; GetDBM(obj, dbmp); if (dbmp->di_size < 0) { dbm = dbmp->di_dbm; key = gdbm_firstkey(dbm); if (key.dptr) { free(key.dptr); return Qfalse; } return Qtrue; } if (dbmp->di_size == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#each;F;[;[[@,i;T;;;0;[;{;IC;"sExecutes _block_ for each key in the database, passing the _key_ and the corresponding _value_ as a parameter. ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @.;[;I"@yield [key, value];T;0; @.;@F;Mi;N0;[; @.;[;I"Executes _block_ for each key in the database, passing the _key_ and the corresponding _value_ as a parameter. @overload each_pair @yield [key, value];T;0; @.;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_each_pair(VALUE obj) { GDBM_FILE dbm; struct dbmdata *dbmp; VALUE keystr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { rb_yield(rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr))); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#each_value;F;[;[[@,iV;T;;;0;[;{;IC;"eExecutes _block_ for each key in the database, passing the corresponding _value_ as a parameter. ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_value;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" value;T; @.;[;I"@yield [value];T;0; @.;@F;Mi;N0;[; @.;[;I"Executes _block_ for each key in the database, passing the corresponding _value_ as a parameter. @overload each_value @yield [value];T;0; @.;@F;Ao;B;CT;DiO;EiT;!@,;"I"}static VALUE fgdbm_each_value(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { rb_yield(rb_gdbm_fetch2(dbm, keystr)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#each_key;F;[;[[@,ip;T;;;0;[;{;IC;"UExecutes _block_ for each key in the database, passing the _key_ as a parameter. ;T;[o;H ;II" overload;F;J0;;;K0;#I" each_key;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @/;[;I"@yield [key];T;0; @/;@F;Mi;N0;[; @/;[;I"yExecutes _block_ for each key in the database, passing the _key_ as a parameter. @overload each_key @yield [key];T;0; @/;@F;Ao;B;CT;Dii;Ein;!@,;"I"fstatic VALUE fgdbm_each_key(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { rb_yield(keystr); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#each_pair;F;[;[[@,i;T;;;0;[;{;IC;"sExecutes _block_ for each key in the database, passing the _key_ and the corresponding _value_ as a parameter. ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @/;[;I"@yield [key, value];T;0; @/;@F;Mi;N0;[; @/;[;@.;0; @/;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_each_pair(VALUE obj) { GDBM_FILE dbm; struct dbmdata *dbmp; VALUE keystr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { rb_yield(rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr))); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#keys;F;[;[[@,i;T;;;0;[;{;IC;"3Returns an array of all keys of this database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" keys;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @8/;[;I"@return [Array];T;0; @8/;@F;Mi;N0;[; @8/;[;I"VReturns an array of all keys of this database. @overload keys @return [Array];T;0; @8/;@F;Ao;B;CT;Di;Ei;!@,;"I"Dstatic VALUE fgdbm_keys(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { rb_ary_push(ary, keystr); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#values;F;[;[[@,i;T;;;0;[;{;IC;"5Returns an array of all values of this database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @S/;[;I"@return [Array];T;0; @S/;@F;Mi;N0;[; @S/;[;I"ZReturns an array of all values of this database. @overload values @return [Array];T;0; @S/;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_values(VALUE obj) { datum key, nextkey; struct dbmdata *dbmp; GDBM_FILE dbm; VALUE valstr, ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) { nextkey = gdbm_nextkey(dbm, key); valstr = rb_gdbm_fetch(dbm, key); free(key.dptr); rb_ary_push(ary, valstr); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#shift;F;[;[[@,iJ;T;;;0;[;{;IC;"Removes a key-value-pair from this database and returns it as a two-item array [ _key_, _value_ ]. Returns nil if the database is empty. ;T;[o;H ;II" overload;F;J0;;;K0;#I" shift;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @n/;[;I"@return [nil];T;0; @n/;@F;Mi;N0;[; @n/;[;I"Removes a key-value-pair from this database and returns it as a two-item array [ _key_, _value_ ]. Returns nil if the database is empty. @overload shift @return [nil];T;0; @n/;@F;Ao;B;CT;DiC;EiH;!@,;"I"bstatic VALUE fgdbm_shift(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, valstr; rb_gdbm_modify(obj); GetDBM2(obj, dbmp, dbm); keystr = rb_gdbm_firstkey(dbm); if (NIL_P(keystr)) return Qnil; valstr = rb_gdbm_fetch2(dbm, keystr); rb_gdbm_delete(obj, keystr); return rb_assoc_new(keystr, valstr); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#delete;F;[[I" keystr;T0;[[@,i9;T;;p;0;[;{;IC;"Removes the key-value-pair with the specified _key_ from this database and returns the corresponding _value_. Returns nil if the database is empty. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @/;[;I"@return [nil];T;0; @/;@F;Mi;N0;[[I"key;T0; @/;[;I"Removes the key-value-pair with the specified _key_ from this database and returns the corresponding _value_. Returns nil if the database is empty. @overload delete(key) @return [nil];T;0; @/;@F;Ao;B;CT;Di2;Ei7;!@,;"I"static VALUE fgdbm_delete(VALUE obj, VALUE keystr) { VALUE valstr; valstr = fgdbm_fetch(obj, keystr, Qnil); rb_gdbm_delete(obj, keystr); return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#delete_if;F;[;[[@,ib;T;;;0;[;{;IC;"RDeletes every key-value pair from _gdbm_ for which _block_ evaluates to true. ;T;[o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @/;[;I"@yield [key, value];T;0; @/;@F;Mi;N0;[; @/o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @/;[;I"@yield [key, value];T;0; @/;@F;Mi;N0;[; @/;[;I"Deletes every key-value pair from _gdbm_ for which _block_ evaluates to true. @overload delete_if @yield [key, value] @overload reject! @yield [key, value];T;0; @/;@F;Ao;B;CT;Di[;Eia;!@,;"I"static VALUE fgdbm_delete_if(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, valstr; VALUE ret, ary = rb_ary_tmp_new(0); long i; int status = 0, n; rb_gdbm_modify(obj); GetDBM2(obj, dbmp, dbm); n = dbmp->di_size; dbmp->di_size = -1; for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { OBJ_FREEZE(keystr); valstr = rb_gdbm_fetch2(dbm, keystr); ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status); if (status != 0) break; if (RTEST(ret)) rb_ary_push(ary, keystr); GetDBM2(obj, dbmp, dbm); } for (i = 0; i < RARRAY_LEN(ary); i++) rb_gdbm_delete(obj, RARRAY_AREF(ary, i)); if (status) rb_jump_tag(status); if (n > 0) dbmp->di_size = n - (int)RARRAY_LEN(ary); rb_ary_clear(ary); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#reject!;F;[;[[@,ib;T;;;0;[;{;IC;"RDeletes every key-value pair from _gdbm_ for which _block_ evaluates to true. ;T;[o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @/;[;I"@yield [key, value];T;0; @/;@F;Mi;N0;[; @/o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @/;[;I"@yield [key, value];T;0; @/;@F;Mi;N0;[; @/;[;@/;0; @/;@F;Ao;B;CT;Di[;Eia;!@,;"I"static VALUE fgdbm_delete_if(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, valstr; VALUE ret, ary = rb_ary_tmp_new(0); long i; int status = 0, n; rb_gdbm_modify(obj); GetDBM2(obj, dbmp, dbm); n = dbmp->di_size; dbmp->di_size = -1; for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { OBJ_FREEZE(keystr); valstr = rb_gdbm_fetch2(dbm, keystr); ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status); if (status != 0) break; if (RTEST(ret)) rb_ary_push(ary, keystr); GetDBM2(obj, dbmp, dbm); } for (i = 0; i < RARRAY_LEN(ary); i++) rb_gdbm_delete(obj, RARRAY_AREF(ary, i)); if (status) rb_jump_tag(status); if (n > 0) dbmp->di_size = n - (int)RARRAY_LEN(ary); rb_ary_clear(ary); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#reject;F;[;[[@,i;T;;;0;[;{;IC;"Returns a hash copy of _gdbm_ where all key-value pairs from _gdbm_ for which _block_ evaluates to true are removed. See also: #delete_if ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @/o;L ;II" return;F;JI";T;0;K[I" Hash;T; @/;[;I"'@yield [key, value] @return [Hash];T;0; @/;@F;Mi;N0;[; @/;[;I"Returns a hash copy of _gdbm_ where all key-value pairs from _gdbm_ for which _block_ evaluates to true are removed. See also: #delete_if @overload reject @yield [key, value] @return [Hash];T;0; @/;@F;Ao;B;CT;Di;Ei;!@,;"I"_static VALUE fgdbm_reject(VALUE obj) { return rb_hash_delete_if(fgdbm_to_hash(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#clear;F;[;[[@,i;T;;3;0;[;{;IC;"3Removes all the key-value pairs within _gdbm_. ;T;[o;H ;II" overload;F;J0;;3;K0;#I" clear;T;IC;";T;[;[;I";T;0; @0;@F;Mi;N0;[; @0;[;I"ERemoves all the key-value pairs within _gdbm_. @overload clear;T;0; @0;@F;Ao;B;CT;Di;Ei;!@,;"I"cstatic VALUE fgdbm_clear(VALUE obj) { datum key, nextkey; struct dbmdata *dbmp; GDBM_FILE dbm; rb_gdbm_modify(obj); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; #if 0 while (key = gdbm_firstkey(dbm), key.dptr) { if (gdbm_delete(dbm, key)) { free(key.dptr); rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } free(key.dptr); } #else while (key = gdbm_firstkey(dbm), key.dptr) { for (; key.dptr; key = nextkey) { nextkey = gdbm_nextkey(dbm, key); if (gdbm_delete(dbm, key)) { free(key.dptr); if (nextkey.dptr) free(nextkey.dptr); rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } free(key.dptr); } } #endif dbmp->di_size = 0; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#invert;F;[;[[@,i;T;;;0;[;{;IC;"UReturns a hash created by using _gdbm_'s values as keys, and the keys as values. ;T;[o;H ;II" overload;F;J0;;;K0;#I" invert;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @20;[;I"@return [Hash];T;0; @20;@F;Mi;N0;[; @20;[;I"yReturns a hash created by using _gdbm_'s values as keys, and the keys as values. @overload invert @return [Hash];T;0; @20;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_invert(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, valstr; VALUE hash = rb_hash_new(); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { valstr = rb_gdbm_fetch2(dbm, keystr); rb_hash_aset(hash, valstr, keystr); } return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#update;F;[[I" other;T0;[[@,i;T;;;0;[;{;IC;"Adds the key-value pairs of _other_ to _gdbm_, overwriting entries with duplicate keys with those from _other_. _other_ must have an each_pair method. ;T;[o;H ;II" overload;F;J0;;;K0;#I"update(other);T;IC;";T;[;[;I";T;0; @M0;@F;Mi;N0;[[I" other;T0; @M0;[;I"Adds the key-value pairs of _other_ to _gdbm_, overwriting entries with duplicate keys with those from _other_. _other_ must have an each_pair method. @overload update(other);T;0; @M0;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_update(VALUE obj, VALUE other) { rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#replace;F;[[I" other;T0;[[@,i;T;;';0;[;{;IC;"oReplaces the content of _gdbm_ with the key-value pairs of _other_. _other_ must have an each_pair method. ;T;[o;H ;II" overload;F;J0;;';K0;#I"replace(other);T;IC;";T;[;[;I";T;0; @g0;@F;Mi;N0;[[I" other;T0; @g0;[;I"Replaces the content of _gdbm_ with the key-value pairs of _other_. _other_ must have an each_pair method. @overload replace(other);T;0; @g0;@F;Ao;B;CT;Di;Ei ;!@,;"I"static VALUE fgdbm_replace(VALUE obj, VALUE other) { fgdbm_clear(obj); rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#reorganize;F;[;[[@,i.;T;:reorganize;0;[;{;IC;"Reorganizes the database file. This operation removes reserved space of elements that have already been deleted. It is only useful after a lot of deletions in the database. ;T;[o;H ;II" overload;F;J0;;T;K0;#I"reorganize;T;IC;";T;[;[;I";T;0; @0;@F;Mi;N0;[; @0;[;I"Reorganizes the database file. This operation removes reserved space of elements that have already been deleted. It is only useful after a lot of deletions in the database. @overload reorganize;T;0; @0;@F;Ao;B;CT;Di&;Ei+;!@,;"I"static VALUE fgdbm_reorganize(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; rb_gdbm_modify(obj); GetDBM2(obj, dbmp, dbm); gdbm_reorganize(dbm); rb_fd_fix_cloexec(gdbm_fdesc(dbm)); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#sync;F;[;[[@,iE;T;;;0;[;{;IC;"FUnless the _gdbm_ object has been opened with the *SYNC* flag, it is not guaranteed that database modification operations are immediately applied to the database file. This method ensures that all recent modifications to the database are written to the file. Blocks until all writing operations to the disk have been finished. ;T;[o;H ;II" overload;F;J0;;;K0;#I" sync;T;IC;";T;[;[;I";T;0; @0;@F;Mi;N0;[; @0;[;I"WUnless the _gdbm_ object has been opened with the *SYNC* flag, it is not guaranteed that database modification operations are immediately applied to the database file. This method ensures that all recent modifications to the database are written to the file. Blocks until all writing operations to the disk have been finished. @overload sync;T;0; @0;@F;Ao;B;CT;Di;;EiB;!@,;"I"static VALUE fgdbm_sync(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; rb_gdbm_modify(obj); GetDBM2(obj, dbmp, dbm); gdbm_sync(dbm); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#cachesize=;F;[[I"val;T0;[[@,iW;T;:cachesize=;0;[;{;IC;":Sets the size of the internal bucket cache to _size_. ;T;[o;H ;II" overload;F;J0;;U;K0;#I"cachesize=(size);T;IC;";T;[;[;I";T;0; @0;@F;Mi;N0;[[I" size;T0; @0;[;I"WSets the size of the internal bucket cache to _size_. @overload cachesize=(size);T;0; @0;@F;Ao;B;CT;DiQ;EiT;!@,;"I"Sstatic VALUE fgdbm_set_cachesize(VALUE obj, VALUE val) { struct dbmdata *dbmp; GDBM_FILE dbm; int optval; GetDBM2(obj, dbmp, dbm); optval = FIX2INT(val); if (gdbm_setopt(dbm, GDBM_CACHESIZE, &optval, sizeof(optval)) == -1) { rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#fastmode=;F;[[I"val;T0;[[@,ip;T;:fastmode=;0;[;{;IC;"Turns the database's fast mode on or off. If fast mode is turned on, gdbm does not wait for writes to be flushed to the disk before continuing. This option is obsolete for gdbm >= 1.8 since fast mode is turned on by default. See also: #syncmode= ;T;[o;H ;II" overload;F;J0;;V;K0;#I"fastmode=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @0;[;I"@return [Boolean];T;0; @0;@F;Mi;N0;[[I" boolean;T0; @0;[;I")Turns the database's fast mode on or off. If fast mode is turned on, gdbm does not wait for writes to be flushed to the disk before continuing. This option is obsolete for gdbm >= 1.8 since fast mode is turned on by default. See also: #syncmode= @overload fastmode=(boolean) @return [Boolean];T;0; @0;@F;Ao;B;CT;Dif;Ein;!@,;"I"ostatic VALUE fgdbm_set_fastmode(VALUE obj, VALUE val) { struct dbmdata *dbmp; GDBM_FILE dbm; int optval; GetDBM2(obj, dbmp, dbm); optval = 0; if (RTEST(val)) optval = 1; if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) { rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#syncmode=;F;[[I"val;T0;[[@,i;T;:syncmode=;0;[;{;IC;"Turns the database's synchronization mode on or off. If the synchronization mode is turned on, the database's in-memory state will be synchronized to disk after every database modification operation. If the synchronization mode is turned off, GDBM does not wait for writes to be flushed to the disk before continuing. This option is only available for gdbm >= 1.8 where syncmode is turned off by default. See also: #fastmode= ;T;[o;H ;II" overload;F;J0;;W;K0;#I"syncmode=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @0;[;I"@return [Boolean];T;0; @0;@F;Mi;N0;[[I" boolean;T0; @0;[;I"Turns the database's synchronization mode on or off. If the synchronization mode is turned on, the database's in-memory state will be synchronized to disk after every database modification operation. If the synchronization mode is turned off, GDBM does not wait for writes to be flushed to the disk before continuing. This option is only available for gdbm >= 1.8 where syncmode is turned off by default. See also: #fastmode= @overload syncmode=(boolean) @return [Boolean];T;0; @0;@F;Ao;B;CT;Di;Ei;!@,;"I"static VALUE fgdbm_set_syncmode(VALUE obj, VALUE val) { #if !defined(GDBM_SYNCMODE) fgdbm_set_fastmode(obj, RTEST(val) ? Qfalse : Qtrue); return val; #else struct dbmdata *dbmp; GDBM_FILE dbm; int optval; GetDBM2(obj, dbmp, dbm); optval = 0; if (RTEST(val)) optval = 1; if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) { rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); } return val; #endif };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#include?;F;[[I" keystr;T0;[[@,i;T;;U;0;[;{;IC;"[Returns true if the given key _k_ exists within the database. Returns false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1o;H ;II" overload;F;J0;;;K0;#I"has_key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1o;H ;II" overload;F;J0;;;K0;#I"member?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1o;H ;II" overload;F;J0;;;K0;#I" key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1;[;I"Returns true if the given key _k_ exists within the database. Returns false otherwise. @overload include?(k) @return [Boolean] @overload has_key?(k) @return [Boolean] @overload member?(k) @return [Boolean] @overload key?(k) @return [Boolean];T;0; @1;@F;Ao;B;CT;Di;Ei;Mi;!@,;"I"static VALUE fgdbm_has_key(VALUE obj, VALUE keystr) { datum key; struct dbmdata *dbmp; GDBM_FILE dbm; long len; ExportStringValue(keystr); len = RSTRING_LENINT(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (int)len; GetDBM2(obj, dbmp, dbm); if (gdbm_exists(dbm, key)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#has_key?;F;[[I" keystr;T0;[[@,i;T;;;0;[;{;IC;"[Returns true if the given key _k_ exists within the database. Returns false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Q1;[;I"@return [Boolean];T;0; @Q1;@F;Mi;N0;[[I"k;T0; @Q1o;H ;II" overload;F;J0;;;K0;#I"has_key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Q1;[;I"@return [Boolean];T;0; @Q1;@F;Mi;N0;[[I"k;T0; @Q1o;H ;II" overload;F;J0;;;K0;#I"member?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Q1;[;I"@return [Boolean];T;0; @Q1;@F;Mi;N0;[[I"k;T0; @Q1o;H ;II" overload;F;J0;;;K0;#I" key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Q1;[;I"@return [Boolean];T;0; @Q1;@F;Mi;N0;[[I"k;T0; @Q1;[;@M1;0; @Q1;@F;Ao;B;CT;Di;Ei;Mi;!@,;"I"static VALUE fgdbm_has_key(VALUE obj, VALUE keystr) { datum key; struct dbmdata *dbmp; GDBM_FILE dbm; long len; ExportStringValue(keystr); len = RSTRING_LENINT(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (int)len; GetDBM2(obj, dbmp, dbm); if (gdbm_exists(dbm, key)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#member?;F;[[I" keystr;T0;[[@,i;T;;;0;[;{;IC;"[Returns true if the given key _k_ exists within the database. Returns false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1o;H ;II" overload;F;J0;;;K0;#I"has_key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1o;H ;II" overload;F;J0;;;K0;#I"member?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1o;H ;II" overload;F;J0;;;K0;#I" key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"k;T0; @1;[;@M1;0; @1;@F;Ao;B;CT;Di;Ei;Mi;!@,;"I"static VALUE fgdbm_has_key(VALUE obj, VALUE keystr) { datum key; struct dbmdata *dbmp; GDBM_FILE dbm; long len; ExportStringValue(keystr); len = RSTRING_LENINT(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (int)len; GetDBM2(obj, dbmp, dbm); if (gdbm_exists(dbm, key)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#has_value?;F;[[I" valstr;T0;[[@,i;T;;;0;[;{;IC;"]Returns true if the given value _v_ exists within the database. Returns false otherwise.;T;[o;H ;II" overload;F;J0;;;K0;#I"has_value?(v);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"v;T0; @1o;H ;II" overload;F;J0;;;K0;#I"value?(v);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @1;[;I"@return [Boolean];T;0; @1;@F;Mi;N0;[[I"v;T0; @1;[;I"Returns true if the given value _v_ exists within the database. Returns false otherwise. @overload has_value?(v) @return [Boolean] @overload value?(v) @return [Boolean];T;0; @1;@F;Ao;B;CT;Di;Ei;Mi;!@,;"I"mstatic VALUE fgdbm_has_value(VALUE obj, VALUE valstr) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, valstr2; ExportStringValue(valstr); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { valstr2 = rb_gdbm_fetch2(dbm, keystr); if (!NIL_P(valstr2) && (int)RSTRING_LEN(valstr) == (int)RSTRING_LEN(valstr2) && memcmp(RSTRING_PTR(valstr), RSTRING_PTR(valstr2), (int)RSTRING_LEN(valstr)) == 0) { return Qtrue; } } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#key?;F;[[I" keystr;T0;[[@,i;T;;;0;[;{;IC;"[Returns true if the given key _k_ exists within the database. Returns false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @2;[;I"@return [Boolean];T;0; @2;@F;Mi;N0;[[I"k;T0; @2o;H ;II" overload;F;J0;;;K0;#I"has_key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @2;[;I"@return [Boolean];T;0; @2;@F;Mi;N0;[[I"k;T0; @2o;H ;II" overload;F;J0;;;K0;#I"member?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @2;[;I"@return [Boolean];T;0; @2;@F;Mi;N0;[[I"k;T0; @2o;H ;II" overload;F;J0;;;K0;#I" key?(k);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @2;[;I"@return [Boolean];T;0; @2;@F;Mi;N0;[[I"k;T0; @2;[;@M1;0; @2;@F;Ao;B;CT;Di;Ei;Mi;!@,;"I"static VALUE fgdbm_has_key(VALUE obj, VALUE keystr) { datum key; struct dbmdata *dbmp; GDBM_FILE dbm; long len; ExportStringValue(keystr); len = RSTRING_LENINT(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (int)len; GetDBM2(obj, dbmp, dbm); if (gdbm_exists(dbm, key)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#value?;F;[[I" valstr;T0;[[@,i;T;;;0;[;{;IC;"]Returns true if the given value _v_ exists within the database. Returns false otherwise.;T;[o;H ;II" overload;F;J0;;;K0;#I"has_value?(v);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`2;[;I"@return [Boolean];T;0; @`2;@F;Mi;N0;[[I"v;T0; @`2o;H ;II" overload;F;J0;;;K0;#I"value?(v);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`2;[;I"@return [Boolean];T;0; @`2;@F;Mi;N0;[[I"v;T0; @`2;[;@2;0; @`2;@F;Ao;B;CT;Di;Ei;Mi;!@,;"I"mstatic VALUE fgdbm_has_value(VALUE obj, VALUE valstr) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, valstr2; ExportStringValue(valstr); GetDBM2(obj, dbmp, dbm); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { valstr2 = rb_gdbm_fetch2(dbm, keystr); if (!NIL_P(valstr2) && (int)RSTRING_LEN(valstr) == (int)RSTRING_LEN(valstr2) && memcmp(RSTRING_PTR(valstr), RSTRING_PTR(valstr2), (int)RSTRING_LEN(valstr)) == 0) { return Qtrue; } } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#to_a;F;[;[[@,i;T;;;0;[;{;IC;"GReturns an array of all key-value pairs contained in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @2;[;I"@return [Array];T;0; @2;@F;Mi;N0;[; @2;[;I"jReturns an array of all key-value pairs contained in the database. @overload to_a @return [Array];T;0; @2;@F;Ao;B;CT;Di;Ei;!@,;"I"ostatic VALUE fgdbm_to_a(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { rb_ary_push(ary, rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr))); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GDBM#to_hash;F;[;[[@,i;T;;;0;[;{;IC;"EReturns a hash of all key-value pairs contained in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @2;[;I"@return [Hash];T;0; @2;@F;Mi;N0;[; @2;[;I"jReturns a hash of all key-value pairs contained in the database. @overload to_hash @return [Hash];T;0; @2;@F;Ao;B;CT;Di;Ei;!@,;"I"jstatic VALUE fgdbm_to_hash(VALUE obj) { struct dbmdata *dbmp; GDBM_FILE dbm; VALUE keystr, hash; GetDBM2(obj, dbmp, dbm); hash = rb_hash_new(); for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr); keystr = rb_gdbm_nextkey(dbm, keystr)) { rb_hash_aset(hash, keystr, rb_gdbm_fetch2(dbm, keystr)); } return hash; };T;#I"static VALUE;T;$To;9;[[@,i;F;: READER;;;;;;[;{;IC;"open database as a reader ;T;[;[;I"open database as a reader;T;0; @2;@F;Ao;B;CT;Di;Ei;!@,;I"GDBM::READER;F;= 1.8 ;T;[;[;I"Cflag for #new and #open. this flag is obsolete for gdbm >= 1.8;T;0; @2;@F;Ao;B;CT;Di ;Ei ;!@,;I"GDBM::FAST;F;= 1.8 ;T;[;[;I"2flag for #new and #open. only for gdbm >= 1.8;T;0; @2;@F;Ao;B;CT;Di;Ei;!@,;I"GDBM::SYNC;F;[]. Furthermore, GDBM mixes in the Enumerable module, thus providing convenient methods such as #find, #collect, #map, etc. A process is allowed to open several different databases at the same time. A process can open a database as a "reader" or a "writer". Whereas a reader has only read-access to the database, a writer has read- and write-access. A database can be accessed either by any number of readers or by exactly one writer at the same time. == Examples 1. Opening/creating a database, and filling it with some entries: require 'gdbm' gdbm = GDBM.new("fruitstore.db") gdbm["ananas"] = "3" gdbm["banana"] = "8" gdbm["cranberry"] = "4909" gdbm.close 2. Reading out a database: require 'gdbm' gdbm = GDBM.new("fruitstore.db") gdbm.each_pair do |key, value| print "#{key}: #{value}\n" end gdbm.close produces banana: 8 ananas: 3 cranberry: 4909 == Links * http://www.gnu.org/software/gdbm/;T;[;[;I" == Summary Ruby extension for GNU dbm (gdbm) -- a simple database engine for storing key-value pairs on disk. == Description GNU dbm is a library for simple databases. A database is a file that stores key-value pairs. Gdbm allows the user to store, retrieve, and delete data by key. It furthermore allows a non-sorted traversal of all key-value pairs. A gdbm database thus provides the same functionality as a hash. As with objects of the Hash class, elements can be accessed with []. Furthermore, GDBM mixes in the Enumerable module, thus providing convenient methods such as #find, #collect, #map, etc. A process is allowed to open several different databases at the same time. A process can open a database as a "reader" or a "writer". Whereas a reader has only read-access to the database, a writer has read- and write-access. A database can be accessed either by any number of readers or by exactly one writer at the same time. == Examples 1. Opening/creating a database, and filling it with some entries: require 'gdbm' gdbm = GDBM.new("fruitstore.db") gdbm["ananas"] = "3" gdbm["banana"] = "8" gdbm["cranberry"] = "4909" gdbm.close 2. Reading out a database: require 'gdbm' gdbm = GDBM.new("fruitstore.db") gdbm.each_pair do |key, value| print "#{key}: #{value}\n" end gdbm.close produces banana: 8 ananas: 3 cranberry: 4909 == Links * http://www.gnu.org/software/gdbm/ ;T;0; @,;@F;Ao;B;CT;Di;EiL;Mi;!@;I" GDBM;F;1@ VpBaseFig()) m -= VpBaseFig(); GUARD_OBJ(pv, VpNewRbClass(m, (char *)pch, self)); m /= VpBaseFig(); if (m && pv->MaxPrec > m) { pv->MaxPrec = m+1; } return ToValue(pv); };T;#I"static VALUE;T;$To; ; F; ;;;;I"#BigDecimal.save_exception_mode;F;[;[[@;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;H ;II" overload;F;J0;;d;K0;#I"save_exception_mode;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @3;[;I"@yield [];T;0; @3;@F;Mi;N0;[; @3;[;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; @3;@F;Ao;B;CT;Di ;Ei ;!@W3;"I"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; ; F; ;;;;I""BigDecimal.save_rounding_mode;F;[;[[@;i ;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;H ;II" overload;F;J0;;e;K0;#I"save_rounding_mode;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @3;[;I"@yield [];T;0; @3;@F;Mi;N0;[; @3;[;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; @3;@F;Ao;B;CT;Di ;Ei ;!@W3;"I"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; ; F; ;;;;I"BigDecimal.save_limit;F;[;[[@;i ;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;H ;II" overload;F;J0;;f;K0;#I"save_limit;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @3;[;I"@yield [];T;0; @3;@F;Mi;N0;[; @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;Ao;B;CT;Di ;Ei ;!@W3;"I"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;9;[[@;i ;F;;^;;;;;;[;{;IC;"&The version of bigdecimal library ;T;[;[;I"'The version of bigdecimal library ;T;0; @3;@F;Ao;B;CT;Di ;Ei ;!@W3;I"BigDecimal::VERSION;F;= 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; @d4;@F;Ao;B;CT;Di: ;Ei; ;!@W3;I"BigDecimal::ROUND_HALF_UP;F;= 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; @p4;@F;Ao;B;CT;Di> ;Ei@ ;!@W3;I" BigDecimal::ROUND_HALF_DOWN;F; [9, 18] ;T;[o;H ;II" overload;F;J0;;};K0;#I" precs;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @5;[;I"@return [Array];T;0; @5;@F;Mi;N0;[; @5;[;I"Returns an Array of two Integer values. The first value is the current number of significant digits in the BigDecimal. The second value is the maximum number of significant digits for the BigDecimal. BigDecimal('5').precs #=> [9, 18] @overload precs @return [Array];T;0; @5;@F;Ao;B;CT;DiG;EiQ;!@W3;"I"static VALUE BigDecimal_prec(VALUE self) { ENTER(1); Real *p; VALUE obj; GUARD_OBJ(p, GetVpValue(self, 1)); obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()), INT2NUM(p->MaxPrec*VpBaseFig())); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#add;F;[[I"b;T0[I"n;T0;[[@;iY;T;;;0;[;{;IC;"call-seq: add(value, digits) Add the specified value. e.g. c = a.add(b,n) c = a + b 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" call-seq: add(value, digits) Add the specified value. e.g. c = a.add(b,n) c = a + b 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; @75;@F;Ao;B;CT;Di;Ei;!@W3;"I"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 ToValue(cv); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#sub;F;[[I"b;T0[I"n;T0;[[@;iw;T;;\;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; @I5;@F;Ao;B;CT;Dij;Eiv;!@W3;"I"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 ToValue(cv); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#mult;F;[[I"b;T0[I"n;T0;[[@;i;T;: mult;0;[;{;IC;"call-seq: mult(value, digits) Multiply by the specified value. e.g. c = a.mult(b,n) c = a * b 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" call-seq: mult(value, digits) Multiply by the specified value. e.g. c = a.mult(b,n) c = a * b 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; @[5;@F;Ao;B;CT;Di;Ei;!@W3;"I"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 ToValue(cv); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#div;F;[[@0;[[@;iO;T;;;0;[;{;IC;"call-seq: 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. 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, 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. 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; @m5;@F;Ao;B;CT;Di0;EiL;!@W3;"I"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; ; F; ;,;;;I"BigDecimal#hash;F;[;[[@;ih;T;;U;0;[;{;IC;"{Creates a hash for this BigDecimal. Two BigDecimals with equal sign, fractional part and exponent have the same hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[;[;I";T;0; @|5;@F;Mi;N0;[; @|5;[;I"Creates a hash for this BigDecimal. Two BigDecimals with equal sign, fractional part and exponent have the same hash. @overload hash;T;0; @|5;@F;Ao;B;CT;Di`;Eif;!@W3;"I"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(BDIGIT)*p->Prec); hash += p->exponent; } return ST2FIX(hash); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#to_s;F;[[@0;[[@;i;T;;h;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; @5;@F;Ao;B;CT;Di;Ei;!@W3;"I"]static 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); rb_check_safe_obj(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_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; ; F; ;,;;;I"BigDecimal#to_i;F;[;[[@;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;Ao;B;CT;Di;Ei;!@W3;"I" 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) * (BDIGIT_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; ; F; ;,;;;I"BigDecimal#to_int;F;[;[[@;i;T;;;0;[;{;IC;"eReturns the value as an Integer. If the BigDecimal is infinity or NaN, raises FloatDomainError. ;T;[;[;@5;0; @5;@F;Ao;B;CT;Di;Ei;!@W3;"I" 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) * (BDIGIT_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; ; F; ;,;;;I"BigDecimal#to_r;F;[;[[@;i:;T;;;0;[;{;IC;")Converts a BigDecimal to a Rational. ;T;[;[;I"*Converts a BigDecimal to a Rational. ;T;0; @5;@F;Ao;B;CT;Di8;Ei9;!@W3;"I"$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; ; F; ;,;;;I"BigDecimal#split;F;[;[[@;i;;T;;H;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;Ao;B;CT;Di#;Ei:;!@W3;"I"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, INT2NUM(e)); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#+;F;[[I"r;T0;[[@;i;T;;(;0;[;{;IC;"call-seq: add(value, digits) Add the specified value. e.g. c = a.add(b,n) c = a + b 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;[;[;@E5;0; @5;@F;Ao;B;CT;Di;Ei;!@W3;"I"2static 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, DBL_DIG+1, 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")); VpAddSub(c, a, b, 1); } else { GUARD_OBJ(c, VpCreateRbObject(mx * (VpBaseFig() + 1), "0")); if(!mx) { VpSetInf(c, VpGetSign(a)); } else { VpAddSub(c, a, b, 1); } } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#-;F;[[I"r;T0;[[@;i;T;;<;0;[;{;IC;"ea - b -> bigdecimal Subtract the specified value. e.g. c = a - b The precision of the result value depends on the type of +b+. If +b+ is a Float, the precision of the result is Float::DIG+1. If +b+ is a BigDecimal, the precision of the result is +b+'s precision of internal representation from platform. So, it's return value is platform dependent. ;T;[;[;I"ha - b -> bigdecimal Subtract the specified value. e.g. c = a - b The precision of the result value depends on the type of +b+. If +b+ is a Float, the precision of the result is Float::DIG+1. If +b+ is a BigDecimal, the precision of the result is +b+'s precision of internal representation from platform. So, it's return value is platform dependent. ;T;0; @5;@F;Ao;B;CT;Di;Ei;!@W3;"I"/static 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, DBL_DIG+1, 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")); VpAddSub(c, a, b, -1); } else { GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0")); if (!mx) { VpSetInf(c,VpGetSign(a)); } else { VpAddSub(c, a, b, -1); } } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#+@;F;[;[[@;i;T;;:;0;[;{;IC;"2Return self. +BigDecimal('5') #=> 0.5e1 ;T;[o;H ;II" overload;F;J0;;(;K0;#I"+big_decimal;T;IC;";T;[;[;I";T;0; @5;@F;Mi;N0;[; @5;[;I"KReturn self. +BigDecimal('5') #=> 0.5e1 @overload +big_decimal;T;0; @5;@F;Ao;B;CT;Di;Ei;!@W3;"I"Cstatic VALUE BigDecimal_uplus(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#-@;F;[;[[@;i;T;;;;0;[;{;IC;"AReturn the negation of self. -BigDecimal('5') #=> -0.5e1 ;T;[o;H ;II" overload;F;J0;;<;K0;#I"-big_decimal;T;IC;";T;[;[;I";T;0; @ 6;@F;Mi;N0;[; @ 6;[;I"ZReturn the negation of self. -BigDecimal('5') #=> -0.5e1 @overload -big_decimal;T;0; @ 6;@F;Ao;B;CT;Di;Ei;!@W3;"I"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")); VpAsgn(c, a, -1); return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#*;F;[[I"r;T0;[[@;i;T;;);0;[;{;IC;"call-seq: mult(value, digits) Multiply by the specified value. e.g. c = a.mult(b,n) c = a * b 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;[;[;@i5;0; @#6;@F;Ao;B;CT;Di;Ei;!@W3;"I"-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, DBL_DIG+1, 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")); VpMult(c, a, b); return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#/;F;[;[[@;i';T;;;0;[;{;IC;")For c = self/r: with round operation ;T;[;[;I")For c = self/r: with round operation;T;0; @26;@F;Ao;B;CT;Di);Ei);!@W3;"I"astatic 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(&c, &res, &div, self, r); 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], (BDIGIT)(VpBaseVal() * (BDIGIT_DBL)res->frac[0] / div->frac[0])); } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#quo;F;[;[[@;i';T;;;0;[;{;IC;")For c = self/r: with round operation ;T;[;[;@<6;0; @@6;@F;Ao;B;CT;Di);Ei);!@W3;"I"astatic 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(&c, &res, &div, self, r); 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], (BDIGIT)(VpBaseVal() * (BDIGIT_DBL)res->frac[0] / div->frac[0])); } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#%;F;[;[[@;i;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; @M6;@F;Ao;B;CT;Di;Ei;!@W3;"I"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 ToValue(mod); } return DoSomeOne(self, r, '%'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#modulo;F;[;[[@;i;T;;;0;[;{;IC;"&%: a%b = a - (a.to_f/b).floor * b ;T;[;[;@W6;0; @[6;@F;Ao;B;CT;Di;Ei;!@W3;"I"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 ToValue(mod); } return DoSomeOne(self, r, '%'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#remainder;F;[;[[@;i;T;;;0;[;{;IC;"remainder ;T;[;[;I"remainder;T;0; @h6;@F;Ao;B;CT;Di;Ei;!@W3;"I"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 ToValue(rv); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#divmod;F;[[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; @v6;@F;Ao;B;CT;Di;Ei;!@W3;"I"static 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(ToValue(div), ToValue(mod)); } return DoSomeOne(self,r,rb_intern("divmod")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#clone;F;[;[[@;i ;T;;X;0;[;{;IC;" ;T;[;[;@;0; @6;!@W3;"I"Astatic VALUE BigDecimal_clone(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#dup;F;[;[[@;i ;T;;Y;0;[;{;IC;" ;T;[;[;@;0; @6;!@W3;"I"Astatic VALUE BigDecimal_clone(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#to_f;F;[;[[@;i ;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;Ao;B;CT;Di;Ei ;!@W3;"I"'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; ; F; ;,;;;I"BigDecimal#abs;F;[;[[@;i;T;;;0;[;{;IC;"vReturns the absolute value, as a BigDecimal. BigDecimal('5').abs #=> 0.5e1 BigDecimal('-3').abs #=> 0.3e1 ;T;[o;H ;II" overload;F;J0;;;K0;#I"abs;T;IC;";T;[;[;I";T;0; @6;@F;Mi;N0;[; @6;[;I"Returns the absolute value, as a BigDecimal. BigDecimal('5').abs #=> 0.5e1 BigDecimal('-3').abs #=> 0.3e1 @overload abs;T;0; @6;@F;Ao;B;CT;Di;Ei;!@W3;"I"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")); VpAsgn(c, a, 1); VpChangeSign(c, 1); return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#sqrt;F;[[I" nFig;T0;[[@;i;T;;~;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;Ao;B;CT;Di;Ei;!@W3;"I"^static 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")); VpSqrt(c, a); return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#fix;F;[;[[@;i;T;:fix;0;[;{;IC;"Prec *(VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0")); VpActiveRound(c, a, VP_ROUND_DOWN, 0); /* 0: round off */ return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#round;F;[[@0;[[@;i;T;;E;0;[;{;IC;"ground(n, mode) Round to the nearest integer (by default), returning the result as a BigDecimal. BigDecimal('3.14159').round #=> 3 BigDecimal('8.7').round #=> 9 BigDecimal('-9.9').round #=> -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').round(3) #=> 3.142 BigDecimal('13345.234').round(-2) #=> 13300.0 The value of the optional mode argument can be used to determine how rounding is performed; see BigDecimal.mode. ;T;[;[;I"iround(n, mode) Round to the nearest integer (by default), returning the result as a BigDecimal. BigDecimal('3.14159').round #=> 3 BigDecimal('8.7').round #=> 9 BigDecimal('-9.9').round #=> -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').round(3) #=> 3.142 BigDecimal('13345.234').round(-2) #=> 13300.0 The value of the optional mode argument can be used to determine how rounding is performed; see BigDecimal.mode. ;T;0; @6;@F;Ao;B;CT;Di;Ei;!@W3;"I"static VALUE BigDecimal_round(int argc, VALUE *argv, VALUE self) { ENTER(5); Real *c, *a; int iLoc = 0; VALUE vLoc; VALUE vRound; size_t mx, pl; unsigned short sw = VpGetRoundMode(); switch (rb_scan_args(argc, argv, "02", &vLoc, &vRound)) { case 0: iLoc = 0; break; case 1: if (RB_TYPE_P(vLoc, T_HASH)) { sw = check_rounding_mode_option(vLoc); } else { iLoc = NUM2INT(vLoc); } 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")); VpSetPrecLimit(pl); VpActiveRound(c, a, sw, iLoc); if (argc == 0) { return BigDecimal_to_i(ToValue(c)); } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#frac;F;[;[[@;iR;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;Ao;B;CT;DiP;EiQ;!@W3;"I"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")); VpFrac(c, a); return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#floor;F;[[@0;[[@;iq;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;Ao;B;CT;Di`;Eip;!@W3;"I"ustatic 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")); 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(ToValue(c)); } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#ceil;F;[[@0;[[@;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; @ 7;@F;Ao;B;CT;Di;Ei;!@W3;"I"+static 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")); VpSetPrecLimit(pl); VpActiveRound(c, a, VP_ROUND_CEIL, iLoc); if (argc == 0) { return BigDecimal_to_i(ToValue(c)); } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#power;F;[[@0;[[@;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;Ao;B;CT;Di;Ei;!@W3;"I"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"); RB_GC_GUARD(y->obj); VpSetNaN(y); return ToValue(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; } exp = GetVpValueWithPrec(vexp, DBL_DIG+1, 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); 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; } 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"); 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 ToValue(y); } else if (is_zero(vexp)) { return ToValue(VpCreateRbObject(n, "1")); } else { return ToValue(VpCreateRbObject(n, "0")); } } if (is_zero(vexp)) { return ToValue(VpCreateRbObject(n, "1")); } 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 ToValue(VpCreateRbObject(n, "0")); } else { /* (-Infinity) ** (-odd_integer) -> -0 */ return ToValue(VpCreateRbObject(n, "-0")); } } else { /* (-Infinity) ** (-non_integer) -> -0 */ return ToValue(VpCreateRbObject(n, "-0")); } } else { return ToValue(VpCreateRbObject(n, "0")); } } else { y = VpCreateRbObject(n, "0"); 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 ToValue(y); } } if (exp != NULL) { return rmpd_power_by_big_decimal(x, exp, n); } else if (RB_TYPE_P(vexp, T_BIGNUM)) { VALUE abs_value = BigDecimal_abs(self); if (is_one(abs_value)) { return ToValue(VpCreateRbObject(n, "1")); } else if (RTEST(rb_funcall(abs_value, '<', 1, INT2FIX(1)))) { if (is_negative(vexp)) { y = VpCreateRbObject(n, "0"); if (is_even(vexp)) { VpSetInf(y, VpGetSign(x)); } else { VpSetInf(y, -VpGetSign(x)); } return ToValue(y); } else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) { return ToValue(VpCreateRbObject(n, "-0")); } else { return ToValue(VpCreateRbObject(n, "0")); } } else { if (is_positive(vexp)) { y = VpCreateRbObject(n, "0"); if (is_even(vexp)) { VpSetInf(y, VpGetSign(x)); } else { VpSetInf(y, -VpGetSign(x)); } return ToValue(y); } else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) { return ToValue(VpCreateRbObject(n, "-0")); } else { return ToValue(VpCreateRbObject(n, "0")); } } } 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")); } else { GUARD_OBJ(y, VpCreateRbObject(1, "0")); } VpPower(y, x, int_exp); if (!NIL_P(prec) && VpIsDef(y)) { VpMidRound(y, VpGetRoundMode(), n); } return ToValue(y); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#**;F;[[I"exp;T0;[[@;i ;T;;;0;[;{;IC;"GReturns the value raised to the power of n. See BigDecimal#power. ;T;[o;H ;II" overload;F;J0;;;K0;#I" **(n);T;IC;";T;[;[;I";T;0; @*7;@F;Mi;N0;[[I"n;T0; @*7;[;I"YReturns the value raised to the power of n. See BigDecimal#power. @overload **(n);T;0; @*7;@F;Ao;B;CT;Di ;Ei ;!@W3;"I"lstatic VALUE BigDecimal_power_op(VALUE self, VALUE exp) { return BigDecimal_power(1, &exp, self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#<=>;F;[[I"r;T0;[[@;iu;T;;V;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; @D7;@F;Ao;B;CT;Dir;Eit;!@W3;"I"bstatic VALUE BigDecimal_comp(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '*'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#==;F;[[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;[;[;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; @T7;@F;Ao;B;CT;Di{;Ei;!@W3;"I"`static VALUE BigDecimal_eq(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '='); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#===;F;[[I"r;T0;[[@;i;T;;O;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;[;[;@`7;0; @d7;@F;Ao;B;CT;Di{;Ei;!@W3;"I"`static VALUE BigDecimal_eq(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '='); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#eql?;F;[[I"r;T0;[[@;i;T;;R;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;L ;II" return;F;J@;0;K[@; @s7;[;@`7;0; @s7;@F;Ao;B;CT;Di{;Ei;Mi;!@W3;"I"`static VALUE BigDecimal_eq(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '='); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#<;F;[[I"r;T0;[[@;i;T;;;0;[;{;IC;"{a < b Returns true if a is less than b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce). ;T;[;[;I"}a < b Returns true if a is less than b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce). ;T;0; @7;@F;Ao;B;CT;Di;Ei;!@W3;"I"`static VALUE BigDecimal_lt(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '<'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#<=;F;[[I"r;T0;[[@;i;T;;;0;[;{;IC;"a <= b Returns true if a is less than or equal to b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce). ;T;[;[;I"a <= b Returns true if a is less than or equal to b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce). ;T;0; @7;@F;Ao;B;CT;Di;Ei;!@W3;"I"`static VALUE BigDecimal_le(VALUE self, VALUE r) { return BigDecimalCmp(self, r, 'L'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#>;F;[[I"r;T0;[[@;i;T;;;0;[;{;IC;"~a > b Returns true if a is greater than b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce). ;T;[;[;I"{a > b Returns true if a is greater than b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce). ;T;0; @7;@F;Ao;B;CT;Di;Ei;!@W3;"I"`static VALUE BigDecimal_gt(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '>'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#>=;F;[[I"r;T0;[[@;i;T;;;0;[;{;IC;"a >= b Returns true if a is greater than or equal to b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce) ;T;[;[;I"a >= b Returns true if a is greater than or equal to b. Values may be coerced to perform the comparison (see ==, BigDecimal#coerce) ;T;0; @7;@F;Ao;B;CT;Di;Ei;!@W3;"I"`static VALUE BigDecimal_ge(VALUE self, VALUE r) { return BigDecimalCmp(self, r, 'G'); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#zero?;F;[;[[@;ic;T;;;0;[;{;IC;"'Returns True if the value is zero.;T;[o;L ;II" return;F;J@;0;K[@; @7;[;I"'Returns True if the value is zero.;T;0; @7;@F;Ao;B;CT;Dib;Eib;Mi;!@W3;"I"}static VALUE BigDecimal_zero(VALUE self) { Real *a = GetVpValue(self, 1); return VpIsZero(a) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#nonzero?;F;[;[[@;ik;T;;;0;[;{;IC;":Returns self if the value is non-zero, nil otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @7;[;I":Returns self if the value is non-zero, nil otherwise.;T;0; @7;@F;Ao;B;CT;Dij;Eij;Mi;!@W3;"I"}static VALUE BigDecimal_nonzero(VALUE self) { Real *a = GetVpValue(self, 1); return VpIsZero(a) ? Qnil : self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#coerce;F;[[I" other;T0;[[@;ih;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; @7;@F;Ao;B;CT;DiZ;Eig;!@W3;"I"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, DBL_DIG+1, 1)); obj = rb_assoc_new(ToValue(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; ; F; ;,;;;I"BigDecimal#inspect;F;[;[[@;il;T;;i;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; @7;@F;Ao;B;CT;Dig;Eik;!@W3;"I"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; ; F; ;,;;;I"BigDecimal#exponent;F;[;[[@;i`;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;Ao;B;CT;Di[;Ei_;!@W3;"I"static VALUE BigDecimal_exponent(VALUE self) { ssize_t e = VpExponent10(GetVpValue(self, 1)); return INT2NUM(e); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#sign;F;[;[[@;i ;T;: sign;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;Ao;B;CT;Di ;Ei ;!@W3;"I"zstatic VALUE BigDecimal_sign(VALUE self) { /* sign */ int s = GetVpValue(self, 1)->sign; return INT2FIX(s); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#nan?;F;[;[[@;i;T;;;0;[;{;IC;"/Returns True if the value is Not a Number.;T;[o;L ;II" return;F;J@;0;K[@; @!8;[;I"/Returns True if the value is Not a Number.;T;0; @!8;@F;Ao;B;CT;Di;Ei;Mi;!@W3;"I"static VALUE BigDecimal_IsNaN(VALUE self) { Real *p = GetVpValue(self, 1); if (VpIsNaN(p)) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#infinite?;F;[;[[@;i;T;;;0;[;{;IC;"^Returns nil, -1, or +1 depending on whether the value is finite, -Infinity, or +Infinity.;T;[o;L ;II" return;F;J@;0;K[@; @28;[;I"_Returns nil, -1, or +1 depending on whether the value is finite, -Infinity, or +Infinity. ;T;0; @28;@F;Ao;B;CT;Di;Ei;Mi;!@W3;"I"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; ; F; ;,;;;I"BigDecimal#finite?;F;[;[[@;i;T;;;0;[;{;IC;"?Returns True if the value is finite (not NaN or infinite).;T;[o;L ;II" return;F;J@;0;K[@; @C8;[;I"?Returns True if the value is finite (not NaN or infinite).;T;0; @C8;@F;Ao;B;CT;Di;Ei;Mi;!@W3;"I"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; ; F; ;,;;;I"BigDecimal#truncate;F;[[@0;[[@;i5;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; @T8;@F;Ao;B;CT;Di";Ei4;!@W3;"I"Estatic 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")); VpSetPrecLimit(pl); VpActiveRound(c, a, VP_ROUND_DOWN, iLoc); /* 0: truncate */ if (argc == 0) { return BigDecimal_to_i(ToValue(c)); } return ToValue(c); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BigDecimal#_dump;F;[[@0;[[@;i;T;;d;0;[;{;IC;"Method used to provide marshalling support. inf = BigDecimal('Infinity') #=> Infinity BigDecimal._load(inf._dump) #=> Infinity See the Marshal module. ;T;[o;H ;II" overload;F;J0;;d;K0;#I" _dump;T;IC;";T;[;[;I";T;0; @c8;@F;Mi;N0;[; @c8;[;I"Method used to provide marshalling support. inf = BigDecimal('Infinity') #=> Infinity BigDecimal._load(inf._dump) #=> Infinity See the Marshal module. @overload _dump;T;0; @c8;@F;Ao;B;CT;Diy;Ei;!@W3;"I"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;&@W3;'IC;[;&@W3;(IC;[;&@W3;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@;iU [@;i ;T;;;;0;;;[;{;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 == 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 == 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; @W3;@F;Ao;B;CT;DiU ;Ei ;Mi;!@;I"BigDecimal;F;1@mo; ;IC;[o; ; F; ;;;;I"BigMath.exp;F;[[I"x;T0[I" vprec;T0;[[@;i1 ;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;Ao;B;CT;Di' ;Ei0 ;!@8;"I"W 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, DBL_DIG+1, 0); } break; case T_RATIONAL: vx = GetVpValueWithPrec(x, prec, 0); break; default: break; } if (infinite) { if (negative) { return ToValue(GetVpValueWithPrec(INT2FIX(0), prec, 1)); } else { Real* vy; vy = VpCreateRbObject(prec, "#0"); VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE); RB_GC_GUARD(vy->obj); return ToValue(vy); } } else if (nan) { Real* vy; vy = VpCreateRbObject(prec, "#0"); VpSetNaN(vy); RB_GC_GUARD(vy->obj); return ToValue(vy); } else if (vx == NULL) { cannot_be_coerced_into_BigDecimal(rb_eArgError, x); } x = vx->obj; n = prec + rmpd_double_figures(); negative = BIGDECIMAL_NEGATIVE_P(vx); if (negative) { VpSetSign(vx, 1); } one = ToValue(VpCreateRbObject(1, "1")); 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 < rmpd_double_figures()) { m = rmpd_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; ; F; ;;;;I"BigMath.log;F;[[I"x;T0[I" vprec;T0;[[@;i ;T;:log;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;Ao;B;CT;Di ;Ei ;!@8;"I" 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, DBL_DIG+1, 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"); RB_GC_GUARD(vy->obj); VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE); return ToValue(vy); } else if (nan) { Real* vy; vy = VpCreateRbObject(prec, "#0"); RB_GC_GUARD(vy->obj); VpSetNaN(vy); return ToValue(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 = ToValue(vx); RB_GC_GUARD(one) = ToValue(VpCreateRbObject(1, "1")); RB_GC_GUARD(two) = ToValue(VpCreateRbObject(1, "2")); n = prec + rmpd_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, ToValue(VpCreateRbObject(1, buf)), 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 < rmpd_double_figures()) { m = rmpd_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 = ToValue(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;;0;;;[;{;IC;" ;T;[;[;@;0; @8;Mi;!@;I" BigMath;Fo; ;IC;[0o; ; F; ;;;;I" DBM.open;F;[[@0;[[I"ext/dbm/dbm.c;Ti;T;;;0;[;{;IC;"ZOpen a dbm database and yields it if a block is given. See also DBM.new. ;T;[o;H ;II" overload;F;J0;;;K0;#I"$open(filename[, mode[, flags]]);T;IC;";T;[;[;I";T;0; @8;@F;Mi;N0;[[I"filename[, mode[, flags]];T0; @8o;H ;II" overload;F;J0;;;K0;#I"$open(filename[, mode[, flags]]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"dbm;T; @8;[;I"@yield [dbm];T;0; @8;@F;Mi;N0;[[I"filename[, mode[, flags]];T0; @8;[;I"Open a dbm database and yields it if a block is given. See also DBM.new. @overload open(filename[, mode[, flags]]) @overload open(filename[, mode[, flags]]) @yield [dbm];T;0; @8;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE fdbm_s_open(int argc, VALUE *argv, VALUE klass) { VALUE obj = fdbm_alloc(klass); if (NIL_P(fdbm_initialize(argc, argv, obj))) { return Qnil; } if (rb_block_given_p()) { return rb_ensure(rb_yield, obj, fdbm_close, obj); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#initialize;F;[[@0;[[@8i;T;;;0;[;{;IC;"{Open a dbm database with the specified name, which can include a directory path. Any file extensions needed will be supplied automatically by the dbm library. For example, Berkeley DB appends '.db', and GNU gdbm uses two physical files with extensions '.dir' and '.pag'. The mode should be an integer, as for Unix chmod. Flags should be one of READER, WRITER, WRCREAT or NEWDB. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"#new(filename[, mode[, flags]]);T;IC;";T;[;[;I";T;0; @8;@F;Mi;N0;[[I"filename[, mode[, flags]];T0; @8;[;I"Open a dbm database with the specified name, which can include a directory path. Any file extensions needed will be supplied automatically by the dbm library. For example, Berkeley DB appends '.db', and GNU gdbm uses two physical files with extensions '.dir' and '.pag'. The mode should be an integer, as for Unix chmod. Flags should be one of READER, WRITER, WRCREAT or NEWDB. @overload new(filename[, mode[, flags]]);T;0; @8;@F;Ao;B;CT;Di;Ei;!@8;"I"` static VALUE fdbm_initialize(int argc, VALUE *argv, VALUE obj) { VALUE file, vmode, vflags; DBM *dbm; struct dbmdata *dbmp; int mode, flags = 0; TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp); if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) { mode = 0666; /* default value */ } else if (NIL_P(vmode)) { mode = -1; /* return nil if DB not exist */ } else { mode = NUM2INT(vmode); } if (!NIL_P(vflags)) flags = NUM2INT(vflags); FilePathValue(file); /* * Note: * gdbm 1.10 works with O_CLOEXEC. gdbm 1.9.1 silently ignore it. */ #ifndef O_CLOEXEC # define O_CLOEXEC 0 #endif if (flags & RUBY_DBM_RW_BIT) { flags &= ~RUBY_DBM_RW_BIT; dbm = dbm_open(RSTRING_PTR(file), flags|O_CLOEXEC, mode); } else { dbm = 0; if (mode >= 0) { dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT|O_CLOEXEC, mode); } if (!dbm) { dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CLOEXEC, 0); } if (!dbm) { dbm = dbm_open(RSTRING_PTR(file), O_RDONLY|O_CLOEXEC, 0); } } if (dbm) { /* * History of dbm_pagfno() and dbm_dirfno() in ndbm and its compatibles. * (dbm_pagfno() and dbm_dirfno() is not standardized.) * * 1986: 4.3BSD provides ndbm. * It provides dbm_pagfno() and dbm_dirfno() as macros. * 1991: gdbm-1.5 provides them as functions. * They returns a same descriptor. * (Earlier releases may have the functions too.) * 1991: Net/2 provides Berkeley DB. * It doesn't provide dbm_pagfno() and dbm_dirfno(). * 1992: 4.4BSD Alpha provides Berkeley DB with dbm_dirfno() as a function. * dbm_pagfno() is a macro as DBM_PAGFNO_NOT_AVAILABLE. * 1997: Berkeley DB 2.0 is released by Sleepycat Software, Inc. * It defines dbm_pagfno() and dbm_dirfno() as macros. * 2011: gdbm-1.9 creates a separate dir file. * dbm_pagfno() and dbm_dirfno() returns different descriptors. */ #if defined(HAVE_DBM_PAGFNO) rb_fd_fix_cloexec(dbm_pagfno(dbm)); #endif #if defined(HAVE_DBM_DIRFNO) rb_fd_fix_cloexec(dbm_dirfno(dbm)); #endif #if defined(RUBYDBM_DB_HEADER) && defined(HAVE_TYPE_DBC) /* Disable Berkeley DB error messages such as: * DB->put: attempt to modify a read-only database */ ((DBC*)dbm)->dbp->set_errfile(((DBC*)dbm)->dbp, NULL); #endif } if (!dbm) { if (mode == -1) return Qnil; rb_sys_fail_str(file); } if (dbmp->di_dbm) dbm_close(dbmp->di_dbm); dbmp->di_dbm = dbm; dbmp->di_size = -1; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#close;F;[;[[@8ia;T;;;0;[;{;IC;"Closes the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[;[;I";T;0; @9;@F;Mi;N0;[; @9;[;I"+Closes the database. @overload close;T;0; @9;@F;Ao;B;CT;Di[;Ei^;!@8;"I"static VALUE fdbm_close(VALUE obj) { struct dbmdata *dbmp; GetDBM(obj, dbmp); dbm_close(dbmp->di_dbm); dbmp->di_dbm = 0; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#closed?;F;[;[[@8is;T;;;0;[;{;IC;"=Returns true if the database is closed, false otherwise.;T;[o;H ;II" overload;F;J0;;;K0;#I" closed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @9;[;I"@return [Boolean];T;0; @9;@F;Mi;N0;[; @9;[;I"eReturns true if the database is closed, false otherwise. @overload closed? @return [Boolean];T;0; @9;@F;Ao;B;CT;Dim;Eiq;Mi;!@8;"I"static VALUE fdbm_closed(VALUE obj) { struct dbmdata *dbmp; TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp); if (dbmp->di_dbm == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#[];F;[[I" keystr;T0;[[@8i);T;;;0;[;{;IC;"qReturn a value from the database by locating the key string provided. If the key is not found, returns nil. ;T;[o;H ;II" overload;F;J0;;;K0;#I" [](key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @69;[;I"@return [nil];T;0; @69;@F;Mi;N0;[[I"key;T0; @69;[;I"Return a value from the database by locating the key string provided. If the key is not found, returns nil. @overload [](key) @return [nil];T;0; @69;@F;Ao;B;CT;Di";Ei';!@8;"I"bstatic VALUE fdbm_aref(VALUE obj, VALUE keystr) { return fdbm_fetch(obj, keystr, Qnil); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#fetch;F;[[@0;[[@8i7;T;;;0;[;{;IC;"Return a value from the database by locating the key string provided. If the key is not found, returns +ifnone+. If +ifnone+ is not given, raises IndexError. ;T;[o;H ;II" overload;F;J0;;;K0;#I"fetch(key[, ifnone]);T;IC;";T;[;[;I";T;0; @U9;@F;Mi;N0;[[I"key[, ifnone];T0; @U9;[;I"Return a value from the database by locating the key string provided. If the key is not found, returns +ifnone+. If +ifnone+ is not given, raises IndexError. @overload fetch(key[, ifnone]);T;0; @U9;@F;Ao;B;CT;Di/;Ei4;!@8;"I"Astatic VALUE fdbm_fetch_m(int argc, VALUE *argv, VALUE obj) { VALUE keystr, valstr, ifnone; rb_scan_args(argc, argv, "11", &keystr, &ifnone); valstr = fdbm_fetch(obj, keystr, ifnone); if (argc == 1 && !rb_block_given_p() && NIL_P(valstr)) rb_raise(rb_eIndexError, "key not found"); return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#[]=;F;[[I" keystr;T0[I" valstr;T0;[[@8i;T;;+;0;[;{;IC;"\Stores the specified string value in the database, indexed via the string key provided. ;T;[o;H ;II" overload;F;J0;;;K0;#I"store(key, value);T;IC;";T;[;[;I";T;0; @n9;@F;Mi;N0;[[I"key;T0[I" value;T0; @n9o;H ;II" overload;F;J0;;+;K0;#I" []=(key);T;IC;";T;[;[;I";T;0; @n9;@F;Mi;N0;[[I"key;T0; @n9;[;I"Stores the specified string value in the database, indexed via the string key provided. @overload store(key, value) @overload []=(key);T;0; @n9;@F;Ao;B;CT;Di;Ei;!@8;"I"bstatic VALUE fdbm_store(VALUE obj, VALUE keystr, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; fdbm_modify(obj); keystr = rb_obj_as_string(keystr); valstr = rb_obj_as_string(valstr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_DSIZE(keystr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_DSIZE(valstr); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; if (dbm_store(dbm, key, val, DBM_REPLACE)) { dbm_clearerr(dbm); if (errno == EPERM) rb_sys_fail(0); rb_raise(rb_eDBMError, "dbm_store failed"); } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#store;F;[[I" keystr;T0[I" valstr;T0;[[@8i;T;;;0;[;{;IC;"\Stores the specified string value in the database, indexed via the string key provided. ;T;[o;H ;II" overload;F;J0;;;K0;#I"store(key, value);T;IC;";T;[;[;I";T;0; @9;@F;Mi;N0;[[I"key;T0[I" value;T0; @9o;H ;II" overload;F;J0;;+;K0;#I" []=(key);T;IC;";T;[;[;I";T;0; @9;@F;Mi;N0;[[I"key;T0; @9;[;@9;0; @9;@F;Ao;B;CT;Di;Ei;!@8;"I"bstatic VALUE fdbm_store(VALUE obj, VALUE keystr, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; fdbm_modify(obj); keystr = rb_obj_as_string(keystr); valstr = rb_obj_as_string(valstr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_DSIZE(keystr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_DSIZE(valstr); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; if (dbm_store(dbm, key, val, DBM_REPLACE)) { dbm_clearerr(dbm); if (errno == EPERM) rb_sys_fail(0); rb_raise(rb_eDBMError, "dbm_store failed"); } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#index;F;[[I" value;T0;[[@8ib;T;;1;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @9;@F;Ao;B;CT;Dia;Eia;!@8;"I"static VALUE fdbm_index(VALUE hash, VALUE value) { rb_warn("DBM#index is deprecated; use DBM#key"); return fdbm_key(hash, value); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#key;F;[[I" valstr;T0;[[@8iJ;T;;;0;[;{;IC;"-Returns the key for the specified value. ;T;[o;H ;II" overload;F;J0;;;K0;#I"key(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @9;[;I"@return [String];T;0; @9;@F;Mi;N0;[[I" value;T0; @9;[;I"WReturns the key for the specified value. @overload key(value) @return [String];T;0; @9;@F;Ao;B;CT;DiD;EiH;!@8;"I"static VALUE fdbm_key(VALUE obj, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; long len; ExportStringValue(valstr); len = RSTRING_LEN(valstr); if (TOO_LONG(len)) return Qnil; GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); if ((long)val.dsize == RSTRING_LEN(valstr) && memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) { return rb_tainted_str_new(key.dptr, key.dsize); } } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#select;F;[;[[@8ip;T;;;0;[;{;IC;"dReturns a new array consisting of the [key, value] pairs for which the code block returns true. ;T;[o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @9o;L ;II" return;F;JI";T;0;K[I" Array;T; @9;[;I"(@yield [key, value] @return [Array];T;0; @9;@F;Mi;N0;[; @9;[;I"Returns a new array consisting of the [key, value] pairs for which the code block returns true. @overload select @yield [key, value] @return [Array];T;0; @9;@F;Ao;B;CT;Dii;Eio;!@8;"I"static VALUE fdbm_select(VALUE obj) { VALUE new = rb_ary_new(); datum key, val; DBM *dbm; struct dbmdata *dbmp; GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { VALUE assoc, v; val = dbm_fetch(dbm, key); assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize), rb_tainted_str_new(val.dptr, val.dsize)); v = rb_yield(assoc); if (RTEST(v)) { rb_ary_push(new, assoc); } GetDBM2(obj, dbmp, dbm); } return new; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#values_at;F;[[@0;[[@8i;T;;;0;[;{;IC;"KReturns an array containing the values associated with the given keys. ;T;[o;H ;II" overload;F;J0;;;K0;#I"values_at(key, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ :;[;I"@return [Array];T;0; @ :;@F;Mi;N0;[[I"key;T0[I"...;T0; @ :;[;I"}Returns an array containing the values associated with the given keys. @overload values_at(key, ...) @return [Array];T;0; @ :;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE fdbm_values_at(int argc, VALUE *argv, VALUE obj) { VALUE new = rb_ary_new2(argc); int i; for (i=0; idi_size > 0) return INT2FIX(dbmp->di_size); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { i++; } dbmp->di_size = i; return INT2FIX(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#size;F;[;[[@8i;T;;;0;[;{;IC;"3Returns the number of entries in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U:;[;I"@return [Integer];T;0; @U:;@F;Mi;N0;[; @U:o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U:;[;I"@return [Integer];T;0; @U:;@F;Mi;N0;[; @U:;[;@Q:;0; @U:;@F;Ao;B;CT;Di;Ei;!@8;"I"Gstatic VALUE fdbm_length(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; int i = 0; GetDBM2(obj, dbmp, dbm); if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { i++; } dbmp->di_size = i; return INT2FIX(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#empty?;F;[;[[@8i;T;;;0;[;{;IC;"di_size < 0) { dbm = dbmp->di_dbm; for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { return Qfalse; } } else { if (dbmp->di_size) return Qfalse; } return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#each;F;[;[[@8i;T;;;0;[;{;IC;"SCalls the block once for each [key, value] pair in the database. Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @:o;L ;II" return;F;JI";T;0;K[I" self;T; @:;[;I"&@yield [key,value] @return [self];T;0; @:;@F;Mi;N0;[; @:;[;I"Calls the block once for each [key, value] pair in the database. Returns self. @overload each_pair @yield [key,value] @return [self];T;0; @:;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE fdbm_each_pair(VALUE obj) { datum key, val; DBM *dbm; struct dbmdata *dbmp; VALUE keystr, valstr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); keystr = rb_tainted_str_new(key.dptr, key.dsize); valstr = rb_tainted_str_new(val.dptr, val.dsize); rb_yield(rb_assoc_new(keystr, valstr)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#each_value;F;[;[[@8i;T;;;0;[;{;IC;"NCalls the block once for each value string in the database. Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_value;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" value;T; @:o;L ;II" return;F;JI";T;0;K[I" self;T; @:;[;I""@yield [value] @return [self];T;0; @:;@F;Mi;N0;[; @:;[;I"Calls the block once for each value string in the database. Returns self. @overload each_value @yield [value] @return [self];T;0; @:;@F;Ao;B;CT;Di;Ei;!@8;"I"nstatic VALUE fdbm_each_value(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); rb_yield(rb_tainted_str_new(val.dptr, val.dsize)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#each_key;F;[;[[@8i;T;;;0;[;{;IC;"LCalls the block once for each key string in the database. Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I" each_key;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @:o;L ;II" return;F;JI";T;0;K[I" self;T; @:;[;I" @yield [key] @return [self];T;0; @:;@F;Mi;N0;[; @:;[;I"|Calls the block once for each key string in the database. Returns self. @overload each_key @yield [key] @return [self];T;0; @:;@F;Ao;B;CT;Di;Ei;!@8;"I"Kstatic VALUE fdbm_each_key(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { rb_yield(rb_tainted_str_new(key.dptr, key.dsize)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#each_pair;F;[;[[@8i;T;;;0;[;{;IC;"SCalls the block once for each [key, value] pair in the database. Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @:o;L ;II" return;F;JI";T;0;K[I" self;T; @:;[;I"&@yield [key,value] @return [self];T;0; @:;@F;Mi;N0;[; @:;[;@:;0; @:;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE fdbm_each_pair(VALUE obj) { datum key, val; DBM *dbm; struct dbmdata *dbmp; VALUE keystr, valstr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); keystr = rb_tainted_str_new(key.dptr, key.dsize); valstr = rb_tainted_str_new(val.dptr, val.dsize); rb_yield(rb_assoc_new(keystr, valstr)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#keys;F;[;[[@8i,;T;;;0;[;{;IC;"=Returns an array of all the string keys in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" keys;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;;[;I"@return [Array];T;0; @;;@F;Mi;N0;[; @;;[;I"`Returns an array of all the string keys in the database. @overload keys @return [Array];T;0; @;;@F;Ao;B;CT;Di&;Ei*;!@8;"I";static VALUE fdbm_keys(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; VALUE ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { rb_ary_push(ary, rb_tainted_str_new(key.dptr, key.dsize)); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#values;F;[;[[@8iD;T;;;0;[;{;IC;"?Returns an array of all the string values in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @1;;[;I"@return [Array];T;0; @1;;@F;Mi;N0;[; @1;;[;I"dReturns an array of all the string values in the database. @overload values @return [Array];T;0; @1;;@F;Ao;B;CT;Di>;EiB;!@8;"I"]static VALUE fdbm_values(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); rb_ary_push(ary, rb_tainted_str_new(val.dptr, val.dsize)); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#shift;F;[;[[@8i;T;;;0;[;{;IC;"Removes a [key, value] pair from the database, and returns it. If the database is empty, returns nil. The order in which values are removed/returned is not guaranteed. ;T;[o;H ;II" overload;F;J0;;;K0;#I" shift();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @L;;[;I"@return [Array];T;0; @L;;@F;Mi;N0;[; @L;;[;I"Removes a [key, value] pair from the database, and returns it. If the database is empty, returns nil. The order in which values are removed/returned is not guaranteed. @overload shift() @return [Array];T;0; @L;;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE fdbm_shift(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; key = dbm_firstkey(dbm); if (!key.dptr) return Qnil; val = dbm_fetch(dbm, key); keystr = rb_tainted_str_new(key.dptr, key.dsize); valstr = rb_tainted_str_new(val.dptr, val.dsize); dbm_delete(dbm, key); return rb_assoc_new(keystr, valstr); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#delete;F;[[I" keystr;T0;[[@8i;T;;p;0;[;{;IC;"(Deletes an entry from the database. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete(key);T;IC;";T;[;[;I";T;0; @g;;@F;Mi;N0;[[I"key;T0; @g;;[;I"@Deletes an entry from the database. @overload delete(key);T;0; @g;;@F;Ao;B;CT;Di;Ei;!@8;"I"*static VALUE fdbm_delete(VALUE obj, VALUE keystr) { datum key, value; struct dbmdata *dbmp; DBM *dbm; VALUE valstr; long len; fdbm_modify(obj); ExportStringValue(keystr); len = RSTRING_LEN(keystr); if (TOO_LONG(len)) goto not_found; key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)len; GetDBM2(obj, dbmp, dbm); value = dbm_fetch(dbm, key); if (value.dptr == 0) { not_found: if (rb_block_given_p()) return rb_yield(keystr); return Qnil; } /* need to save value before dbm_delete() */ valstr = rb_tainted_str_new(value.dptr, value.dsize); if (dbm_delete(dbm, key)) { dbmp->di_size = -1; rb_raise(rb_eDBMError, "dbm_delete failed"); } else if (dbmp->di_size >= 0) { dbmp->di_size--; } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#delete_if;F;[;[[@8i;T;;;0;[;{;IC;"MDeletes all entries for which the code block returns true. Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;o;L ;II" return;F;JI";T;0;K[I" self;T; @;;[;I"'@yield [key, value] @return [self];T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;o;L ;II" return;F;JI";T;0;K[I" self;T; @;;[;I"'@yield [key, value] @return [self];T;0; @;;@F;Mi;N0;[; @;;[;I"Deletes all entries for which the code block returns true. Returns self. @overload reject! @yield [key, value] @return [self] @overload delete_if @yield [key, value] @return [self];T;0; @;;@F;Ao;B;CT;Di;Ei;!@8;"I"Bstatic VALUE fdbm_delete_if(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; VALUE ret, ary = rb_ary_tmp_new(0); int status = 0; long i, n; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); n = dbmp->di_size; dbmp->di_size = -1; for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); keystr = rb_tainted_str_new(key.dptr, key.dsize); OBJ_FREEZE(keystr); valstr = rb_tainted_str_new(val.dptr, val.dsize); ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status); if (status != 0) break; if (RTEST(ret)) rb_ary_push(ary, keystr); GetDBM2(obj, dbmp, dbm); } for (i = 0; i < RARRAY_LEN(ary); i++) { keystr = RARRAY_AREF(ary, i); key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)RSTRING_LEN(keystr); if (dbm_delete(dbm, key)) { rb_raise(rb_eDBMError, "dbm_delete failed"); } } if (status) rb_jump_tag(status); if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary); rb_ary_clear(ary); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#reject!;F;[;[[@8i;T;;;0;[;{;IC;"MDeletes all entries for which the code block returns true. Returns self. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;o;L ;II" return;F;JI";T;0;K[I" self;T; @;;[;I"'@yield [key, value] @return [self];T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;o;L ;II" return;F;JI";T;0;K[I" self;T; @;;[;I"'@yield [key, value] @return [self];T;0; @;;@F;Mi;N0;[; @;;[;@;;0; @;;@F;Ao;B;CT;Di;Ei;!@8;"I"Bstatic VALUE fdbm_delete_if(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; VALUE ret, ary = rb_ary_tmp_new(0); int status = 0; long i, n; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); n = dbmp->di_size; dbmp->di_size = -1; for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); keystr = rb_tainted_str_new(key.dptr, key.dsize); OBJ_FREEZE(keystr); valstr = rb_tainted_str_new(val.dptr, val.dsize); ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status); if (status != 0) break; if (RTEST(ret)) rb_ary_push(ary, keystr); GetDBM2(obj, dbmp, dbm); } for (i = 0; i < RARRAY_LEN(ary); i++) { keystr = RARRAY_AREF(ary, i); key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)RSTRING_LEN(keystr); if (dbm_delete(dbm, key)) { rb_raise(rb_eDBMError, "dbm_delete failed"); } } if (status) rb_jump_tag(status); if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary); rb_ary_clear(ary); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#reject;F;[;[[@8i;T;;;0;[;{;IC;"Converts the contents of the database to an in-memory Hash, then calls Hash#reject with the specified code block, returning a new Hash. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;;[;I"&@yield [key,value] @return [Hash];T;0; @;;@F;Mi;N0;[; @;;[;I"Converts the contents of the database to an in-memory Hash, then calls Hash#reject with the specified code block, returning a new Hash. @overload reject @yield [key,value] @return [Hash];T;0; @;;@F;Ao;B;CT;Di;Ei;!@8;"I"]static VALUE fdbm_reject(VALUE obj) { return rb_hash_delete_if(fdbm_to_hash(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#clear;F;[;[[@8i#;T;;3;0;[;{;IC;"(Deletes all data from the database. ;T;[o;H ;II" overload;F;J0;;3;K0;#I" clear;T;IC;";T;[;[;I";T;0; @ <;@F;Mi;N0;[; @ <;[;I":Deletes all data from the database. @overload clear;T;0; @ <;@F;Ao;B;CT;Di;Ei ;!@8;"I"Ystatic VALUE fdbm_clear(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; while (key = dbm_firstkey(dbm), key.dptr) { if (dbm_delete(dbm, key)) { rb_raise(rb_eDBMError, "dbm_delete failed"); } } dbmp->di_size = 0; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#invert;F;[;[[@8i>;T;;;0;[;{;IC;"Returns a Hash (not a DBM database) created by using each value in the database as a key, with the corresponding key as its value. ;T;[o;H ;II" overload;F;J0;;;K0;#I" invert;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @<;[;I"@return [Hash];T;0; @<;@F;Mi;N0;[; @<;[;I"Returns a Hash (not a DBM database) created by using each value in the database as a key, with the corresponding key as its value. @overload invert @return [Hash];T;0; @<;@F;Ao;B;CT;Di7;Ei<;!@8;"I"static VALUE fdbm_invert(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; VALUE hash = rb_hash_new(); GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); keystr = rb_tainted_str_new(key.dptr, key.dsize); valstr = rb_tainted_str_new(val.dptr, val.dsize); rb_hash_aset(hash, valstr, keystr); } return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#update;F;[[I" other;T0;[[@8ih;T;;;0;[;{;IC;"Updates the database with multiple values from the specified object. Takes any object which implements the each_pair method, including Hash and DBM objects. ;T;[o;H ;II" overload;F;J0;;;K0;#I"update(obj);T;IC;";T;[;[;I";T;0; @:<;@F;Mi;N0;[[I"obj;T0; @:<;[;I"Updates the database with multiple values from the specified object. Takes any object which implements the each_pair method, including Hash and DBM objects. @overload update(obj);T;0; @:<;@F;Ao;B;CT;Di`;Eie;!@8;"I"static VALUE fdbm_update(VALUE obj, VALUE other) { rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#replace;F;[[I" other;T0;[[@8iw;T;;';0;[;{;IC;"Replaces the contents of the database with the contents of the specified object. Takes any object which implements the each_pair method, including Hash and DBM objects. ;T;[o;H ;II" overload;F;J0;;';K0;#I"replace(obj);T;IC;";T;[;[;I";T;0; @T<;@F;Mi;N0;[[I"obj;T0; @T<;[;I"Replaces the contents of the database with the contents of the specified object. Takes any object which implements the each_pair method, including Hash and DBM objects. @overload replace(obj);T;0; @T<;@F;Ao;B;CT;Dio;Eit;!@8;"I"static VALUE fdbm_replace(VALUE obj, VALUE other) { fdbm_clear(obj); rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#include?;F;[[I" keystr;T0;[[@8i_;T;;U;0;[;{;IC;"NReturns true if the database contains the specified key, false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n<;[;I"@return [Boolean];T;0; @n<;@F;Mi;N0;[[I"key;T0; @n<o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n<;[;I"@return [Boolean];T;0; @n<;@F;Mi;N0;[[I"key;T0; @n<o;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n<;[;I"@return [Boolean];T;0; @n<;@F;Mi;N0;[[I"key;T0; @n<o;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @n<;[;I"@return [Boolean];T;0; @n<;@F;Mi;N0;[[I"key;T0; @n<;[;I"Returns true if the database contains the specified key, false otherwise. @overload include?(key) @return [Boolean] @overload has_key?(key) @return [Boolean] @overload member?(key) @return [Boolean] @overload key?(key) @return [Boolean];T;0; @n<;@F;Ao;B;CT;DiV;Ei`;Mi;!@8;"I"static VALUE fdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; long len; ExportStringValue(keystr); len = RSTRING_LEN(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)len; GetDBM2(obj, dbmp, dbm); val = dbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#has_key?;F;[[I" keystr;T0;[[@8i_;T;;;0;[;{;IC;"NReturns true if the database contains the specified key, false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @<;[;I"@return [Boolean];T;0; @<;@F;Mi;N0;[[I"key;T0; @<o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @<;[;I"@return [Boolean];T;0; @<;@F;Mi;N0;[[I"key;T0; @<o;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @<;[;I"@return [Boolean];T;0; @<;@F;Mi;N0;[[I"key;T0; @<o;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @<;[;I"@return [Boolean];T;0; @<;@F;Mi;N0;[[I"key;T0; @<;[;@<;0; @<;@F;Ao;B;CT;DiV;Ei`;Mi;!@8;"I"static VALUE fdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; long len; ExportStringValue(keystr); len = RSTRING_LEN(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)len; GetDBM2(obj, dbmp, dbm); val = dbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#member?;F;[[I" keystr;T0;[[@8i_;T;;;0;[;{;IC;"NReturns true if the database contains the specified key, false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @=;[;I"@return [Boolean];T;0; @=;@F;Mi;N0;[[I"key;T0; @=o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @=;[;I"@return [Boolean];T;0; @=;@F;Mi;N0;[[I"key;T0; @=o;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @=;[;I"@return [Boolean];T;0; @=;@F;Mi;N0;[[I"key;T0; @=o;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @=;[;I"@return [Boolean];T;0; @=;@F;Mi;N0;[[I"key;T0; @=;[;@<;0; @=;@F;Ao;B;CT;DiV;Ei`;Mi;!@8;"I"static VALUE fdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; long len; ExportStringValue(keystr); len = RSTRING_LEN(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)len; GetDBM2(obj, dbmp, dbm); val = dbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#has_value?;F;[[I" valstr;T0;[[@8i{;T;;;0;[;{;IC;"WReturns true if the database contains the specified string value, false otherwise.;T;[o;H ;II" overload;F;J0;;;K0;#I"has_value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @P=;[;I"@return [Boolean];T;0; @P=;@F;Mi;N0;[[I" value;T0; @P=o;H ;II" overload;F;J0;;;K0;#I"value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @P=;[;I"@return [Boolean];T;0; @P=;@F;Mi;N0;[[I" value;T0; @P=;[;I"Returns true if the database contains the specified string value, false otherwise. @overload has_value?(value) @return [Boolean] @overload value?(value) @return [Boolean];T;0; @P=;@F;Ao;B;CT;Dis;Eiz;Mi;!@8;"I"Ustatic VALUE fdbm_has_value(VALUE obj, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; long len; ExportStringValue(valstr); len = RSTRING_LEN(valstr); if (TOO_LONG(len)) return Qfalse; val.dptr = RSTRING_PTR(valstr); val.dsize = (DSIZE_TYPE)len; GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); if ((DSIZE_TYPE)val.dsize == (DSIZE_TYPE)RSTRING_LEN(valstr) && memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#key?;F;[[I" keystr;T0;[[@8i_;T;;;0;[;{;IC;"NReturns true if the database contains the specified key, false otherwise.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @~=;[;I"@return [Boolean];T;0; @~=;@F;Mi;N0;[[I"key;T0; @~=o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @~=;[;I"@return [Boolean];T;0; @~=;@F;Mi;N0;[[I"key;T0; @~=o;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @~=;[;I"@return [Boolean];T;0; @~=;@F;Mi;N0;[[I"key;T0; @~=o;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @~=;[;I"@return [Boolean];T;0; @~=;@F;Mi;N0;[[I"key;T0; @~=;[;@<;0; @~=;@F;Ao;B;CT;DiV;Ei`;Mi;!@8;"I"static VALUE fdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; long len; ExportStringValue(keystr); len = RSTRING_LEN(keystr); if (TOO_LONG(len)) return Qfalse; key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)len; GetDBM2(obj, dbmp, dbm); val = dbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#value?;F;[[I" valstr;T0;[[@8i{;T;;;0;[;{;IC;"WReturns true if the database contains the specified string value, false otherwise.;T;[o;H ;II" overload;F;J0;;;K0;#I"has_value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @=;[;I"@return [Boolean];T;0; @=;@F;Mi;N0;[[I" value;T0; @=o;H ;II" overload;F;J0;;;K0;#I"value?(value);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @=;[;I"@return [Boolean];T;0; @=;@F;Mi;N0;[[I" value;T0; @=;[;@z=;0; @=;@F;Ao;B;CT;Dis;Eiz;Mi;!@8;"I"Ustatic VALUE fdbm_has_value(VALUE obj, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; long len; ExportStringValue(valstr); len = RSTRING_LEN(valstr); if (TOO_LONG(len)) return Qfalse; val.dptr = RSTRING_PTR(valstr); val.dsize = (DSIZE_TYPE)len; GetDBM2(obj, dbmp, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); if ((DSIZE_TYPE)val.dsize == (DSIZE_TYPE)RSTRING_LEN(valstr) && memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" DBM#to_a;F;[;[[@8i;T;;;0;[;{;IC;"^Converts the contents of the database to an array of [key, value] arrays, and returns it. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @=;[;I"@return [Array];T;0; @=;@F;Mi;N0;[; @=;[;I"|Converts the contents of the database to an array of [key, value] arrays, and returns it. @overload to_a @return [Array];T;0; @=;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE fdbm_to_a(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); rb_ary_push(ary, rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize), rb_tainted_str_new(val.dptr, val.dsize))); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DBM#to_hash;F;[;[[@8i;T;;;0;[;{;IC;"WConverts the contents of the database to an in-memory Hash object, and returns it. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @>;[;I"@return [Hash];T;0; @>;@F;Mi;N0;[; @>;[;I"|Converts the contents of the database to an in-memory Hash object, and returns it. @overload to_hash @return [Hash];T;0; @>;@F;Ao;B;CT;Di;Ei;!@8;"I"static VALUE fdbm_to_hash(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE hash; GetDBM2(obj, dbmp, dbm); hash = rb_hash_new(); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); rb_hash_aset(hash, rb_tainted_str_new(key.dptr, key.dsize), rb_tainted_str_new(val.dptr, val.dsize)); } return hash; };T;#I"static VALUE;T;$To;9;[[@8iG;F;;X;;;;;;[;{;IC;"IIndicates that dbm_open() should open the database in read-only mode ;T;[;[;I"IIndicates that dbm_open() should open the database in read-only mode;T;0; @,>;@F;Ao;B;CT;DiF;EiF;!@8;I"DBM::READER;F;;@F;Ao;B;CT;DiI;EiI;!@8;I"DBM::WRITER;F;;@F;Ao;B;CT;DiL;EiN;!@8;I"DBM::WRCREAT;F;;@F;Ao;B;CT;DiQ;EiT;!@8;I"DBM::NEWDB;F;;@F;Ao;B;CT;Diw;Ei;!@8;I"DBM::VERSION;F;;'IC;[;&@w>;(IC;[;&@w>;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@8i[@8i;T;: DBMError;;0;;;[;{;IC;"@Exception class used to return errors from the dbm library. ;T;[;[;I"AException class used to return errors from the dbm library. ;T;0; @w>;@F;Ao;B;CT;Di;Ei;!@;I" DBMError;F;1@7o; ;IC;[@o; ;IC;[o; ; F; ;,;;;I"Fiddle::Closure#initialize;F;[[I" argv[];T0[I" self;T0;[[I"ext/fiddle/closure.c;Ti;T;;;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;Ao;B;CT;DiB;EiM;!@>;"I"static VALUE initialize(int rbargc, VALUE argv[], VALUE self) { VALUE ret; VALUE 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 *)); for (i = 0; i < argc; i++) { int type = NUM2INT(RARRAY_AREF(args, i)); cl->argv[i] = INT2FFI_TYPE(type); } cl->argv[argc] = NULL; rb_iv_set(self, "@ctype", ret); rb_iv_set(self, "@args", args); cif = &cl->cif; pcl = cl->pcl; result = ffi_prep_cif(cif, NUM2INT(abi), argc, INT2FFI_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; ; F; ;,;;;I"Fiddle::Closure#to_i;F;[;[[@>i;T;;=;0;[;{;IC;"0Returns the memory address for this closure ;T;[;[;I"2 Returns the memory address for this closure ;T;0; @>;@F;Ao;B;CT;DiR;EiT;!@>;"I"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;-{;.[;[[@>i*[@>i>;T;: Closure;;0;;;[;{;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;Ao;B;CT;Di*;Ei;;!@>;I"Fiddle::Closure;F;1@;'IC;[;&@>;(IC;[;&@>;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/fiddle/fiddle.c;Ti[@>i;T;: DLError;;0;;;[;{;IC;"$standard dynamic load exception ;T;[;[;I"& standard dynamic load exception ;T;0; @>;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::DLError;F;1@7o;9;[[@>i;F;:TYPE_VOID;;;;;;[;{;IC;"C type - void ;T;[;[;I" C type - void ;T;0; @>;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_VOID;F;i;F;:TYPE_VOIDP;;;;;;[;{;IC;"C type - void* ;T;[;[;I" C type - void* ;T;0; @>;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_VOIDP;F;i;F;:TYPE_CHAR;;;;;;[;{;IC;"C type - char ;T;[;[;I" C type - char ;T;0; @>;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_CHAR;F;i;F;:TYPE_SHORT;;;;;;[;{;IC;"C type - short ;T;[;[;I" C type - short ;T;0; @>;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_SHORT;F;i;F;: TYPE_INT;;;;;;[;{;IC;"C type - int ;T;[;[;I" C type - int ;T;0; @?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_INT;F;i;F;:TYPE_LONG;;;;;;[;{;IC;"C type - long ;T;[;[;I" C type - long ;T;0; @?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_LONG;F;i;F;:TYPE_LONG_LONG;;;;;;[;{;IC;"C type - long long ;T;[;[;I" C type - long long ;T;0; @?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_LONG_LONG;F;i;F;:TYPE_FLOAT;;;;;;[;{;IC;"C type - float ;T;[;[;I" C type - float ;T;0; @+?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_FLOAT;F;i;F;:TYPE_DOUBLE;;;;;;[;{;IC;"C type - double ;T;[;[;I" C type - double ;T;0; @7?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_DOUBLE;F;i;F;:TYPE_SIZE_T;;;;;;[;{;IC;"C type - size_t ;T;[;[;I" C type - size_t ;T;0; @C?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_SIZE_T;F;i;F;:TYPE_SSIZE_T;;;;;;[;{;IC;"C type - ssize_t ;T;[;[;I" C type - ssize_t ;T;0; @O?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_SSIZE_T;F;i;F;:TYPE_PTRDIFF_T;;;;;;[;{;IC;"C type - ptrdiff_t ;T;[;[;I" C type - ptrdiff_t ;T;0; @[?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_PTRDIFF_T;F;i;F;:TYPE_INTPTR_T;;;;;;[;{;IC;"C type - intptr_t ;T;[;[;I" C type - intptr_t ;T;0; @g?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_INTPTR_T;F;i;F;:TYPE_UINTPTR_T;;;;;;[;{;IC;"C type - uintptr_t ;T;[;[;I" C type - uintptr_t ;T;0; @s?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::TYPE_UINTPTR_T;F;i;F;:ALIGN_VOIDP;;;;;;[;{;IC;""The alignment size of a void* ;T;[;[;I"$ The alignment size of a void* ;T;0; @?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::ALIGN_VOIDP;F;i ;F;:ALIGN_CHAR;;;;;;[;{;IC;"!The alignment size of a char ;T;[;[;I"# The alignment size of a char ;T;0; @?;@F;Ao;B;CT;Di ;Ei ;!@>;I"Fiddle::ALIGN_CHAR;F;i;F;:ALIGN_SHORT;;;;;;[;{;IC;""The alignment size of a short ;T;[;[;I"$ The alignment size of a short ;T;0; @?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::ALIGN_SHORT;F;i;F;:ALIGN_INT;;;;;;[;{;IC;"!The alignment size of an int ;T;[;[;I"# The alignment size of an int ;T;0; @?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::ALIGN_INT;F;i;F;:ALIGN_LONG;;;;;;[;{;IC;"!The alignment size of a long ;T;[;[;I"# The alignment size of a long ;T;0; @?;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::ALIGN_LONG;F;i&;F;:ALIGN_LONG_LONG;;;;;;[;{;IC;"&The alignment size of a long long ;T;[;[;I"( The alignment size of a long long ;T;0; @?;@F;Ao;B;CT;Di";Ei$;!@>;I"Fiddle::ALIGN_LONG_LONG;F;i-;F;:ALIGN_FLOAT;;;;;;[;{;IC;""The alignment size of a float ;T;[;[;I"$ The alignment size of a float ;T;0; @?;@F;Ao;B;CT;Di);Ei+;!@>;I"Fiddle::ALIGN_FLOAT;F;i3;F;:ALIGN_DOUBLE;;;;;;[;{;IC;"#The alignment size of a double ;T;[;[;I"% The alignment size of a double ;T;0; @?;@F;Ao;B;CT;Di/;Ei1;!@>;I"Fiddle::ALIGN_DOUBLE;F;i9;F;:ALIGN_SIZE_T;;;;;;[;{;IC;"#The alignment size of a size_t ;T;[;[;I"% The alignment size of a size_t ;T;0; @?;@F;Ao;B;CT;Di5;Ei7;!@>;I"Fiddle::ALIGN_SIZE_T;F;i?;F;:ALIGN_SSIZE_T;;;;;;[;{;IC;"same as size_t ;T;[;[;I"same as size_t;T;0; @?;@F;Ao;B;CT;Di?;Ei?;!@>;I"Fiddle::ALIGN_SSIZE_T;F;iE;F;:ALIGN_PTRDIFF_T;;;;;;[;{;IC;"&The alignment size of a ptrdiff_t ;T;[;[;I"( The alignment size of a ptrdiff_t ;T;0; @?;@F;Ao;B;CT;DiA;EiC;!@>;I"Fiddle::ALIGN_PTRDIFF_T;F;iK;F;:ALIGN_INTPTR_T;;;;;;[;{;IC;"%The alignment size of a intptr_t ;T;[;[;I"' The alignment size of a intptr_t ;T;0; @@;@F;Ao;B;CT;DiG;EiI;!@>;I"Fiddle::ALIGN_INTPTR_T;F;iQ;F;:ALIGN_UINTPTR_T;;;;;;[;{;IC;"&The alignment size of a uintptr_t ;T;[;[;I"( The alignment size of a uintptr_t ;T;0; @@;@F;Ao;B;CT;DiM;EiO;!@>;I"Fiddle::ALIGN_UINTPTR_T;F;iX[@>iZ;F;: WINDOWS;;;;;;[;{;IC;" ;T;[;[;@;0; @@;!@>;I"Fiddle::WINDOWS;F;ia;F;:SIZEOF_VOIDP;;;;;;[;{;IC;"size of a void* ;T;[;[;I" size of a void* ;T;0; @&@;@F;Ao;B;CT;Di];Ei_;!@>;I"Fiddle::SIZEOF_VOIDP;F;ig;F;:SIZEOF_CHAR;;;;;;[;{;IC;"size of a char ;T;[;[;I" size of a char ;T;0; @2@;@F;Ao;B;CT;Dic;Eie;!@>;I"Fiddle::SIZEOF_CHAR;F;im;F;:SIZEOF_SHORT;;;;;;[;{;IC;"size of a short ;T;[;[;I" size of a short ;T;0; @>@;@F;Ao;B;CT;Dii;Eik;!@>;I"Fiddle::SIZEOF_SHORT;F;is;F;:SIZEOF_INT;;;;;;[;{;IC;"size of an int ;T;[;[;I" size of an int ;T;0; @J@;@F;Ao;B;CT;Dio;Eiq;!@>;I"Fiddle::SIZEOF_INT;F;iy;F;:SIZEOF_LONG;;;;;;[;{;IC;"size of a long ;T;[;[;I" size of a long ;T;0; @V@;@F;Ao;B;CT;Diu;Eiw;!@>;I"Fiddle::SIZEOF_LONG;F;i;F;:SIZEOF_LONG_LONG;;;;;;[;{;IC;"size of a long long ;T;[;[;I" size of a long long ;T;0; @b@;@F;Ao;B;CT;Di|;Ei~;!@>;I"Fiddle::SIZEOF_LONG_LONG;F;i;F;:SIZEOF_FLOAT;;;;;;[;{;IC;"size of a float ;T;[;[;I" size of a float ;T;0; @n@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::SIZEOF_FLOAT;F;i;F;:SIZEOF_DOUBLE;;;;;;[;{;IC;"size of a double ;T;[;[;I" size of a double ;T;0; @z@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::SIZEOF_DOUBLE;F;i;F;:SIZEOF_SIZE_T;;;;;;[;{;IC;"size of a size_t ;T;[;[;I" size of a size_t ;T;0; @@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::SIZEOF_SIZE_T;F;i;F;:SIZEOF_SSIZE_T;;;;;;[;{;IC;"same as size_t ;T;[;[;I"same as size_t;T;0; @@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::SIZEOF_SSIZE_T;F;i;F;:SIZEOF_PTRDIFF_T;;;;;;[;{;IC;"size of a ptrdiff_t ;T;[;[;I" size of a ptrdiff_t ;T;0; @@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::SIZEOF_PTRDIFF_T;F;i;F;:SIZEOF_INTPTR_T;;;;;;[;{;IC;"size of a intptr_t ;T;[;[;I" size of a intptr_t ;T;0; @@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::SIZEOF_INTPTR_T;F;i;F;:SIZEOF_UINTPTR_T;;;;;;[;{;IC;"size of a uintptr_t ;T;[;[;I" size of a uintptr_t ;T;0; @@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::SIZEOF_UINTPTR_T;F;i;F;:RUBY_FREE;;;;;;[;{;IC;")Address of the ruby_xfree() function ;T;[;[;I"+ Address of the ruby_xfree() function ;T;0; @@;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::RUBY_FREE;F;i;F;:BUILD_RUBY_PLATFORM;;;;;;[;{;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; @@;@F;Ao;B;CT;Di;Ei;!@>;I" Fiddle::BUILD_RUBY_PLATFORM;F;i};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;H ;II" overload;F;J0;;;K0;#I"dlwrap(val);T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[[I"val;T0; @@;[;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; @@;@F;N0;!@>;"I"`static VALUE rb_fiddle_value2ptr(VALUE self, VALUE val) { return PTR2NUM((void*)val); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Fiddle.dlwrap;F;@@;@@;T;;;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;H ;II" overload;F;J0;;;K0;#I"dlwrap(val);T;IC;";T;[;[;I";T;0; @@;@F;Mi;N0;[[I"val;T0; @@;[;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; @@;@F;Ao;B;CT;Dip;Ei{;Mi;!@>;"@@;#@@;$To; ; F; ;,;;;I"Fiddle#dlunwrap;F;[[I" addr;T0;[[@>ij;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;H ;II" overload;F;J0;;;K0;#I"dlunwrap(addr);T;IC;";T;[;[;I";T;0; @A;@F;Mi;N0;[[I" addr;T0; @A;[;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; @A;@F;N0;!@>;"I"[VALUE rb_fiddle_ptr2value(VALUE self, VALUE addr) { return (VALUE)NUM2PTR(addr); };T;#I" VALUE;T;$To; ; T; ;;;;I"Fiddle.dlunwrap;F;@A;@ A;T;;;0;@ A;{;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;H ;II" overload;F;J0;;;K0;#I"dlunwrap(addr);T;IC;";T;[;[;I";T;0; @A;@F;Mi;N0;[[I" addr;T0; @A;[;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; @A;@F;Ao;B;CT;DiZ;Eih;Mi;!@>;"@A;#@A;$To; ; F; ;,;;;I"Fiddle#malloc;F;[[I" size;T0;[[@>i3;T;: malloc;0;[;{;IC;"dAllocate +size+ bytes of memory and return the integer memory address for the allocated memory. ;T;[o;H ;II" overload;F;J0;;;K0;#I"malloc(size);T;IC;";T;[;[;I";T;0; @0A;@F;Mi;N0;[[I" size;T0; @0A;[;I"|Allocate +size+ bytes of memory and return the integer memory address for the allocated memory. @overload malloc(size) ;T;0; @0A;@F;N0;!@>;"I"static VALUE rb_fiddle_malloc(VALUE self, VALUE size) { void *ptr; ptr = (void*)ruby_xmalloc(NUM2SIZET(size)); return PTR2NUM(ptr); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Fiddle.malloc;F;@2A;@5A;T;;;0;@7A;{;IC;"dAllocate +size+ bytes of memory and return the integer memory address for the allocated memory.;T;[o;H ;II" overload;F;J0;;;K0;#I"malloc(size);T;IC;";T;[;[;I";T;0; @IA;@F;Mi;N0;[[I" size;T0; @IA;[;I"}Allocate +size+ bytes of memory and return the integer memory address for the allocated memory. @overload malloc(size);T;0; @IA;@F;Ao;B;CT;Di-;Ei1;Mi;!@>;"@GA;#@HA;$To; ; F; ;,;;;I"Fiddle#realloc;F;[[I" addr;T0[I" size;T0;[[@>iC;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;H ;II" overload;F;J0;;;K0;#I"realloc(addr, size);T;IC;";T;[;[;I";T;0; @[A;@F;Mi;N0;[[I" addr;T0[I" size;T0; @[A;[;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; @[A;@F;N0;!@>;"I"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; ; T; ;;;;I"Fiddle.realloc;F;@]A;@bA;T;;;0;@dA;{;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;H ;II" overload;F;J0;;;K0;#I"realloc(addr, size);T;IC;";T;[;[;I";T;0; @xA;@F;Mi;N0;[[I" addr;T0[I" size;T0; @xA;[;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; @xA;@F;Ao;B;CT;Di<;EiA;Mi;!@>;"@vA;#@wA;$To; ; F; ;,;;;I"Fiddle#free;F;[[I" addr;T0;[[@>iQ;T;: free;0;[;{;IC;"&Free the memory at address +addr+ ;T;[o;H ;II" overload;F;J0;;;K0;#I"free(addr);T;IC;";T;[;[;I";T;0; @A;@F;Mi;N0;[[I" addr;T0; @A;[;I";"I"{VALUE rb_fiddle_free(VALUE self, VALUE addr) { void *ptr = NUM2PTR(addr); ruby_xfree(ptr); return Qnil; };T;#I" VALUE;T;$To; ; T; ;;;;I"Fiddle.free;F;@A;@A;T;;;0;@A;{;IC;"&Free the memory at address +addr+;T;[o;H ;II" overload;F;J0;;;K0;#I"free(addr);T;IC;";T;[;[;I";T;0; @A;@F;Mi;N0;[[I" addr;T0; @A;[;I"=Free the memory at address +addr+ @overload free(addr);T;0; @A;@F;Ao;B;CT;DiL;EiO;Mi;!@>;"@A;#@A;$To; ;IC;[o; ; F; ;;;;I"Fiddle::Handle.sym;F;[[I"sym;T0;[[I"ext/fiddle/handle.c;Ti2;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; @A;@F;Ao;B;CT;Di(;Ei/;!@A;"I"qstatic VALUE rb_fiddle_handle_s_sym(VALUE self, VALUE sym) { return fiddle_handle_sym(RTLD_NEXT, sym); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Fiddle::Handle.[];F;[[I"sym;T0;[[@Ai2;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;[;[;@A;0; @A;@F;Ao;B;CT;Di(;Ei/;!@A;"I"qstatic VALUE rb_fiddle_handle_s_sym(VALUE self, VALUE sym) { return fiddle_handle_sym(RTLD_NEXT, sym); };T;#I"static VALUE;T;$To;9;[[@Ai;F;: NEXT;;;;;;[;{;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; @A;@F;Ao;B;CT;Di;Ei;!@A;I"Fiddle::Handle::NEXT;F;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;H ;II" overload;F;J0;; ;K0;#I"Hnew(library = nil, flags = Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL);T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[[I" library;TI"nil;T[I" flags;TI"*Fiddle::RTLD_LAZY|Fiddle::RTLD_GLOBAL;T; @B;[;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; @B;@F;Ao;B;CT;Diz;Ei;!@A;"I"xstatic 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 : SafeStringValueCStr(lib); cflag = RTLD_LAZY | RTLD_GLOBAL; break; case 2: clib = NIL_P(lib) ? NULL : SafeStringValueCStr(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_eFiddleError, "%s", err); } #else if( !ptr ){ err = dlerror(); rb_raise(rb_eFiddleError, "%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; ; F; ;,;;;I"Fiddle::Handle#to_i;F;[;[[@Ai;T;;=;0;[;{;IC;"0Returns the memory address for this handle. ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[;[;I";T;0; @5B;@F;Mi;N0;[; @5B;[;I"AReturns the memory address for this handle. @overload to_i;T;0; @5B;@F;Ao;B;CT;Di;Ei;!@A;"I"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); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Handle#close;F;[;[[@AiG;T;;;0;[;{;IC;"]Close this handle. Calling close more than once will raise a Fiddle::DLError exception. ;T;[o;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[;[;I";T;0; @KB;@F;Mi;N0;[; @KB;[;I"oClose this handle. Calling close more than once will raise a Fiddle::DLError exception. @overload close;T;0; @KB;@F;Ao;B;CT;Di@;EiE;!@A;"I"Vstatic 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_eFiddleError, "%s", dlerror()); #else rb_raise(rb_eFiddleError, "could not close handle"); #endif } return INT2NUM(ret); } rb_raise(rb_eFiddleError, "dlclose() called too many times"); UNREACHABLE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Handle#sym;F;[[I"sym;T0;[[@Ai;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; @aB;@F;Ao;B;CT;Di ;Ei;!@A;"I"Istatic 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_eFiddleError, "closed handle"); } return fiddle_handle_sym(fiddle_handle->ptr, sym); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Handle#[];F;[[I"sym;T0;[[@Ai;T;;;0;[;{;IC;"Vcall-seq: sym(name) Get the address as an Integer for the function named +name+. ;T;[;[;@mB;0; @qB;@F;Ao;B;CT;Di ;Ei;!@A;"I"Istatic 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_eFiddleError, "closed handle"); } return fiddle_handle_sym(fiddle_handle->ptr, sym); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!Fiddle::Handle#disable_close;F;[;[[@Ai;T;:disable_close;0;[;{;IC;"GDisable a call to dlclose() when this handle is garbage collected. ;T;[o;H ;II" overload;F;J0;;;K0;#I"disable_close;T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[; @B;[;I"aDisable a call to dlclose() when this handle is garbage collected. @overload disable_close;T;0; @B;@F;Ao;B;CT;Di;Ei;!@A;"I"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; ; F; ;,;;;I" Fiddle::Handle#enable_close;F;[;[[@Ai;T;:enable_close;0;[;{;IC;"FEnable a call to dlclose() when this handle is garbage collected. ;T;[o;H ;II" overload;F;J0;;;K0;#I"enable_close;T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[; @B;[;I"_Enable a call to dlclose() when this handle is garbage collected. @overload enable_close;T;0; @B;@F;Ao;B;CT;Di;Ei;!@A;"I"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; ; F; ;,;;;I""Fiddle::Handle#close_enabled?;F;[;[[@Ai;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;H ;II" overload;F;J0;;;K0;#I"close_enabled?;T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[; @Bo;L ;II" return;F;J@;0;K[@; @B;[;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; @B;@F;Ao;B;CT;Di;Ei;Mi;!@A;"I"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;&@A;'IC;[;&@A;(IC;[;&@A;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Ai|[@Ai;T;: Handle;;0;;;[;{;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; @A;@F;Ao;B;CT;Di|;Ei;!@>;I"Fiddle::Handle;F;1@wrap[1] = wrap; return obj; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Fiddle::Pointer.to_ptr;F;[[I"val;T0;[[@Bi;T;: to_ptr;0;[;{;IC;"`Get the underlying pointer for ruby object +val+ and return it as a Fiddle::Pointer object. ;T;[o;H ;II" overload;F;J0;:Fiddle::Pointer;K0;#I"Fiddle::Pointer[val];T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[; @Bo;H ;II" overload;F;J0;;;K0;#I"to_ptr(val);T;IC;";T;[;[;I";T;0; @B;@F;Mi;N0;[[I"val;T0; @B;[;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; @B;@F;Ao;B;CT;Diz;Ei;!@B;"I"rstatic 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); 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_eFiddleError, "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); } OBJ_INFECT(ptr, val); if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap; return ptr; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Fiddle::Pointer.[];F;[[I"val;T0;[[@Bi;T;;;0;[;{;IC;"`Get the underlying pointer for ruby object +val+ and return it as a Fiddle::Pointer object. ;T;[o;H ;II" overload;F;J0;;;K0;#I"Fiddle::Pointer[val];T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[; @Co;H ;II" overload;F;J0;;;K0;#I"to_ptr(val);T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[[I"val;T0; @C;[;@C;0; @C;@F;Ao;B;CT;Diz;Ei;!@B;"I"rstatic 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); 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_eFiddleError, "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); } OBJ_INFECT(ptr, val); if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap; return ptr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Pointer#initialize;F;[[I" argv[];T0[I" self;T0;[[@Bi;T;;;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;H ;II" overload;F;J0;:Fiddle::Pointer.new;K0;#I"!Fiddle::Pointer.new(address);T;IC;";T;[;[;I";T;0; @ fiddle_cptr;T;IC;";T;[;[;I";T;0; @ fiddle_cptr;T;IC;";T;[;[;I";T;0; @ fiddle_cptr @overload new(address, size, freefunc) => fiddle_cptr;T;0; @= 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; ; F; ;,;;;I"Fiddle::Pointer#free=;F;[[I"val;T0;[[@Bi9;T;: free=;0;[;{;IC;"XSet the free function for this pointer to +function+ in the given Fiddle::Function. ;T;[o;H ;II" overload;F;J0;;;K0;#I"free=(function);T;IC;";T;[;[;I";T;0; @rC;@F;Mi;N0;[[I" function;T0; @rC;[;I"tSet the free function for this pointer to +function+ in the given Fiddle::Function. @overload free=(function);T;0; @rC;@F;Ao;B;CT;Di3;Ei7;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#free;F;[;[[@BiM;T;;;0;[;{;IC;"sGet the free function for this pointer. Returns a new instance of Fiddle::Function. See Fiddle::Function.new ;T;[o;H ;II" overload;F;J0;;;K0;#I" free;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Fiddle::Function;T; @C;[;I"@return [Fiddle::Function];T;0; @C;@F;Mi;N0;[; @C;[;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; @C;@F;Ao;B;CT;DiD;EiL;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#to_i;F;[;[[@Bi;T;;=;0;[;{;IC;"9Returns the integer memory location of this pointer. ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[; @C;[;I"JReturns the integer memory location of this pointer. @overload to_i;T;0; @C;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#to_int;F;[;[[@Bi;T;;;0;[;{;IC;"9Returns the integer memory location of this pointer. ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[; @C;[;@C;0; @C;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#to_value;F;[;[[@Bi;T;: to_value;0;[;{;IC;"(Cast this pointer to a ruby object. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_value;T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[; @C;[;I"=Cast this pointer to a ruby object. @overload to_value;T;0; @C;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#ptr;F;[;[[@Bi ;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;H ;II" overload;F;J0;;;K0;#I"ptr;T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[; @C;[;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; @C;@F;Ao;B;CT;Di;Ei ;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#+@;F;[;[[@Bi ;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;H ;II" overload;F;J0;;;K0;#I"ptr;T;IC;";T;[;[;I";T;0; @C;@F;Mi;N0;[; @C;[;@C;0; @C;@F;Ao;B;CT;Di;Ei ;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#ref;F;[;[[@Bi;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;H ;II" overload;F;J0;;;K0;#I"ref;T;IC;";T;[;[;I";T;0; @D;@F;Mi;N0;[; @D;[;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; @D;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#-@;F;[;[[@Bi;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;H ;II" overload;F;J0;;;K0;#I"ref;T;IC;";T;[;[;I";T;0; @)D;@F;Mi;N0;[; @)D;[;@%D;0; @)D;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#null?;F;[;[[@Bi*;T;: null?;0;[;{;IC;".Returns +true+ if this is a null pointer.;T;[o;H ;II" overload;F;J0;;;K0;#I" null?;T;IC;";T;[;[;I";T;0; @>D;@F;Mi;N0;[; @>Do;L ;II" return;F;J@;0;K[@; @>D;[;I"@Returns +true+ if this is a null pointer. @overload null?;T;0; @>D;@F;Ao;B;CT;Di%;Ei(;Mi;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#to_s;F;[[I" argv[];T0[I" self;T0;[[@Biq;T;;h;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;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @WD;[;I"@return [String];T;0; @WD;@F;Mi;N0;[; @WDo;H ;II" overload;F;J0;;h;K0;#I"to_s(len);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @WD;[;I"@return [String];T;0; @WD;@F;Mi;N0;[[I"len;T0; @WD;[;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; @WD;@F;Ao;B;CT;Dib;Eio;!@B;"I"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_tainted_str_new2((char*)(data->ptr)); break; case 1: len = NUM2INT(arg1); val = rb_tainted_str_new((char*)(data->ptr), len); break; default: rb_bug("rb_fiddle_ptr_to_s"); } return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Pointer#to_str;F;[[I" argv[];T0[I" self;T0;[[@Bi;T;;?;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;H ;II" overload;F;J0;;?;K0;#I" to_str;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @D;[;I"@return [String];T;0; @D;@F;Mi;N0;[; @Do;H ;II" overload;F;J0;;?;K0;#I"to_str(len);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @D;[;I"@return [String];T;0; @D;@F;Mi;N0;[[I"len;T0; @D;[;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; @D;@F;Ao;B;CT;Di;Ei;!@B;"I"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_tainted_str_new((char*)(data->ptr),data->size); break; case 1: len = NUM2INT(arg1); val = rb_tainted_str_new((char*)(data->ptr), len); break; default: rb_bug("rb_fiddle_ptr_to_str"); } return val; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Pointer#inspect;F;[;[[@Bi;T;;i;0;[;{;IC;"lReturns a string formatted with an easily readable representation of the internal state of the pointer. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[;[;I";T;0; @D;@F;Mi;N0;[; @D;[;I"{Returns a string formatted with an easily readable representation of the internal state of the pointer. @overload inspect;T;0; @D;@F;Ao;B;CT;Di;Ei;!@B;"I":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; ; F; ;,;;;I"Fiddle::Pointer#<=>;F;[[I" other;T0;[[@Bi;T;;V;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;H ;II" overload;F;J0;;V;K0;#I"<=>(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"1;TI"nil;T; @D;[;I"@return [-1, 0, 1, nil];T;0; @D;@F;Mi;N0;[[I" other;T0; @D;[;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; @D;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#==;F;[[I" other;T0;[[@Bi;T;;S;0;[;{;IC;"MReturns true if +other+ wraps the same pointer, otherwise returns false. ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @D;[;I"@return [Boolean];T;0; @D;@F;Mi;N0;[[I" other;T0; @Do;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @D;[;I"@return [Boolean];T;0; @D;@F;Mi;N0;[[I" other;T0; @D;[;I"Returns true if +other+ wraps the same pointer, otherwise returns false. @overload ==(other) @return [Boolean] @overload eql?(other) @return [Boolean];T;0; @D;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#eql?;F;[[I" other;T0;[[@Bi;T;;R;0;[;{;IC;"MReturns true if +other+ wraps the same pointer, otherwise returns false.;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @E;[;I"@return [Boolean];T;0; @E;@F;Mi;N0;[[I" other;T0; @Eo;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @E;[;I"@return [Boolean];T;0; @E;@F;Mi;N0;[[I" other;T0; @E;[;@E;0; @E;@F;Ao;B;CT;Di;Ei;Mi;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#+;F;[[I" other;T0;[[@Bi;T;;(;0;[;{;IC;"EReturns a new pointer instance that has been advanced +n+ bytes. ;T;[o;H ;II" overload;F;J0;;(;K0;#I" +(n);T;IC;";T;[;[;I";T;0; @FE;@F;Mi;N0;[[I"n;T0; @FE;[;I"VReturns a new pointer instance that has been advanced +n+ bytes. @overload +(n);T;0; @FE;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#-;F;[[I" other;T0;[[@Bi;T;;<;0;[;{;IC;"GReturns a new pointer instance that has been moved back +n+ bytes. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" -(n);T;IC;";T;[;[;I";T;0; @`E;@F;Mi;N0;[[I"n;T0; @`E;[;I"XReturns a new pointer instance that has been moved back +n+ bytes. @overload -(n);T;0; @`E;@F;Ao;B;CT;Di;Ei;!@B;"I"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; ; F; ;,;;;I"Fiddle::Pointer#[];F;[[I" argv[];T0[I" self;T0;[[@Bi;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;H ;II" overload;F;J0;;;K0;#I"[](index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @zE;[;I"@return [Integer];T;0; @zE;@F;Mi;N0;[[I" index;T0; @zEo;H ;II" overload;F;J0;;;K0;#I"[](start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @zE;[;I"@return [String];T;0; @zE;@F;Mi;N0;[[I" start;T0[I" length;T0; @zE;[;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; @zE;@F;Ao;B;CT;Di;Ei;!@B;"I"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_eFiddleError, "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_tainted_str_new((char *)data->ptr + offset, len); break; default: rb_bug("rb_fiddle_ptr_aref()"); } return retval; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Pointer#[]=;F;[[I" argv[];T0[I" self;T0;[[@Bi=;T;;+;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;H ;II" overload;F;J0;;+;K0;#I"[]=(index);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @E;[;I"@return [Integer];T;0; @E;@F;Mi;N0;[[I" index;T0; @Eo;H ;II" overload;F;J0;;+;K0;#I"[]=(start, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @E;[;I"@return [String];T;0; @E;@F;Mi;N0;[[I" start;T0[I" length;T0; @E;[;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; @E;@F;Ao;B;CT;Di2;Ei<;!@B;"I"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_eFiddleError, "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; ; F; ;,;;;I"Fiddle::Pointer#size;F;[;[[@Bit;T;;;0;[;{;IC;""Get the size of this pointer. ;T;[o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[;[;I";T;0; @E;@F;Mi;N0;[; @E;[;I"3Get the size of this pointer. @overload size;T;0; @E;@F;Ao;B;CT;Dio;Eir;!@B;"I"dstatic VALUE rb_fiddle_ptr_size_get(VALUE self) { return LONG2NUM(RPTR_DATA(self)->size); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Fiddle::Pointer#size=;F;[[I" size;T0;[[@Bih;T;: size=;0;[;{;IC;"+Set the size of this pointer to +size+ ;T;[o;H ;II" overload;F;J0;;;K0;#I"size=(size);T;IC;";T;[;[;I";T;0; @E;@F;Mi;N0;[[I" size;T0; @E;[;I"CSet the size of this pointer to +size+ @overload size=(size);T;0; @E;@F;Ao;B;CT;Dic;Eif;!@B;"I"|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;&@B;'IC;[;&@B;(IC;[;&@B;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Bi[@Bi;T;: Pointer;;0;;;[;{;IC;"4Fiddle::Pointer is a class to handle C pointers ;T;[;[;I"7 Fiddle::Pointer is a class to handle C pointers ;T;0; @B;@F;Ao;B;CT;Di;Ei;!@>;I"Fiddle::Pointer;F;1@;I"Fiddle::NULL;F;= 1) { for (i = 0; i < argc; i++) { VALUE src = argv[i]; if (OBJ_TAINTED(src)) { rb_raise(rb_eSecurityError, "tainted parameter not allowed"); } } } generic_args = ALLOCV(alloc_buffer, (size_t)(argc + 1) * sizeof(void *) + (size_t)argc * sizeof(fiddle_generic)); args.values = (void **)((char *)generic_args + (size_t)argc * sizeof(fiddle_generic)); for (i = 0; i < argc; i++) { VALUE type = RARRAY_AREF(types, i); VALUE src = argv[i]; int argtype = FIX2INT(type); if (argtype == TYPE_VOIDP) { if(NIL_P(src)) { src = INT2FIX(0); } else if(cPointer != CLASS_OF(src)) { src = rb_funcall(cPointer, rb_intern("[]"), 1, src); } src = rb_Integer(src); } VALUE2GENERIC(argtype, src, &generic_args[i]); args.values[i] = (void *)&generic_args[i]; } args.values[argc] = NULL; args.fn = (void(*)(void))NUM2PTR(cfunc); (void)rb_thread_call_without_gvl(nogvl_ffi_call, &args, 0, 0); rb_funcall(mFiddle, rb_intern("last_error="), 1, INT2NUM(errno)); #if defined(_WIN32) rb_funcall(mFiddle, rb_intern("win32_last_error="), 1, INT2NUM(errno)); #endif ALLOCV_END(alloc_buffer); return GENERIC2VALUE(rb_iv_get(self, "@return_type"), args.retval); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Fiddle::Function#initialize;F;[[@0;[[I"ext/psych/psych_emitter.c;TiO;T;;;0;[;{;IC;"5Create a new Psych::Emitter that writes to +io+. ;T;[o;H ;II" overload;F;J0;:Psych::Emitter.new;K0;#I">Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS);T;IC;";T;[;[;I";T;0; @YF;@F;Mi;N0;[[I"io;T0[I" options;TI"Psych::Emitter::OPTIONS;T; @YF;[;I"{Create a new Psych::Emitter that writes to +io+. @overload Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS);T;0; @YF;@F;Ao;B;CT;DiK;EiN;!@,F;"I"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;$T;&@,F;'IC;[;&@,F;(IC;[;&@,F;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@1Fi[@1Fi ;T;: Function;;0;;;[;{;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;@F;Ao;B;CT;Di;Ei ;!@>;I"Fiddle::Function;F;1@<;&@>;'IC;[;&@>;(IC;[;&@>;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@>i[@>i'[@>i;T;: Fiddle;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!@;I" Fiddle;Fo; ;IC;[1o; ; F; ;,;;;I"Readline#readline;F;[[@0;[[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;H ;II" overload;F;J0;;;K0;#I",readline(prompt = "", add_hist = false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @F;[;I"@return [String, nil];T;0; @F;@F;Mi;N0;[[I" prompt;TI""";T[I" add_hist;TI" false;T; @F;[;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;@F;N0;!@F;"I"\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; ; T; ;;;;I"Readline.readline;F;@F;@F;T;;;0;@F;{;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;H ;II" overload;F;J0;;;K0;#I",readline(prompt = "", add_hist = false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @F;[;I"@return [String, nil];T;0; @F;@F;Mi;N0;[[I" prompt;TI""";T[I" add_hist;TI" false;T; @F;[;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;@F;Ao;B;CT;Di;Ei;Mi;!@F;"@F;#@F;$To; ; F; ;;;;I"Readline.input=;F;[[I" input;T0;[[@Fi(;T;: input=;0;[;{;IC;"WSpecifies a File object +input+ that is input stream for Readline.readline method. ;T;[o;H ;II" overload;F;J0;;;K0;#I"input=(input);T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[[I" input;T0; @F;[;I"qSpecifies a File object +input+ that is input stream for Readline.readline method. @overload input=(input);T;0; @F;@F;Ao;B;CT;Di!;Ei%;!@F;"I"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; ; F; ;;;;I"Readline.output=;F;[[I" output;T0;[[@FiL;T;: output=;0;[;{;IC;"YSpecifies a File object +output+ that is output stream for Readline.readline method. ;T;[o;H ;II" overload;F;J0;;;K0;#I"output=(output);T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[[I" output;T0; @F;[;I"uSpecifies a File object +output+ that is output stream for Readline.readline method. @overload output=(output);T;0; @F;@F;Ao;B;CT;DiE;EiI;!@F;"I"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; ; F; ;;;;I"Readline.completion_proc=;F;[[I" proc;T0;[[@FiF;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://svn.ruby-lang.org/repos/ruby/trunk/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;H ;II" overload;F;J0;;;K0;#I"completion_proc=(proc);T;IC;";T;[;[;I";T;0; @G;@F;Mi;N0;[[I" proc;T0; @G;[;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://svn.ruby-lang.org/repos/ruby/trunk/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; @G;@F;Ao;B;CT;Di;EiC;!@F;"I"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; ; F; ;;;;I"Readline.completion_proc;F;[;[[@FiS;T;:completion_proc;0;[;{;IC;"(Returns the completion Proc object. ;T;[o;H ;II" overload;F;J0;;;K0;#I"completion_proc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @*G;[;I"@return [Proc];T;0; @*G;@F;Mi;N0;[; @*G;[;I"UReturns the completion Proc object. @overload completion_proc @return [Proc];T;0; @*G;@F;Ao;B;CT;DiM;EiQ;!@F;"I"tstatic VALUE readline_s_get_completion_proc(VALUE self) { return rb_attr_get(mReadline, completion_proc); };T;#I"static VALUE;T;$To; ; F; ;;;;I"%Readline.quoting_detection_proc=;F;[[I" proc;T0;[[@Fio;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;H ;II" overload;F;J0;;;K0;#I""quoting_detection_proc=(proc);T;IC;";T;[;[;I";T;0; @EG;@F;Mi;N0;[[I" proc;T0; @EG;[;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; @EG;@F;Ao;B;CT;DiZ;Eil;!@F;"I"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; ; F; ;;;;I"$Readline.quoting_detection_proc;F;[;[[@Fi|;T;:quoting_detection_proc;0;[;{;IC;"/Returns the quoting detection Proc object. ;T;[o;H ;II" overload;F;J0;;;K0;#I"quoting_detection_proc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @_G;[;I"@return [Proc];T;0; @_G;@F;Mi;N0;[; @_G;[;I"cReturns the quoting detection Proc object. @overload quoting_detection_proc @return [Proc];T;0; @_G;@F;Ao;B;CT;Div;Eiz;!@F;"I"}static VALUE readline_s_get_quoting_detection_proc(VALUE self) { return rb_attr_get(mReadline, quoting_detection_proc); };T;#I"static VALUE;T;$To; ; F; ;;;;I"#Readline.completion_case_fold=;F;[[I"val;T0;[[@Fi;T;:completion_case_fold=;0;[;{;IC;"6Sets whether or not to ignore case on completion. ;T;[o;H ;II" overload;F;J0;;;K0;#I" completion_case_fold=(bool);T;IC;";T;[;[;I";T;0; @zG;@F;Mi;N0;[[I" bool;T0; @zG;[;I"^Sets whether or not to ignore case on completion. @overload completion_case_fold=(bool);T;0; @zG;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I""Readline.completion_case_fold;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"completion_case_fold;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @G;[;I"@return [Boolean];T;0; @G;@F;Mi;N0;[; @G;[;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; @G;@F;Ao;B;CT;Di;Ei;!@F;"I"~static VALUE readline_s_get_completion_case_fold(VALUE self) { return rb_attr_get(mReadline, completion_case_fold); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Readline.line_buffer;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"line_buffer;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @G;[;I"@return [String];T;0; @G;@F;Mi;N0;[; @G;[;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; @G;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I"Readline.point;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I" point;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @G;[;I"@return [Integer];T;0; @G;@F;Mi;N0;[; @G;[;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; @G;@F;Ao;B;CT;Di;Ei;!@F;"I"Tstatic VALUE readline_s_get_point(VALUE self) { return INT2NUM(rl_point); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Readline.point=;F;[[I"pos;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"point=(int);T;IC;";T;[;[;I";T;0; @G;@F;Mi;N0;[[I"int;T0; @G;[;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; @G;@F;Ao;B;CT;Di;Ei;!@F;"I"nstatic VALUE readline_s_set_point(VALUE self, VALUE pos) { rl_point = NUM2INT(pos); return pos; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Readline.set_screen_size;F;[[I" rows;T0[I" columns;T0;[[@FiZ;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;H ;II" overload;F;J0;;;K0;#I"#set_screen_size(rows, columns);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @G;[;I"@return [self];T;0; @G;@F;Mi;N0;[[I" rows;T0[I" columns;T0; @G;[;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; @G;@F;Ao;B;CT;DiP;EiX;!@F;"I"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; ; F; ;;;;I"Readline.get_screen_size;F;[;[[@Fio;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;H ;II" overload;F;J0;;;K0;#I"get_screen_size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @"H;[;I"@return [Array];T;0; @"H;@F;Mi;N0;[; @"H;[;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; @"H;@F;Ao;B;CT;Die;Eim;!@F;"I"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; ; F; ;;;;I"Readline.vi_editing_mode;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"vi_editing_mode;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @=H;[;I"@return [nil];T;0; @=H;@F;Mi;N0;[; @=H;[;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; @=H;@F;Ao;B;CT;Di;Ei;!@F;"I"jstatic VALUE readline_s_vi_editing_mode(VALUE self) { rl_vi_editing_mode(1,0); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Readline.vi_editing_mode?;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"vi_editing_mode?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @XH;[;I"@return [Boolean];T;0; @XH;@F;Mi;N0;[; @XH;[;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; @XH;@F;Ao;B;CT;Di;Ei;Mi;!@F;"I"pstatic VALUE readline_s_vi_editing_mode_p(VALUE self) { return rl_editing_mode == 0 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I" Readline.emacs_editing_mode;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"emacs_editing_mode;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @sH;[;I"@return [nil];T;0; @sH;@F;Mi;N0;[; @sH;[;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; @sH;@F;Ao;B;CT;Di;Ei;!@F;"I"pstatic VALUE readline_s_emacs_editing_mode(VALUE self) { rl_emacs_editing_mode(1,0); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"!Readline.emacs_editing_mode?;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"emacs_editing_mode?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @H;[;I"@return [Boolean];T;0; @H;@F;Mi;N0;[; @H;[;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; @H;@F;Ao;B;CT;Di;Ei;Mi;!@F;"I"sstatic VALUE readline_s_emacs_editing_mode_p(VALUE self) { return rl_editing_mode == 1 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"*Readline.completion_append_character=;F;[[I"str;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"'completion_append_character=(char);T;IC;";T;[;[;I";T;0; @H;@F;Mi;N0;[[I" char;T0; @H;[;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; @H;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I")Readline.completion_append_character;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I" completion_append_character;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @H;[;I"@return [String];T;0; @H;@F;Mi;N0;[; @H;[;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; @H;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I"(Readline.completion_quote_character;F;[;[[@Fi-;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;H ;II" overload;F;J0;;;K0;#I"completion_quote_character;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @H;[;I"@return [String];T;0; @H;@F;Mi;N0;[; @H;[;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; @H;@F;Ao;B;CT;Di ;Ei+;!@F;"I"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; ; F; ;;;;I"*Readline.basic_word_break_characters=;F;[[I"str;T0;[[@FiG;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;H ;II" overload;F;J0;;;K0;#I")basic_word_break_characters=(string);T;IC;";T;[;[;I";T;0; @H;@F;Mi;N0;[[I" string;T0; @H;[;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; @H;@F;Ao;B;CT;Di=;EiD;!@F;"I"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; ; F; ;;;;I")Readline.basic_word_break_characters;F;[[I"str;T0;[[@Fih;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;H ;II" overload;F;J0;;;K0;#I" basic_word_break_characters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[; @I;[;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; @I;@F;Ao;B;CT;Di_;Eif;!@F;"I"static VALUE readline_s_get_basic_word_break_characters(VALUE self, VALUE str) { 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; ; F; ;;;;I".Readline.completer_word_break_characters=;F;[[I"str;T0;[[@Fi~;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;H ;II" overload;F;J0;;;K0;#I"-completer_word_break_characters=(string);T;IC;";T;[;[;I";T;0; @0I;@F;Mi;N0;[[I" string;T0; @0I;[;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; @0I;@F;Ao;B;CT;Dit;Ei{;!@F;"I"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; ; F; ;;;;I"-Readline.completer_word_break_characters;F;[[I"str;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"$completer_word_break_characters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @JI;[;I"@return [String];T;0; @JI;@F;Mi;N0;[; @JI;[;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; @JI;@F;Ao;B;CT;Di;Ei;!@F;"I"static VALUE readline_s_get_completer_word_break_characters(VALUE self, VALUE str) { 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; ; F; ;;;;I"%Readline.basic_quote_characters=;F;[[I"str;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"$basic_quote_characters=(string);T;IC;";T;[;[;I";T;0; @gI;@F;Mi;N0;[[I" string;T0; @gI;[;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; @gI;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I"$Readline.basic_quote_characters;F;[[I"str;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"basic_quote_characters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[; @I;[;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; @I;@F;Ao;B;CT;Di ;Ei;!@F;"I"static VALUE readline_s_get_basic_quote_characters(VALUE self, VALUE str) { if (rl_basic_quote_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_basic_quote_characters); };T;#I"static VALUE;T;$To; ; F; ;;;;I")Readline.completer_quote_characters=;F;[[I"str;T0;[[@Fi);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;H ;II" overload;F;J0;;;K0;#I"(completer_quote_characters=(string);T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[[I" string;T0; @I;[;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; @I;@F;Ao;B;CT;Di;Ei&;!@F;"I"`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; ; F; ;;;;I"(Readline.completer_quote_characters;F;[[I"str;T0;[[@FiJ;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;H ;II" overload;F;J0;;;K0;#I"completer_quote_characters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[; @I;[;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; @I;@F;Ao;B;CT;DiA;EiH;!@F;"I"static VALUE readline_s_get_completer_quote_characters(VALUE self, VALUE str) { if (rl_completer_quote_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_completer_quote_characters); };T;#I"static VALUE;T;$To; ; F; ;;;;I"(Readline.filename_quote_characters=;F;[[I"str;T0;[[@Fi_;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;H ;II" overload;F;J0;;;K0;#I"'filename_quote_characters=(string);T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[[I" string;T0; @I;[;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; @I;@F;Ao;B;CT;DiV;Ei\;!@F;"I"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; ; F; ;;;;I"'Readline.filename_quote_characters;F;[[I"str;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"filename_quote_characters;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[; @I;[;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; @I;@F;Ao;B;CT;Diw;Ei~;!@F;"I"static VALUE readline_s_get_filename_quote_characters(VALUE self, VALUE str) { if (rl_filename_quote_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_filename_quote_characters); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Readline.refresh_line;F;[;[[@Fi;T;:refresh_line;0;[;{;IC;""Clear the current input line. ;T;[o;H ;II" overload;F;J0;;;K0;#I"refresh_line;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ J;[;I"@return [nil];T;0; @ J;@F;Mi;N0;[; @ J;[;I"KClear the current input line. @overload refresh_line @return [nil];T;0; @ J;@F;Ao;B;CT;Di;Ei;!@F;"I"}static VALUE readline_s_refresh_line(VALUE self) { prepare_readline(); rl_refresh_line(0, 0); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Readline.pre_input_hook=;F;[[I" proc;T0;[[@Fix;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;H ;II" overload;F;J0;;;K0;#I"pre_input_hook=(proc);T;IC;";T;[;[;I";T;0; @'J;@F;Mi;N0;[[I" proc;T0; @'J;[;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; @'J;@F;Ao;B;CT;Dij;Eiu;!@F;"I"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; ; F; ;;;;I"Readline.pre_input_hook;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"pre_input_hook;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Proc;T; @AJ;[;I"@return [Proc];T;0; @AJ;@F;Mi;N0;[; @AJ;[;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; @AJ;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I"Readline.insert_text;F;[[I"str;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"insert_text(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @\J;[;I"@return [self];T;0; @\J;@F;Mi;N0;[[I" string;T0; @\J;[;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; @\J;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I"Readline.delete_text;F;[[@0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"#delete_text([start[, length]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @{J;[;I"@return [self];T;0; @{J;@F;Mi;N0;[[I"[start[, length]];T0; @{Jo;H ;II" overload;F;J0;;;K0;#I"delete_text(start..end);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @{J;[;I"@return [self];T;0; @{J;@F;Mi;N0;[[I"start..end;T0; @{Jo;H ;II" overload;F;J0;;;K0;#I"delete_text();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @{J;[;I"@return [self];T;0; @{J;@F;Mi;N0;[; @{J;[;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; @{J;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I"Readline.redisplay;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"redisplay;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @J;[;I"@return [self];T;0; @J;@F;Mi;N0;[; @J;[;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; @J;@F;Ao;B;CT;Di;Ei;!@F;"I"[static VALUE readline_s_redisplay(VALUE self) { rl_redisplay(); return self; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Readline.special_prefixes=;F;[[I"str;T0;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"special_prefixes=(string);T;IC;";T;[;[;I";T;0; @J;@F;Mi;N0;[[I" string;T0; @J;[;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; @J;@F;Ao;B;CT;Di;Ei;!@F;"I"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; ; F; ;;;;I"Readline.special_prefixes;F;[;[[@Fi;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;H ;II" overload;F;J0;;;K0;#I"special_prefixes;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @J;[;I"@return [String];T;0; @J;@F;Mi;N0;[; @J;[;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; @J;@F;Ao;B;CT;Di;Ei;!@F;"I"/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;9;[[@Fi;F;: HISTORY;;;;;;[;{;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; @K;@F;Ao;B;CT;Di ;Ei;!@F;I"Readline::HISTORY;F;Raised when errors occur during PKey#sign or PKey#verify. ;T;[;[;I"@ Raised when errors occur during PKey#sign or PKey#verify. ;T;0; @K;@F;Ao;B;CT;Di;Ei;!@K;I"OpenSSL::PKey::PKeyError;F;1@FKo; ;IC;[o; ; F; ;,;;;I"#OpenSSL::PKey::PKey#initialize;F;[;[[@QKi;T;;;0;[;{;IC;"qBecause PKey is an abstract class, actually calling this method explicitly will raise a NotImplementedError. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @K;[;I"@return [self];T;0; @K;@F;Mi;N0;[; @K;[;I"Because PKey is an abstract class, actually calling this method explicitly will raise a NotImplementedError. @overload new @return [self];T;0; @K;@F;Ao;B;CT;Di;Ei;!@K;"I"static VALUE ossl_pkey_initialize(VALUE self) { if (rb_obj_is_instance_of(self, cPKey)) { ossl_raise(rb_eTypeError, "OpenSSL::PKey::PKey can't be instantiated directly"); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::PKey#sign;F;[[I" digest;T0[I" data;T0;[[@QKi9;T;;;0;[;{;IC;"To sign the String _data_, _digest_, an instance of OpenSSL::Digest, must be provided. The return value is again a String containing the signature. A PKeyError is raised should errors occur. Any previous state of the Digest instance is irrelevant to the signature outcome, the digest instance is reset to its initial state during the operation. == Example data = 'Sign me!' digest = OpenSSL::Digest::SHA256.new pkey = OpenSSL::PKey::RSA.new(2048) signature = pkey.sign(digest, data) ;T;[o;H ;II" overload;F;J0;;;K0;#I"sign(digest, data);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @K;[;I"@return [String];T;0; @K;@F;Mi;N0;[[I" digest;T0[I" data;T0; @K;[;I"To sign the String _data_, _digest_, an instance of OpenSSL::Digest, must be provided. The return value is again a String containing the signature. A PKeyError is raised should errors occur. Any previous state of the Digest instance is irrelevant to the signature outcome, the digest instance is reset to its initial state during the operation. == Example data = 'Sign me!' digest = OpenSSL::Digest::SHA256.new pkey = OpenSSL::PKey::RSA.new(2048) signature = pkey.sign(digest, data) @overload sign(digest, data) @return [String];T;0; @K;@F;Ao;B;CT;Di(;Ei7;!@K;"I"static VALUE ossl_pkey_sign(VALUE self, VALUE digest, VALUE data) { EVP_PKEY *pkey; const EVP_MD *md; EVP_MD_CTX *ctx; unsigned int buf_len; VALUE str; int result; pkey = GetPrivPKeyPtr(self); md = ossl_evp_get_digestbyname(digest); StringValue(data); str = rb_str_new(0, EVP_PKEY_size(pkey)); ctx = EVP_MD_CTX_new(); if (!ctx) ossl_raise(ePKeyError, "EVP_MD_CTX_new"); if (!EVP_SignInit_ex(ctx, md, NULL)) { EVP_MD_CTX_free(ctx); ossl_raise(ePKeyError, "EVP_SignInit_ex"); } if (!EVP_SignUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data))) { EVP_MD_CTX_free(ctx); ossl_raise(ePKeyError, "EVP_SignUpdate"); } result = EVP_SignFinal(ctx, (unsigned char *)RSTRING_PTR(str), &buf_len, pkey); EVP_MD_CTX_free(ctx); if (!result) ossl_raise(ePKeyError, "EVP_SignFinal"); rb_str_set_len(str, buf_len); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::PKey#verify;F;[[I" digest;T0[I"sig;T0[I" data;T0;[[@QKiq;T;: verify;0;[;{;IC;"To verify the String _signature_, _digest_, an instance of OpenSSL::Digest, must be provided to re-compute the message digest of the original _data_, also a String. The return value is +true+ if the signature is valid, +false+ otherwise. A PKeyError is raised should errors occur. Any previous state of the Digest instance is irrelevant to the validation outcome, the digest instance is reset to its initial state during the operation. == Example data = 'Sign me!' digest = OpenSSL::Digest::SHA256.new pkey = OpenSSL::PKey::RSA.new(2048) signature = pkey.sign(digest, data) pub_key = pkey.public_key puts pub_key.verify(digest, signature, data) # => true ;T;[o;H ;II" overload;F;J0;;;K0;#I"$verify(digest, signature, data);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @K;[;I"@return [String];T;0; @K;@F;Mi;N0;[[I" digest;T0[I"signature;T0[I" data;T0; @K;[;I"To verify the String _signature_, _digest_, an instance of OpenSSL::Digest, must be provided to re-compute the message digest of the original _data_, also a String. The return value is +true+ if the signature is valid, +false+ otherwise. A PKeyError is raised should errors occur. Any previous state of the Digest instance is irrelevant to the validation outcome, the digest instance is reset to its initial state during the operation. == Example data = 'Sign me!' digest = OpenSSL::Digest::SHA256.new pkey = OpenSSL::PKey::RSA.new(2048) signature = pkey.sign(digest, data) pub_key = pkey.public_key puts pub_key.verify(digest, signature, data) # => true @overload verify(digest, signature, data) @return [String];T;0; @K;@F;Ao;B;CT;Di\;Eio;!@K;"I"static VALUE ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data) { EVP_PKEY *pkey; const EVP_MD *md; EVP_MD_CTX *ctx; int siglen, result; GetPKey(self, pkey); ossl_pkey_check_public_key(pkey); md = ossl_evp_get_digestbyname(digest); StringValue(sig); siglen = RSTRING_LENINT(sig); StringValue(data); ctx = EVP_MD_CTX_new(); if (!ctx) ossl_raise(ePKeyError, "EVP_MD_CTX_new"); if (!EVP_VerifyInit_ex(ctx, md, NULL)) { EVP_MD_CTX_free(ctx); ossl_raise(ePKeyError, "EVP_VerifyInit_ex"); } if (!EVP_VerifyUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data))) { EVP_MD_CTX_free(ctx); ossl_raise(ePKeyError, "EVP_VerifyUpdate"); } result = EVP_VerifyFinal(ctx, (unsigned char *)RSTRING_PTR(sig), siglen, pkey); EVP_MD_CTX_free(ctx); switch (result) { case 0: ossl_clear_error(); return Qfalse; case 1: return Qtrue; default: ossl_raise(ePKeyError, "EVP_VerifyFinal"); } };T;#I"static VALUE;T;$T;&@K;'IC;[;&@K;(IC;[;&@K;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[ [@QKi[@QKi[@Kie[@Kit[@SKiw[@KiD;T;: PKey;;0;;;[;{;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; @K;@F;Ao;B;CT;Di;Ei;!@K;I"OpenSSL::PKey::PKey;F;1@ dsa DSA.new(1024) -> dsa DSA.new(File.read('dsa.pem')) -> dsa DSA.new(File.read('dsa.pem'), 'mypassword') -> dsa ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[; @Lo;H ;II" overload;F;J0;; ;K0;#I"new(size);T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[[I" size;T0; @Lo;H ;II" overload;F;J0;; ;K0;#I"new(string [, pass]);T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[[I"string[, pass];T0; @L;[;I"Creates a new DSA instance by reading an existing key from _string_. === Parameters * _size_ is an integer representing the desired key size. * _string_ contains a DER or PEM encoded key. * _pass_ is a string that contains an optional password. === Examples DSA.new -> dsa DSA.new(1024) -> dsa DSA.new(File.read('dsa.pem')) -> dsa DSA.new(File.read('dsa.pem'), 'mypassword') -> dsa @overload new @overload new(size) @overload new(string [, pass]);T;0; @L;@F;Ao;B;CT;Di;Ei;!@L;"I"Wstatic VALUE ossl_dsa_initialize(int argc, VALUE *argv, VALUE self) { EVP_PKEY *pkey; DSA *dsa; BIO *in; VALUE arg, pass; GetPKey(self, pkey); if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) { dsa = DSA_new(); } else if (RB_INTEGER_TYPE_P(arg)) { if (!(dsa = dsa_generate(NUM2INT(arg)))) { ossl_raise(eDSAError, NULL); } } else { pass = ossl_pem_passwd_value(pass); arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); dsa = PEM_read_bio_DSAPrivateKey(in, NULL, ossl_pem_passwd_cb, (void *)pass); if (!dsa) { OSSL_BIO_reset(in); dsa = PEM_read_bio_DSA_PUBKEY(in, NULL, NULL, NULL); } if (!dsa) { OSSL_BIO_reset(in); dsa = d2i_DSAPrivateKey_bio(in, NULL); } if (!dsa) { OSSL_BIO_reset(in); dsa = d2i_DSA_PUBKEY_bio(in, NULL); } if (!dsa) { OSSL_BIO_reset(in); #define PEM_read_bio_DSAPublicKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ (d2i_of_void *)d2i_DSAPublicKey, PEM_STRING_DSA_PUBLIC, (bp), (void **)(x), (cb), (u)) dsa = PEM_read_bio_DSAPublicKey(in, NULL, NULL, NULL); #undef PEM_read_bio_DSAPublicKey } BIO_free(in); if (!dsa) { ossl_clear_error(); ossl_raise(eDSAError, "Neither PUB key nor PRIV key"); } } if (!EVP_PKEY_assign_DSA(pkey, dsa)) { DSA_free(dsa); ossl_raise(eDSAError, NULL); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"'OpenSSL::PKey::DSA#initialize_copy;F;[[I" other;T0;[[@Ki ;T;;];0;[;{;IC;" ;T;[;[;@;0; @L;!@L;"I"static VALUE ossl_dsa_initialize_copy(VALUE self, VALUE other) { EVP_PKEY *pkey; DSA *dsa, *dsa_new; GetPKey(self, pkey); if (EVP_PKEY_base_id(pkey) != EVP_PKEY_NONE) ossl_raise(eDSAError, "DSA already initialized"); GetDSA(other, dsa); dsa_new = ASN1_dup((i2d_of_void *)i2d_DSAPrivateKey, (d2i_of_void *)d2i_DSAPrivateKey, (char *)dsa); if (!dsa_new) ossl_raise(eDSAError, "ASN1_dup"); EVP_PKEY_assign_DSA(pkey, dsa_new); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::DSA#public?;F;[;[[@Ki&;T;: public?;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;H ;II" overload;F;J0;;;K0;#I" public?;T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[; @Lo;L ;II" return;F;J@;0;K[@; @L;[;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; @L;@F;Ao;B;CT;Di;Ei#;Mi;!@L;"I"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; ; F; ;,;;;I" OpenSSL::PKey::DSA#private?;F;[;[[@Ki9;T;: private?;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;H ;II" overload;F;J0;;;K0;#I" private?;T;IC;";T;[;[;I";T;0; @L;@F;Mi;N0;[; @Lo;L ;II" return;F;J@;0;K[@; @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; @L;@F;Ao;B;CT;Di2;Ei6;Mi;!@L;"I"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; ; F; ;,;;;I"OpenSSL::PKey::DSA#to_text;F;[;[[@Ki;T;: to_text;0;[;{;IC;"yPrints all parameters of key to buffer INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_text;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @M;[;I"@return [aString];T;0; @M;@F;Mi;N0;[; @M;[;I"Prints all parameters of key to buffer INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) @overload to_text @return [aString];T;0; @M;@F;Ao;B;CT;Di;Ei;!@L;"I"Vstatic VALUE ossl_dsa_to_text(VALUE self) { DSA *dsa; BIO *out; VALUE str; GetDSA(self, dsa); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDSAError, NULL); } if (!DSA_print(out, dsa, 0)) { /* offset = 0 */ BIO_free(out); ossl_raise(eDSAError, NULL); } str = ossl_membio2str(out); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::DSA#export;F;[[@0;[[@KiT;T;: export;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;H ;II" overload;F;J0;;;K0;#I"export([cipher, password]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @+M;[;I"@return [aString];T;0; @+M;@F;Mi;N0;[[I"[cipher, password];T0; @+Mo;H ;II" overload;F;J0;: to_pem;K0;#I"to_pem([cipher, password]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @+M;[;I"@return [aString];T;0; @+M;@F;Mi;N0;[[I"[cipher, password];T0; @+Mo;H ;II" overload;F;J0;;h;K0;#I"to_s([cipher, password]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @+M;[;I"@return [aString];T;0; @+M;@F;Mi;N0;[[I"[cipher, password];T0; @+M;[;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; ; F; ;,;;;I"OpenSSL::PKey::DSA#to_s;F;[;[[@Ki;F;;h;;0;[;{;@3M;!@L;"I"static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self) { DSA *dsa; BIO *out; const EVP_CIPHER *ciph = NULL; VALUE cipher, pass, str; GetDSA(self, dsa); rb_scan_args(argc, argv, "02", &cipher, &pass); if (!NIL_P(cipher)) { ciph = ossl_evp_get_cipherbyname(cipher); pass = ossl_pem_passwd_value(pass); } if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDSAError, NULL); } if (DSA_HAS_PRIVATE(dsa)) { if (!PEM_write_bio_DSAPrivateKey(out, dsa, ciph, NULL, 0, ossl_pem_passwd_cb, (void *)pass)){ BIO_free(out); ossl_raise(eDSAError, NULL); } } else { if (!PEM_write_bio_DSA_PUBKEY(out, dsa)) { BIO_free(out); ossl_raise(eDSAError, NULL); } } str = ossl_membio2str(out); return str; };T;#I"static VALUE;T;@F;Ao;B;CT;DiC;EiT;!@L;"I"static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self) { DSA *dsa; BIO *out; const EVP_CIPHER *ciph = NULL; VALUE cipher, pass, str; GetDSA(self, dsa); rb_scan_args(argc, argv, "02", &cipher, &pass); if (!NIL_P(cipher)) { ciph = ossl_evp_get_cipherbyname(cipher); pass = ossl_pem_passwd_value(pass); } if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDSAError, NULL); } if (DSA_HAS_PRIVATE(dsa)) { if (!PEM_write_bio_DSAPrivateKey(out, dsa, ciph, NULL, 0, ossl_pem_passwd_cb, (void *)pass)){ BIO_free(out); ossl_raise(eDSAError, NULL); } } else { if (!PEM_write_bio_DSA_PUBKEY(out, dsa)) { BIO_free(out); ossl_raise(eDSAError, NULL); } } str = ossl_membio2str(out); return str; };T;#@lM;$To; ; F; ;,;;;I"OpenSSL::PKey::DSA#to_pem;F;[;[[@Ki;F;;;;0;[;{;@3M;!@L;"I"static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self) { DSA *dsa; BIO *out; const EVP_CIPHER *ciph = NULL; VALUE cipher, pass, str; GetDSA(self, dsa); rb_scan_args(argc, argv, "02", &cipher, &pass); if (!NIL_P(cipher)) { ciph = ossl_evp_get_cipherbyname(cipher); pass = ossl_pem_passwd_value(pass); } if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDSAError, NULL); } if (DSA_HAS_PRIVATE(dsa)) { if (!PEM_write_bio_DSAPrivateKey(out, dsa, ciph, NULL, 0, ossl_pem_passwd_cb, (void *)pass)){ BIO_free(out); ossl_raise(eDSAError, NULL); } } else { if (!PEM_write_bio_DSA_PUBKEY(out, dsa)) { BIO_free(out); ossl_raise(eDSAError, NULL); } } str = ossl_membio2str(out); return str; };T;#@lM@dMo; ; F; ;,;;;I"OpenSSL::PKey::DSA#to_der;F;[;[[@Ki};T;: to_der;0;[;{;IC;"*Encodes this DSA to its DER encoding. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @wM;[;I"@return [aString];T;0; @wM;@F;Mi;N0;[; @wM;[;I"REncodes this DSA to its DER encoding. @overload to_der @return [aString];T;0; @wM;@F;Ao;B;CT;Div;Ei{;!@L;"I"/static VALUE ossl_dsa_to_der(VALUE self) { DSA *dsa; int (*i2d_func)(DSA *, unsigned char **); unsigned char *p; long len; VALUE str; GetDSA(self, dsa); if(DSA_HAS_PRIVATE(dsa)) i2d_func = (int (*)(DSA *,unsigned char **))i2d_DSAPrivateKey; else i2d_func = i2d_DSA_PUBKEY; if((len = i2d_func(dsa, NULL)) <= 0) ossl_raise(eDSAError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_func(dsa, &p) < 0) ossl_raise(eDSAError, NULL); ossl_str_adjust(str, p); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""OpenSSL::PKey::DSA#public_key;F;[;[[@Ki;T;:public_key;0;[;{;IC;"Returns a new DSA instance that carries just the public key information. If the current instance has also private key information, this will no longer be present in the new instance. This feature is helpful for publishing the public key information without leaking any of the private information. === Example dsa = OpenSSL::PKey::DSA.new(2048) # has public and private information pub_key = dsa.public_key # has only the public part available pub_key_der = pub_key.to_der # it's safe to publish this ;T;[o;H ;II" overload;F;J0;; ;K0;#I"public_key;T;IC;";T;[;[;I";T;0; @M;@F;Mi;N0;[; @M;[;I" Returns a new DSA instance that carries just the public key information. If the current instance has also private key information, this will no longer be present in the new instance. This feature is helpful for publishing the public key information without leaking any of the private information. === Example dsa = OpenSSL::PKey::DSA.new(2048) # has public and private information pub_key = dsa.public_key # has only the public part available pub_key_der = pub_key.to_der # it's safe to publish this @overload public_key;T;0; @M;@F;Ao;B;CT;Di;Ei;!@L;"I" static VALUE ossl_dsa_to_public_key(VALUE self) { EVP_PKEY *pkey; DSA *dsa; VALUE obj; GetPKeyDSA(self, pkey); /* err check performed by dsa_instance */ #define DSAPublicKey_dup(dsa) (DSA *)ASN1_dup( \ (i2d_of_void *)i2d_DSAPublicKey, (d2i_of_void *)d2i_DSAPublicKey, (char *)(dsa)) dsa = DSAPublicKey_dup(EVP_PKEY_get0_DSA(pkey)); #undef DSAPublicKey_dup obj = dsa_instance(rb_obj_class(self), dsa); if (obj == Qfalse) { DSA_free(dsa); ossl_raise(eDSAError, NULL); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::DSA#syssign;F;[[I" data;T0;[[@Ki ;T;: syssign;0;[;{;IC;"Computes and returns the DSA signature of _string_, where _string_ is expected to be an already-computed message digest of the original input data. The signature is issued using the private key of this DSA instance. === Parameters * _string_ is a message digest of the original input data to be signed. === Example dsa = OpenSSL::PKey::DSA.new(2048) doc = "Sign me" digest = OpenSSL::Digest::SHA1.digest(doc) sig = dsa.syssign(digest) ;T;[o;H ;II" overload;F;J0;; ;K0;#I"syssign(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @M;[;I"@return [aString];T;0; @M;@F;Mi;N0;[[I" string;T0; @M;[;I"Computes and returns the DSA signature of _string_, where _string_ is expected to be an already-computed message digest of the original input data. The signature is issued using the private key of this DSA instance. === Parameters * _string_ is a message digest of the original input data to be signed. === Example dsa = OpenSSL::PKey::DSA.new(2048) doc = "Sign me" digest = OpenSSL::Digest::SHA1.digest(doc) sig = dsa.syssign(digest) @overload syssign(string) @return [aString];T;0; @M;@F;Ao;B;CT;Di;Ei;!@L;"I"static VALUE ossl_dsa_sign(VALUE self, VALUE data) { DSA *dsa; const BIGNUM *dsa_q; unsigned int buf_len; VALUE str; GetDSA(self, dsa); DSA_get0_pqg(dsa, NULL, &dsa_q, NULL); if (!dsa_q) ossl_raise(eDSAError, "incomplete DSA"); if (!DSA_PRIVATE(self, dsa)) ossl_raise(eDSAError, "Private DSA key needed!"); StringValue(data); str = rb_str_new(0, DSA_size(dsa)); if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *)RSTRING_PTR(str), &buf_len, dsa)) { /* type is ignored (0) */ ossl_raise(eDSAError, NULL); } rb_str_set_len(str, buf_len); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!OpenSSL::PKey::DSA#sysverify;F;[[I" digest;T0[I"sig;T0;[[@Ki6;T;:sysverify;0;[;{;IC;"Verifies whether the signature is valid given the message digest input. It does so by validating _sig_ using the public key of this DSA instance. === Parameters * _digest_ is a message digest of the original input data to be signed * _sig_ is a DSA signature value === Example dsa = OpenSSL::PKey::DSA.new(2048) doc = "Sign me" digest = OpenSSL::Digest::SHA1.digest(doc) sig = dsa.syssign(digest) puts dsa.sysverify(digest, sig) # => true ;T;[o;H ;II" overload;F;J0;; ;K0;#I"sysverify(digest, sig);T;IC;";T;[;[;I";T;0; @M;@F;Mi;N0;[[I" digest;T0[I"sig;T0; @M;[;I"Verifies whether the signature is valid given the message digest input. It does so by validating _sig_ using the public key of this DSA instance. === Parameters * _digest_ is a message digest of the original input data to be signed * _sig_ is a DSA signature value === Example dsa = OpenSSL::PKey::DSA.new(2048) doc = "Sign me" digest = OpenSSL::Digest::SHA1.digest(doc) sig = dsa.syssign(digest) puts dsa.sysverify(digest, sig) # => true @overload sysverify(digest, sig);T;0; @M;@F;Ao;B;CT;Di#;Ei3;!@L;"I"static VALUE ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig) { DSA *dsa; int ret; GetDSA(self, dsa); StringValue(digest); StringValue(sig); /* type is ignored (0) */ ret = DSA_verify(0, (unsigned char *)RSTRING_PTR(digest), RSTRING_LENINT(digest), (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), dsa); if (ret < 0) { ossl_raise(eDSAError, NULL); } else if (ret == 1) { return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::DSA#set_pqg;F;[;[;F;: set_pqg;;0;[;{;IC;",Sets _p_, _q_, _g_ to the DSA instance. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"set_pqg(p, q, g);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @M;[;I"@return [self];T;0; @M;@F;Mi;N0;[[I"p;T0[I"q;T0[I"g;T0; @M;[;I"ZSets _p_, _q_, _g_ to the DSA instance. @overload set_pqg(p, q, g) @return [self];T;0; @M;@F;Ao;B;CT;DiL;EiP;!@L;$To; ; F; ;,;;;I"OpenSSL::PKey::DSA#set_key;F;[;[;F;: set_key;;0;[;{;IC;"QSets _pub_key_ and _priv_key_ for the DSA instance. _priv_key_ may be +nil+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"set_key(pub_key, priv_key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @N;[;I"@return [self];T;0; @N;@F;Mi;N0;[[I" pub_key;T0[I" priv_key;T0; @N;[;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; @N;@F;Ao;B;CT;DiT;EiX;!@L;$To; ; F; ;,;;;I"OpenSSL::PKey::DSA#params;F;[;[[@Ki;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;H ;II" overload;F;J0;;;K0;#I" params;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @N;[;I"@return [Hash];T;0; @N;@F;Mi;N0;[; @N;[;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; @N;@F;Ao;B;CT;Di;Ei;!@L;"I"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;&@L;'IC;[;&@L;(IC;[;&@L;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@oM;@dM;;.[;[[@Kiq[@Kiw;T;:DSA;;0;;;[;{;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; @L;@F;Ao;B;CT;Diq;Eiu;!@K;I"OpenSSL::PKey::DSA;F;1@Ko; ;IC;[;&@LN;'IC;[;&@LN;(IC;[;&@LN;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Kix[@Ki~;T;: RSAError;;0;;;[;{;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; @LN;@F;Ao;B;CT;Dix;Ei|;!@K;I"OpenSSL::PKey::RSAError;F;1@Ko; ;IC;[o; ; F; ;;;;I" OpenSSL::PKey::RSA.generate;F;[[@0;[[@Ki;T;;;0;[;{;IC;"Generates an RSA keypair. _size_ is an integer representing the desired key size. Keys smaller than 1024 should be considered insecure. _exponent_ is an odd number normally 3, 17, or 65537. ;T;[o;H ;II" overload;F;J0;;;K0;#I"generate(size);T;IC;";T;[;[;I";T;0; @bN;@F;Mi;N0;[[I" size;T0; @bNo;H ;II" overload;F;J0;;;K0;#I"generate(size, exponent);T;IC;";T;[;[;I";T;0; @bN;@F;Mi;N0;[[I" size;T0[I" exponent;T0; @bN;[;I"Generates an RSA keypair. _size_ is an integer representing the desired key size. Keys smaller than 1024 should be considered insecure. _exponent_ is an odd number normally 3, 17, or 65537. @overload generate(size) @overload generate(size, exponent);T;0; @bN;@F;Ao;B;CT;Di;Ei;!@`N;"I"static VALUE ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass) { /* why does this method exist? why can't initialize take an optional exponent? */ RSA *rsa; VALUE size, exp; VALUE obj; rb_scan_args(argc, argv, "11", &size, &exp); rsa = rsa_generate(NUM2INT(size), NIL_P(exp) ? RSA_F4 : NUM2ULONG(exp)); /* err handled by rsa_instance */ obj = rsa_instance(klass, rsa); if (obj == Qfalse) { RSA_free(rsa); ossl_raise(eRSAError, NULL); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""OpenSSL::PKey::RSA#initialize;F;[[@0;[[@Ki;T;;;0;[;{;IC;"Generates or loads an RSA keypair. If an integer _key_size_ is given it represents the desired key size. Keys less than 1024 bits should be considered insecure. A key can instead be loaded from an _encoded_key_ which must be PEM or DER encoded. A _pass_phrase_ can be used to decrypt the key. If none is given OpenSSL will prompt for the pass phrase. = 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;H ;II" overload;F;J0;; ;K0;#I"new(key_size);T;IC;";T;[;[;I";T;0; @N;@F;Mi;N0;[[I" key_size;T0; @No;H ;II" overload;F;J0;; ;K0;#I"new(encoded_key);T;IC;";T;[;[;I";T;0; @N;@F;Mi;N0;[[I"encoded_key;T0; @No;H ;II" overload;F;J0;; ;K0;#I""new(encoded_key, pass_phrase);T;IC;";T;[;[;I";T;0; @N;@F;Mi;N0;[[I"encoded_key;T0[I"pass_phrase;T0; @N;[;I"XGenerates or loads an RSA keypair. If an integer _key_size_ is given it represents the desired key size. Keys less than 1024 bits should be considered insecure. A key can instead be loaded from an _encoded_key_ which must be PEM or DER encoded. A _pass_phrase_ can be used to decrypt the key. If none is given OpenSSL will prompt for the pass phrase. = 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(key_size) @overload new(encoded_key) @overload new(encoded_key, pass_phrase);T;0; @N;@F;Ao;B;CT;Di;Ei;!@`N;"I"static VALUE ossl_rsa_initialize(int argc, VALUE *argv, VALUE self) { EVP_PKEY *pkey; RSA *rsa; BIO *in; VALUE arg, pass; GetPKey(self, pkey); if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) { rsa = RSA_new(); } else if (RB_INTEGER_TYPE_P(arg)) { rsa = rsa_generate(NUM2INT(arg), NIL_P(pass) ? RSA_F4 : NUM2ULONG(pass)); if (!rsa) ossl_raise(eRSAError, NULL); } else { pass = ossl_pem_passwd_value(pass); arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ossl_pem_passwd_cb, (void *)pass); if (!rsa) { OSSL_BIO_reset(in); rsa = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL); } if (!rsa) { OSSL_BIO_reset(in); rsa = d2i_RSAPrivateKey_bio(in, NULL); } if (!rsa) { OSSL_BIO_reset(in); rsa = d2i_RSA_PUBKEY_bio(in, NULL); } if (!rsa) { OSSL_BIO_reset(in); rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL); } if (!rsa) { OSSL_BIO_reset(in); rsa = d2i_RSAPublicKey_bio(in, NULL); } BIO_free(in); if (!rsa) { ossl_raise(eRSAError, "Neither PUB key nor PRIV key"); } } if (!EVP_PKEY_assign_RSA(pkey, rsa)) { RSA_free(rsa); ossl_raise(eRSAError, NULL); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"'OpenSSL::PKey::RSA#initialize_copy;F;[[I" other;T0;[[@Ki;T;;];0;[;{;IC;" ;T;[;[;@;0; @N;!@`N;"I"static VALUE ossl_rsa_initialize_copy(VALUE self, VALUE other) { EVP_PKEY *pkey; RSA *rsa, *rsa_new; GetPKey(self, pkey); if (EVP_PKEY_base_id(pkey) != EVP_PKEY_NONE) ossl_raise(eRSAError, "RSA already initialized"); GetRSA(other, rsa); rsa_new = ASN1_dup((i2d_of_void *)i2d_RSAPrivateKey, (d2i_of_void *)d2i_RSAPrivateKey, (char *)rsa); if (!rsa_new) ossl_raise(eRSAError, "ASN1_dup"); EVP_PKEY_assign_RSA(pkey, rsa_new); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::RSA#public?;F;[;[[@Ki-;T;;;0;[;{;IC;"TThe return value is always +true+ since every private key is also a public key.;T;[o;H ;II" overload;F;J0;;;K0;#I" public?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @N;[;I"@return [true];T;0; @N;@F;Mi;N0;[; @N;[;I"yThe return value is always +true+ since every private key is also a public key. @overload public? @return [true];T;0; @N;@F;Ao;B;CT;Di&;Ei+;Mi;!@`N;"I"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; ; F; ;,;;;I" OpenSSL::PKey::RSA#private?;F;[;[[@Ki@;T;;;0;[;{;IC;"-Does this keypair contain a private key?;T;[o;H ;II" overload;F;J0;;;K0;#I" private?;T;IC;";T;[;[;I";T;0; @N;@F;Mi;N0;[; @No;L ;II" return;F;J@;0;K[@; @N;[;I"BDoes this keypair contain a private key? @overload private?;T;0; @N;@F;Ao;B;CT;Di:;Ei=;Mi;!@`N;"I"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; ; F; ;,;;;I"OpenSSL::PKey::RSA#to_text;F;[;[[@Ki;T;;;0;[;{;IC;"THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!! Dumps all parameters of a keypair to a String Don't use :-)) (It's up to you) ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_text;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @N;[;I"@return [String];T;0; @N;@F;Mi;N0;[; @N;[;I"THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!! Dumps all parameters of a keypair to a String Don't use :-)) (It's up to you) @overload to_text @return [String];T;0; @N;@F;Ao;B;CT;Di;Ei;!@`N;"I"Vstatic VALUE ossl_rsa_to_text(VALUE self) { RSA *rsa; BIO *out; VALUE str; GetRSA(self, rsa); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eRSAError, NULL); } if (!RSA_print(out, rsa, 0)) { /* offset = 0 */ BIO_free(out); ossl_raise(eRSAError, NULL); } str = ossl_membio2str(out); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::RSA#export;F;[[@0;[[@KiT;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;H ;II" overload;F;J0;;;K0;#I""export([cipher, pass_phrase]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"PEM-format String;T; @O;[;I" @return [PEM-format String];T;0; @O;@F;Mi;N0;[[I"[cipher, pass_phrase];T0; @Oo;H ;II" overload;F;J0;;;K0;#I""to_pem([cipher, pass_phrase]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"PEM-format String;T; @O;[;I" @return [PEM-format String];T;0; @O;@F;Mi;N0;[[I"[cipher, pass_phrase];T0; @Oo;H ;II" overload;F;J0;;h;K0;#I" to_s([cipher, pass_phrase]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"PEM-format String;T; @O;[;I" @return [PEM-format String];T;0; @O;@F;Mi;N0;[[I"[cipher, pass_phrase];T0; @O;[;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; ; F; ;,;;;I"OpenSSL::PKey::RSA#to_s;F;[;[[@Ki;F;;h;;0;[;{;@O;!@`N;"I"static VALUE ossl_rsa_export(int argc, VALUE *argv, VALUE self) { RSA *rsa; BIO *out; const EVP_CIPHER *ciph = NULL; VALUE cipher, pass, str; GetRSA(self, rsa); rb_scan_args(argc, argv, "02", &cipher, &pass); if (!NIL_P(cipher)) { ciph = ossl_evp_get_cipherbyname(cipher); pass = ossl_pem_passwd_value(pass); } if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eRSAError, NULL); } if (RSA_HAS_PRIVATE(rsa)) { if (!PEM_write_bio_RSAPrivateKey(out, rsa, ciph, NULL, 0, ossl_pem_passwd_cb, (void *)pass)) { BIO_free(out); ossl_raise(eRSAError, NULL); } } else { if (!PEM_write_bio_RSA_PUBKEY(out, rsa)) { BIO_free(out); ossl_raise(eRSAError, NULL); } } str = ossl_membio2str(out); return str; };T;#I"static VALUE;T;@F;Ao;B;CT;DiJ;EiT;!@`N;"I"static VALUE ossl_rsa_export(int argc, VALUE *argv, VALUE self) { RSA *rsa; BIO *out; const EVP_CIPHER *ciph = NULL; VALUE cipher, pass, str; GetRSA(self, rsa); rb_scan_args(argc, argv, "02", &cipher, &pass); if (!NIL_P(cipher)) { ciph = ossl_evp_get_cipherbyname(cipher); pass = ossl_pem_passwd_value(pass); } if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eRSAError, NULL); } if (RSA_HAS_PRIVATE(rsa)) { if (!PEM_write_bio_RSAPrivateKey(out, rsa, ciph, NULL, 0, ossl_pem_passwd_cb, (void *)pass)) { BIO_free(out); ossl_raise(eRSAError, NULL); } } else { if (!PEM_write_bio_RSA_PUBKEY(out, rsa)) { BIO_free(out); ossl_raise(eRSAError, NULL); } } str = ossl_membio2str(out); return str; };T;#@TO;$To; ; F; ;,;;;I"OpenSSL::PKey::RSA#to_pem;F;[;[[@Ki;F;;;;0;[;{;@O;!@`N;"I"static VALUE ossl_rsa_export(int argc, VALUE *argv, VALUE self) { RSA *rsa; BIO *out; const EVP_CIPHER *ciph = NULL; VALUE cipher, pass, str; GetRSA(self, rsa); rb_scan_args(argc, argv, "02", &cipher, &pass); if (!NIL_P(cipher)) { ciph = ossl_evp_get_cipherbyname(cipher); pass = ossl_pem_passwd_value(pass); } if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eRSAError, NULL); } if (RSA_HAS_PRIVATE(rsa)) { if (!PEM_write_bio_RSAPrivateKey(out, rsa, ciph, NULL, 0, ossl_pem_passwd_cb, (void *)pass)) { BIO_free(out); ossl_raise(eRSAError, NULL); } } else { if (!PEM_write_bio_RSA_PUBKEY(out, rsa)) { BIO_free(out); ossl_raise(eRSAError, NULL); } } str = ossl_membio2str(out); return str; };T;#@TO@LOo; ; F; ;,;;;I"OpenSSL::PKey::RSA#to_der;F;[;[[@Ki~;T;; ;0;[;{;IC;"*Outputs this keypair in DER encoding. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"DER-format String;T; @_O;[;I" @return [DER-format String];T;0; @_O;@F;Mi;N0;[; @_O;[;I"[Outputs this keypair in DER encoding. @overload to_der @return [DER-format String];T;0; @_O;@F;Ao;B;CT;Dix;Ei|;!@`N;"I"=static VALUE ossl_rsa_to_der(VALUE self) { RSA *rsa; int (*i2d_func)(const RSA *, unsigned char **); unsigned char *p; long len; VALUE str; GetRSA(self, rsa); if (RSA_HAS_PRIVATE(rsa)) i2d_func = i2d_RSAPrivateKey; else i2d_func = (int (*)(const RSA *, unsigned char **))i2d_RSA_PUBKEY; if((len = i2d_func(rsa, NULL)) <= 0) ossl_raise(eRSAError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_func(rsa, &p) < 0) ossl_raise(eRSAError, NULL); ossl_str_adjust(str, p); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""OpenSSL::PKey::RSA#public_key;F;[;[[@Ki!;T;; ;0;[;{;IC;"KMakes new RSA instance containing the public key from the private key. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"public_key;T;IC;";T;[;[;I";T;0; @zO;@F;Mi;N0;[; @zO;[;I"bMakes new RSA instance containing the public key from the private key. @overload public_key;T;0; @zO;@F;Ao;B;CT;Di;Ei;!@`N;"I"rstatic VALUE ossl_rsa_to_public_key(VALUE self) { EVP_PKEY *pkey; RSA *rsa; VALUE obj; GetPKeyRSA(self, pkey); /* err check performed by rsa_instance */ rsa = RSAPublicKey_dup(EVP_PKEY_get0_RSA(pkey)); obj = rsa_instance(rb_obj_class(self), rsa); if (obj == Qfalse) { RSA_free(rsa); ossl_raise(eRSAError, NULL); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&OpenSSL::PKey::RSA#public_encrypt;F;[[@0;[[@Ki;T;:public_encrypt;0;[;{;IC;"Encrypt _string_ with the public key. _padding_ defaults to PKCS1_PADDING. The encrypted string output can be decrypted using #private_decrypt. ;T;[o;H ;II" overload;F;J0;;;K0;#I"public_encrypt(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @O;[;I"@return [String];T;0; @O;@F;Mi;N0;[[I" string;T0; @Oo;H ;II" overload;F;J0;;;K0;#I"$public_encrypt(string, padding);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @O;[;I"@return [String];T;0; @O;@F;Mi;N0;[[I" string;T0[I" padding;T0; @O;[;I"Encrypt _string_ with the public key. _padding_ defaults to PKCS1_PADDING. The encrypted string output can be decrypted using #private_decrypt. @overload public_encrypt(string) @return [String] @overload public_encrypt(string, padding) @return [String];T;0; @O;@F;Ao;B;CT;Di;Ei;!@`N;"I"static VALUE ossl_rsa_public_encrypt(int argc, VALUE *argv, VALUE self) { RSA *rsa; const BIGNUM *rsa_n; int buf_len, pad; VALUE str, buffer, padding; GetRSA(self, rsa); RSA_get0_key(rsa, &rsa_n, NULL, NULL); if (!rsa_n) ossl_raise(eRSAError, "incomplete RSA"); rb_scan_args(argc, argv, "11", &buffer, &padding); pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding); StringValue(buffer); str = rb_str_new(0, RSA_size(rsa)); buf_len = RSA_public_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer), (unsigned char *)RSTRING_PTR(str), rsa, pad); if (buf_len < 0) ossl_raise(eRSAError, NULL); rb_str_set_len(str, buf_len); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&OpenSSL::PKey::RSA#public_decrypt;F;[[@0;[[@Ki;T;:public_decrypt;0;[;{;IC;"{Decrypt _string_, which has been encrypted with the private key, with the public key. _padding_ defaults to PKCS1_PADDING. ;T;[o;H ;II" overload;F;J0;;;K0;#I"public_decrypt(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @O;[;I"@return [String];T;0; @O;@F;Mi;N0;[[I" string;T0; @Oo;H ;II" overload;F;J0;;;K0;#I"$public_decrypt(string, padding);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @O;[;I"@return [String];T;0; @O;@F;Mi;N0;[[I" string;T0[I" padding;T0; @O;[;I"Decrypt _string_, which has been encrypted with the private key, with the public key. _padding_ defaults to PKCS1_PADDING. @overload public_decrypt(string) @return [String] @overload public_decrypt(string, padding) @return [String];T;0; @O;@F;Ao;B;CT;Di;Ei;!@`N;"I"static VALUE ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self) { RSA *rsa; const BIGNUM *rsa_n; int buf_len, pad; VALUE str, buffer, padding; GetRSA(self, rsa); RSA_get0_key(rsa, &rsa_n, NULL, NULL); if (!rsa_n) ossl_raise(eRSAError, "incomplete RSA"); rb_scan_args(argc, argv, "11", &buffer, &padding); pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding); StringValue(buffer); str = rb_str_new(0, RSA_size(rsa)); buf_len = RSA_public_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer), (unsigned char *)RSTRING_PTR(str), rsa, pad); if (buf_len < 0) ossl_raise(eRSAError, NULL); rb_str_set_len(str, buf_len); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"'OpenSSL::PKey::RSA#private_encrypt;F;[[@0;[[@Ki;T;:private_encrypt;0;[;{;IC;"Encrypt _string_ with the private key. _padding_ defaults to PKCS1_PADDING. The encrypted string output can be decrypted using #public_decrypt. ;T;[o;H ;II" overload;F;J0;;;K0;#I"private_encrypt(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @O;[;I"@return [String];T;0; @O;@F;Mi;N0;[[I" string;T0; @Oo;H ;II" overload;F;J0;;;K0;#I"%private_encrypt(string, padding);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @O;[;I"@return [String];T;0; @O;@F;Mi;N0;[[I" string;T0[I" padding;T0; @O;[;I"Encrypt _string_ with the private key. _padding_ defaults to PKCS1_PADDING. The encrypted string output can be decrypted using #public_decrypt. @overload private_encrypt(string) @return [String] @overload private_encrypt(string, padding) @return [String];T;0; @O;@F;Ao;B;CT;Di;Ei;!@`N;"I"%static VALUE ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self) { RSA *rsa; const BIGNUM *rsa_n; int buf_len, pad; VALUE str, buffer, padding; GetRSA(self, rsa); RSA_get0_key(rsa, &rsa_n, NULL, NULL); if (!rsa_n) ossl_raise(eRSAError, "incomplete RSA"); if (!RSA_PRIVATE(self, rsa)) ossl_raise(eRSAError, "private key needed."); rb_scan_args(argc, argv, "11", &buffer, &padding); pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding); StringValue(buffer); str = rb_str_new(0, RSA_size(rsa)); buf_len = RSA_private_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer), (unsigned char *)RSTRING_PTR(str), rsa, pad); if (buf_len < 0) ossl_raise(eRSAError, NULL); rb_str_set_len(str, buf_len); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"'OpenSSL::PKey::RSA#private_decrypt;F;[[@0;[[@Ki;T;:private_decrypt;0;[;{;IC;"{Decrypt _string_, which has been encrypted with the public key, with the private key. _padding_ defaults to PKCS1_PADDING. ;T;[o;H ;II" overload;F;J0;;;K0;#I"private_decrypt(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @P;[;I"@return [String];T;0; @P;@F;Mi;N0;[[I" string;T0; @Po;H ;II" overload;F;J0;;;K0;#I"%private_decrypt(string, padding);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @P;[;I"@return [String];T;0; @P;@F;Mi;N0;[[I" string;T0[I" padding;T0; @P;[;I"Decrypt _string_, which has been encrypted with the public key, with the private key. _padding_ defaults to PKCS1_PADDING. @overload private_decrypt(string) @return [String] @overload private_decrypt(string, padding) @return [String];T;0; @P;@F;Ao;B;CT;Di;Ei;!@`N;"I"%static VALUE ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self) { RSA *rsa; const BIGNUM *rsa_n; int buf_len, pad; VALUE str, buffer, padding; GetRSA(self, rsa); RSA_get0_key(rsa, &rsa_n, NULL, NULL); if (!rsa_n) ossl_raise(eRSAError, "incomplete RSA"); if (!RSA_PRIVATE(self, rsa)) ossl_raise(eRSAError, "private key needed."); rb_scan_args(argc, argv, "11", &buffer, &padding); pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding); StringValue(buffer); str = rb_str_new(0, RSA_size(rsa)); buf_len = RSA_private_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer), (unsigned char *)RSTRING_PTR(str), rsa, pad); if (buf_len < 0) ossl_raise(eRSAError, NULL); rb_str_set_len(str, buf_len); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" OpenSSL::PKey::RSA#sign_pss;F;[[@0;[[@Ki<;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 = pkey.public_key puts pub_key.verify_pss("SHA256", signature, data, salt_length: :auto, mgf1_hash: "SHA256") # => true ;T;[o;H ;II" overload;F;J0;;;K0;#I"5sign_pss(digest, data, salt_length:, mgf1_hash:);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @LP;[;I"@return [String];T;0; @LP;@F;Mi;N0;[ [I" digest;T0[I" data;T0[I"salt_length:;TI";T[I"mgf1_hash:;TI";T; @LP;[;I"5Signs _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 = pkey.public_key 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; @LP;@F;Ao;B;CT;Di;Ei:;!@`N;"I"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; ; F; ;,;;;I""OpenSSL::PKey::RSA#verify_pss;F;[[@0;[[@Ki;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;H ;II" overload;F;J0;;;K0;#I"Bverify_pss(digest, signature, data, salt_length:, mgf1_hash:);T;IC;";T;[;[;I";T;0; @rP;@F;Mi;N0;[ [I" digest;T0[I"signature;T0[I" data;T0[I"salt_length:;TI";T[I"mgf1_hash:;TI";T; @rP;[;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; @rP;@F;Ao;B;CT;Di|;Ei;!@`N;"I" 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; ; F; ;,;;;I"OpenSSL::PKey::RSA#set_key;F;[;[;F;;;;0;[;{;IC;"-Sets _n_, _e_, _d_ for the RSA instance. ;T;[o;H ;II" overload;F;J0;;;K0;#I"set_key(n, e, d);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @P;[;I"@return [self];T;0; @P;@F;Mi;N0;[[I"n;T0[I"e;T0[I"d;T0; @P;[;I"[Sets _n_, _e_, _d_ for the RSA instance. @overload set_key(n, e, d) @return [self];T;0; @P;@F;Ao;B;CT;DiO;EiS;!@`N;$To; ; F; ;,;;;I"#OpenSSL::PKey::RSA#set_factors;F;[;[;F;:set_factors;;0;[;{;IC;"(Sets _p_, _q_ for the RSA instance. ;T;[o;H ;II" overload;F;J0;;;K0;#I"set_factors(p, q);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @P;[;I"@return [self];T;0; @P;@F;Mi;N0;[[I"p;T0[I"q;T0; @P;[;I"WSets _p_, _q_ for the RSA instance. @overload set_factors(p, q) @return [self];T;0; @P;@F;Ao;B;CT;DiW;Ei[;!@`N;$To; ; F; ;,;;;I"&OpenSSL::PKey::RSA#set_crt_params;F;[;[;F;:set_crt_params;;0;[;{;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;H ;II" overload;F;J0;;;K0;#I"%set_crt_params(dmp1, dmq1, iqmp);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @P;[;I"@return [self];T;0; @P;@F;Mi;N0;[[I" dmp1;T0[I" dmq1;T0[I" iqmp;T0; @P;[;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; @P;@F;Ao;B;CT;Di_;Eie;!@`N;$To; ; F; ;,;;;I"OpenSSL::PKey::RSA#params;F;[;[[@Ki;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;H ;II" overload;F;J0;;;K0;#I" params;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @P;[;I"@return [Hash];T;0; @P;@F;Mi;N0;[; @P;[;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; @P;@F;Ao;B;CT;Di;Ei;!@`N;"I"(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;&@`N;'IC;[;&@`N;(IC;[;&@`N;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@WO;@LO;;.[;[[@Ki[@Ki;T;:RSA;;0;;;[;{;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; @`N;@F;Ao;B;CT;Di;Ei;!@K;I"OpenSSL::PKey::RSA;F;1@Ko; ;IC;[;&@Q;'IC;[;&@Q;(IC;[;&@Q;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@SKi|;F;: ECError;;0;;;[;{;IC;" ;T;[;[;@;0; @Q;!@K;I"OpenSSL::PKey::ECError;F;1@Ko; ;IC;[!o; ;IC;[o; ;IC;[;&@/Q;'IC;[;&@/Q;(IC;[;&@/Q;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@SKi;F;: Error;;0;;;[;{;IC;" ;T;[;[;@;0; @/Q;!@-Q;I"$OpenSSL::PKey::EC::Group::Error;F;1@FKo; ; F; ;,;;;I"(OpenSSL::PKey::EC::Group#initialize;F;[[@0;[[@SKi;T;;;0;[;{;IC;"Creates a new EC::Group object. _ec_method_ is a symbol that represents an EC_METHOD. Currently the following are supported: * :GFp_simple * :GFp_mont * :GFp_nist * :GF2m_simple If the first argument is :GFp or :GF2m, creates a new curve with given parameters. ;T;[ o;H ;II" overload;F;J0;:!OpenSSL::PKey::EC::Group.new;K0;#I"+OpenSSL::PKey::EC::Group.new(ec_group);T;IC;";T;[;[;I";T;0; @@Q;@F;Mi;N0;[[I" ec_group;T0; @@Qo;H ;II" overload;F;J0;;;K0;#I"5OpenSSL::PKey::EC::Group.new(pem_or_der_encoded);T;IC;";T;[;[;I";T;0; @@Q;@F;Mi;N0;[[I"pem_or_der_encoded;T0; @@Qo;H ;II" overload;F;J0;;;K0;#I",OpenSSL::PKey::EC::Group.new(ec_method);T;IC;";T;[;[;I";T;0; @@Q;@F;Mi;N0;[[I"ec_method;T0; @@Qo;H ;II" overload;F;J0;;;K0;#I"EOpenSSL::PKey::EC::Group.new(:GFp, bignum_p, bignum_a, bignum_b);T;IC;";T;[;[;I";T;0; @@Q;@F;Mi;N0;[ [I":;TI"GFp;T[I" bignum_p;T0[I" bignum_a;T0[I" bignum_b;T0; @@Qo;H ;II" overload;F;J0;;;K0;#I"FOpenSSL::PKey::EC::Group.new(:GF2m, bignum_p, bignum_a, bignum_b);T;IC;";T;[;[;I";T;0; @@Q;@F;Mi;N0;[ [I":;TI" GF2m;T[I" bignum_p;T0[I" bignum_a;T0[I" bignum_b;T0; @@Q;[;I">Creates a new EC::Group object. _ec_method_ is a symbol that represents an EC_METHOD. Currently the following are supported: * :GFp_simple * :GFp_mont * :GFp_nist * :GF2m_simple 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(ec_method) @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; @@Q;@F;Ao;B;CT;Di;Ei;!@-Q;"I" 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 (SYMBOL_P(arg1)) { const EC_METHOD *method = NULL; ID id = SYM2ID(arg1); if (id == s_GFp_simple) { method = EC_GFp_simple_method(); } else if (id == s_GFp_mont) { method = EC_GFp_mont_method(); } else if (id == s_GFp_nist) { method = EC_GFp_nist_method(); #if !defined(OPENSSL_NO_EC2M) } else if (id == s_GF2m_simple) { method = EC_GF2m_simple_method(); #endif } if (method) { if ((group = EC_GROUP_new(method)) == NULL) ossl_raise(eEC_GROUP, "EC_GROUP_new"); } else { ossl_raise(rb_eArgError, "unknown symbol, must be :GFp_simple, :GFp_mont, :GFp_nist or :GF2m_simple"); } } else 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"); } if (group == NULL) ossl_raise(eEC_GROUP, ""); RTYPEDDATA_DATA(self) = group; return self; };T;#I"Mstatic VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self);T;$To; ; F; ;,;;;I"-OpenSSL::PKey::EC::Group#initialize_copy;F;[[I" other;T0;[[@SKi>;T;;];0;[;{;IC;" ;T;[;[;@;0; @Q;!@-Q;"I"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; ; F; ;,;;;I""OpenSSL::PKey::EC::Group#eql?;F;[[I"b;T0;[[@SKiX;T;;R;0;[;{;IC;"iReturns +true+ if the two groups use the same curve and have the same parameters, +false+ otherwise.;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(group2);T;IC;";T;[;[;I";T;0; @Q;@F;Mi;N0;[[I" group2;T0; @Qo;H ;II" overload;F;J0;;S;K0;#I"==(group2);T;IC;";T;[;[;I";T;0; @Q;@F;Mi;N0;[[I" group2;T0; @Qo;L ;II" return;F;J@;0;K[@; @Q;[;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; ; F; ;,;;;I" OpenSSL::PKey::EC::Group#==;F;[;[[@SKi;F;;S;;0;[;{;@Q;!@-Q;"I"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;Ao;B;CT;DiP;EiU;Mi;!@-Q;"I"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;#@Q;$T@Qo; ; F; ;,;;;I"'OpenSSL::PKey::EC::Group#generator;F;[;[[@SKim;T;:generator;0;[;{;IC;"eReturns the generator of the group. See the OpenSSL documentation for EC_GROUP_get0_generator() ;T;[o;H ;II" overload;F;J0;;;K0;#I"generator;T;IC;";T;[;[;I";T;0; @Q;@F;Mi;N0;[; @Q;[;I"{Returns the generator of the group. See the OpenSSL documentation for EC_GROUP_get0_generator() @overload generator;T;0; @Q;@F;Ao;B;CT;Die;Eij;!@-Q;"I"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; ; F; ;,;;;I"+OpenSSL::PKey::EC::Group#set_generator;F;[[I"generator;T0[I" order;T0[I" cofactor;T0;[[@SKi;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;H ;II" overload;F;J0;;;K0;#I".set_generator(generator, order, cofactor);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @Q;[;I"@return [self];T;0; @Q;@F;Mi;N0;[[I"generator;T0[I" order;T0[I" cofactor;T0; @Q;[;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; @Q;@F;Ao;B;CT;Diz;Ei;!@-Q;"I"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; ; F; ;,;;;I"#OpenSSL::PKey::EC::Group#order;F;[;[[@SKi;T;: order;0;[;{;IC;"\Returns the order of the group. See the OpenSSL documentation for EC_GROUP_get_order() ;T;[o;H ;II" overload;F;J0;:get_order;K0;#I"get_order;T;IC;";T;[;[;I";T;0; @ R;@F;Mi;N0;[; @ R;[;I"rReturns the order of the group. See the OpenSSL documentation for EC_GROUP_get_order() @overload get_order;T;0; @ R;@F;Ao;B;CT;Di;Ei;!@-Q;"I"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; ; F; ;,;;;I"&OpenSSL::PKey::EC::Group#cofactor;F;[;[[@SKi;T;: cofactor;0;[;{;IC;"bReturns the cofactor of the group. See the OpenSSL documentation for EC_GROUP_get_cofactor() ;T;[o;H ;II" overload;F;J0;:get_cofactor;K0;#I"get_cofactor;T;IC;";T;[;[;I";T;0; @R;@F;Mi;N0;[; @R;[;I"{Returns the cofactor of the group. See the OpenSSL documentation for EC_GROUP_get_cofactor() @overload get_cofactor;T;0; @R;@F;Ao;B;CT;Di;Ei;!@-Q;"I"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; ; F; ;,;;;I"(OpenSSL::PKey::EC::Group#curve_name;F;[;[[@SKi;T;:curve_name;0;[;{;IC;"^Returns the curve name (sn). See the OpenSSL documentation for EC_GROUP_get_curve_name() ;T;[o;H ;II" overload;F;J0;;$;K0;#I"curve_name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @5R;[;I"@return [String];T;0; @5R;@F;Mi;N0;[; @5R;[;I"Returns the curve name (sn). See the OpenSSL documentation for EC_GROUP_get_curve_name() @overload curve_name @return [String];T;0; @5R;@F;Ao;B;CT;Di;Ei;!@-Q;"I"=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; ; F; ;,;;;I"'OpenSSL::PKey::EC::Group#asn1_flag;F;[;[[@SKi ;T;:asn1_flag;0;[;{;IC;"?Returns the flags set on the group. See also #asn1_flag=. ;T;[o;H ;II" overload;F;J0;;%;K0;#I"asn1_flag;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @PR;[;I"@return [Integer];T;0; @PR;@F;Mi;N0;[; @PR;[;I"iReturns the flags set on the group. See also #asn1_flag=. @overload asn1_flag @return [Integer];T;0; @PR;@F;Ao;B;CT;Di;Ei;!@-Q;"I"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; ; F; ;,;;;I"(OpenSSL::PKey::EC::Group#asn1_flag=;F;[[I" flag_v;T0;[[@SKi#;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;H ;II" overload;F;J0;;&;K0;#I"asn1_flag=(flags);T;IC;";T;[;[;I";T;0; @kR;@F;Mi;N0;[[I" flags;T0; @kR;[;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; @kR;@F;Ao;B;CT;Di;Ei ;!@-Q;"I"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; ; F; ;,;;;I"3OpenSSL::PKey::EC::Group#point_conversion_form;F;[;[[@SKi5;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;H ;II" overload;F;J0;;';K0;#I"point_conversion_form;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Symbol;T; @R;[;I"@return [Symbol];T;0; @R;@F;Mi;N0;[; @R;[;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; @R;@F;Ao;B;CT;Di-;Ei3;!@-Q;"I"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; ; F; ;,;;;I"4OpenSSL::PKey::EC::Group#point_conversion_form=;F;[[I" form_v;T0;[[@SKik;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;H ;II" overload;F;J0;;(;K0;#I"!point_conversion_form=(form);T;IC;";T;[;[;I";T;0; @R;@F;Mi;N0;[[I" form;T0; @R;[;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; @R;@F;Ao;B;CT;DiX;Eih;!@-Q;"I"(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; ; F; ;,;;;I""OpenSSL::PKey::EC::Group#seed;F;[;[[@SKi;T;;;0;[;{;IC;";See the OpenSSL documentation for EC_GROUP_get0_seed() ;T;[o;H ;II" overload;F;J0;;;K0;#I" seed;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @R;[;I"@return [String, nil];T;0; @R;@F;Mi;N0;[; @R;[;I"dSee the OpenSSL documentation for EC_GROUP_get0_seed() @overload seed @return [String, nil];T;0; @R;@F;Ao;B;CT;Diy;Ei};!@-Q;"I"'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; ; F; ;,;;;I"#OpenSSL::PKey::EC::Group#seed=;F;[[I" seed;T0;[[@SKi;T;: seed=;0;[;{;IC;":See the OpenSSL documentation for EC_GROUP_set_seed() ;T;[o;H ;II" overload;F;J0;;);K0;#I"seed=(seed);T;IC;";T;[;[;I";T;0; @R;@F;Mi;N0;[[I" seed;T0; @R;[;I"RSee the OpenSSL documentation for EC_GROUP_set_seed() @overload seed=(seed);T;0; @R;@F;Ao;B;CT;Di;Ei;!@-Q;"I"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; ; F; ;,;;;I"$OpenSSL::PKey::EC::Group#degree;F;[;[[@SKi;T;: degree;0;[;{;IC;"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;H ;II" overload;F;J0;;2;K0;#I"mul(bn1 [, bn2]);T;IC;";T;[;[;I";T;0; @T;@F;Mi;N0;[[I"bn1[, bn2];T0; @To;H ;II" overload;F;J0;;2;K0;#I"mul(bns, points [, bn2]);T;IC;";T;[;[;I";T;0; @T;@F;Mi;N0;[[I"bns;T0[I"points[, bn2];T0; @T;[;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; @T;@F;Ao;B;CT;Di;Ei+;!@kS;"I"Xstatic 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 { /* * 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"); 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); } return result; };T;#I"Fstatic VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self);T;$T;&@kS;'IC;[;&@kS;(IC;[;&@kS;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@S;R;.[;[[@SKi;F;: Point;;0;;;[;{;IC;" ;T;[;[;@;0; @kS;Mi;!@+Q;I"OpenSSL::PKey::EC::Point;F;1@See the OpenSSL documentation for EC_KEY_set_public_key() ;T;[o;H ;II" overload;F;J0;;;;K0;#I"public_key=(ec_point);T;IC;";T;[;[;I";T;0; @U;@F;Mi;N0;[[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;Ao;B;CT;Dip;Eis;!@+Q;"I"static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key) { 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; default: ossl_raise(eECError, "EC_KEY_set_public_key"); } return public_key; };T;#I"Jstatic VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key);T;$To; ; F; ;,;;;I"OpenSSL::PKey::EC#private?;F;[;[[@SKi;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;H ;II" overload;F;J0;;;K0;#I" private?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @U;[;I"@return [Boolean];T;0; @U;@F;Mi;N0;[; @U;[;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; ; F; ;,;;;I"#OpenSSL::PKey::EC#private_key?;F;[;[[@SKi;F;:private_key?;;0;[;{;@U;!@+Q;"I"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;Ao;B;CT;Di;Ei;Mi;!@+Q;"I"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;#@V;$To; ; F; ;,;;;I"OpenSSL::PKey::EC#public?;F;[;[[@SKi;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;H ;II" overload;F;J0;;;K0;#I" public?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @V;[;I"@return [Boolean];T;0; @V;@F;Mi;N0;[; @V;[;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; ; F; ;,;;;I""OpenSSL::PKey::EC#public_key?;F;[;[[@SKi;F;:public_key?;;0;[;{;@"V;!@+Q;"I"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;Ao;B;CT;Di;Ei;Mi;!@+Q;"I"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;#@;V;$T@V@3Vo; ; F; ;,;;;I"$OpenSSL::PKey::EC#generate_key!;F;[;[[@SKi+;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;H ;II" overload;F;J0;;>;K0;#I"generate_key!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @>V;[;I"@return [self];T;0; @>V;@F;Mi;N0;[; @>V;[;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; ; F; ;,;;;I"#OpenSSL::PKey::EC#generate_key;F;[;[[@SKi;F;:generate_key;;0;[;{;@EV;!@+Q;"I"static VALUE ossl_ec_key_generate_key(VALUE self) { EC_KEY *ec; GetEC(self, ec); if (EC_KEY_generate_key(ec) != 1) ossl_raise(eECError, "EC_KEY_generate_key"); return self; };T;#I"6static VALUE ossl_ec_key_generate_key(VALUE self);T;@F;Ao;B;CT;Di;Ei);!@+Q;"I"static VALUE ossl_ec_key_generate_key(VALUE self) { EC_KEY *ec; GetEC(self, ec); if (EC_KEY_generate_key(ec) != 1) ossl_raise(eECError, "EC_KEY_generate_key"); return self; };T;#@^V;$T@VVo; ; F; ;,;;;I" OpenSSL::PKey::EC#check_key;F;[;[[@SKi>;T;:check_key;0;[;{;IC;"eRaises an exception if the key is invalid. See the OpenSSL documentation for EC_KEY_check_key() ;T;[o;H ;II" overload;F;J0;;@;K0;#I"check_key;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @aV;[;I"@return [true];T;0; @aV;@F;Mi;N0;[; @aV;[;I"Raises an exception if the key is invalid. See the OpenSSL documentation for EC_KEY_check_key() @overload check_key @return [true];T;0; @aV;@F;Ao;B;CT;Di6;Ei<;!@+Q;"I"static VALUE ossl_ec_key_check_key(VALUE self) { EC_KEY *ec; GetEC(self, ec); if (EC_KEY_check_key(ec) != 1) ossl_raise(eECError, "EC_KEY_check_key"); return Qtrue; };T;#I"3static VALUE ossl_ec_key_check_key(VALUE self);T;$To; ; F; ;,;;;I"%OpenSSL::PKey::EC#dh_compute_key;F;[[I" pubkey;T0;[[@SKiO;T;:dh_compute_key;0;[;{;IC;"9See the OpenSSL documentation for ECDH_compute_key() ;T;[o;H ;II" overload;F;J0;;A;K0;#I"dh_compute_key(pubkey);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @|V;[;I"@return [String];T;0; @|V;@F;Mi;N0;[[I" pubkey;T0; @|V;[;I"oSee the OpenSSL documentation for ECDH_compute_key() @overload dh_compute_key(pubkey) @return [String];T;0; @|V;@F;Ao;B;CT;DiI;EiM;!@+Q;"I"static VALUE ossl_ec_key_dh_compute_key(VALUE self, VALUE pubkey) { EC_KEY *ec; EC_POINT *point; int buf_len; VALUE str; GetEC(self, ec); GetECPoint(pubkey, point); /* BUG: need a way to figure out the maximum string size */ buf_len = 1024; str = rb_str_new(0, buf_len); /* BUG: take KDF as a block */ buf_len = ECDH_compute_key(RSTRING_PTR(str), buf_len, point, ec, NULL); if (buf_len < 0) ossl_raise(eECError, "ECDH_compute_key"); rb_str_resize(str, buf_len); return str; };T;#I"Fstatic VALUE ossl_ec_key_dh_compute_key(VALUE self, VALUE pubkey);T;$To; ; F; ;,;;;I"$OpenSSL::PKey::EC#dsa_sign_asn1;F;[[I" data;T0;[[@SKin;T;:dsa_sign_asn1;0;[;{;IC;"3See the OpenSSL documentation for ECDSA_sign() ;T;[o;H ;II" overload;F;J0;;B;K0;#I"dsa_sign_asn1(data);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @V;[;I"@return [String];T;0; @V;@F;Mi;N0;[[I" data;T0; @V;[;I"fSee the OpenSSL documentation for ECDSA_sign() @overload dsa_sign_asn1(data) @return [String];T;0; @V;@F;Ao;B;CT;Dih;Eil;!@+Q;"I"static VALUE ossl_ec_key_dsa_sign_asn1(VALUE self, VALUE data) { EC_KEY *ec; unsigned int buf_len; VALUE str; GetEC(self, ec); StringValue(data); if (EC_KEY_get0_private_key(ec) == NULL) ossl_raise(eECError, "Private EC key needed!"); str = rb_str_new(0, ECDSA_size(ec)); if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1) ossl_raise(eECError, "ECDSA_sign"); rb_str_set_len(str, buf_len); return str; };T;#I"Cstatic VALUE ossl_ec_key_dsa_sign_asn1(VALUE self, VALUE data);T;$To; ; F; ;,;;;I"&OpenSSL::PKey::EC#dsa_verify_asn1;F;[[I" data;T0[I"sig;T0;[[@SKi;T;:dsa_verify_asn1;0;[;{;IC;"5See the OpenSSL documentation for ECDSA_verify() ;T;[o;H ;II" overload;F;J0;;C;K0;#I"dsa_verify_asn1(data, sig);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @V;[;I"@return [Boolean];T;0; @V;@F;Mi;N0;[[I" data;T0[I"sig;T0; @V;[;I"pSee the OpenSSL documentation for ECDSA_verify() @overload dsa_verify_asn1(data, sig) @return [Boolean];T;0; @V;@F;Ao;B;CT;Di;Ei;!@+Q;"I"static VALUE ossl_ec_key_dsa_verify_asn1(VALUE self, VALUE data, VALUE sig) { EC_KEY *ec; GetEC(self, ec); StringValue(data); StringValue(sig); switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(sig), (int)RSTRING_LEN(sig), ec)) { case 1: return Qtrue; case 0: return Qfalse; default: break; } ossl_raise(eECError, "ECDSA_verify"); UNREACHABLE; };T;#I"Pstatic VALUE ossl_ec_key_dsa_verify_asn1(VALUE self, VALUE data, VALUE sig);T;$To; ; F; ;,;;;I"OpenSSL::PKey::EC#export;F;[[@0;[[@SKi;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;H ;II" overload;F;J0;;;K0;#I""export([cipher, pass_phrase]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @V;[;I"@return [String];T;0; @V;@F;Mi;N0;[[I"[cipher, pass_phrase];T0; @Vo;H ;II" overload;F;J0;;;K0;#I""to_pem([cipher, pass_phrase]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @V;[;I"@return [String];T;0; @V;@F;Mi;N0;[[I"[cipher, pass_phrase];T0; @V;[;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; ; F; ;,;;;I"OpenSSL::PKey::EC#to_pem;F;[;[[@SKi;F;;;;0;[;{;@V;!@+Q;"I"static VALUE ossl_ec_key_export(int argc, VALUE *argv, VALUE self) { VALUE cipher, passwd; rb_scan_args(argc, argv, "02", &cipher, &passwd); return ossl_ec_key_to_string(self, cipher, passwd, EXPORT_PEM); };T;#I"Gstatic VALUE ossl_ec_key_export(int argc, VALUE *argv, VALUE self);T;@F;Ao;B;CT;Di;Ei;!@+Q;"I"static VALUE ossl_ec_key_export(int argc, VALUE *argv, VALUE self) { VALUE cipher, passwd; rb_scan_args(argc, argv, "02", &cipher, &passwd); return ossl_ec_key_to_string(self, cipher, passwd, EXPORT_PEM); };T;#@W;$T@Wo; ; F; ;,;;;I"OpenSSL::PKey::EC#to_der;F;[;[[@SKi;T;; ;0;[;{;IC;"=See the OpenSSL documentation for i2d_ECPrivateKey_bio() ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @W;[;I"@return [String];T;0; @W;@F;Mi;N0;[; @W;[;I"cSee the OpenSSL documentation for i2d_ECPrivateKey_bio() @overload to_der @return [String];T;0; @W;@F;Ao;B;CT;Di;Ei;!@+Q;"I"tstatic VALUE ossl_ec_key_to_der(VALUE self) { return ossl_ec_key_to_string(self, Qnil, Qnil, EXPORT_DER); };T;#I"0static VALUE ossl_ec_key_to_der(VALUE self);T;$To; ; F; ;,;;;I"OpenSSL::PKey::EC#to_text;F;[;[[@SKi ;T;;;0;[;{;IC;"5See the OpenSSL documentation for EC_KEY_print() ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_text;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @-W;[;I"@return [String];T;0; @-W;@F;Mi;N0;[; @-W;[;I"\See the OpenSSL documentation for EC_KEY_print() @overload to_text @return [String];T;0; @-W;@F;Ao;B;CT;Di;Ei;!@+Q;"I"dstatic VALUE ossl_ec_key_to_text(VALUE self) { EC_KEY *ec; BIO *out; VALUE str; GetEC(self, ec); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eECError, "BIO_new(BIO_s_mem())"); } if (!EC_KEY_print(out, ec, 0)) { BIO_free(out); ossl_raise(eECError, "EC_KEY_print"); } str = ossl_membio2str(out); return str; };T;#I"1static VALUE ossl_ec_key_to_text(VALUE self);T;$T;&@+Q;'IC;[;&@+Q;(IC;[;&@+Q;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{ @V;@3V;@VV;>@W;;.[;[[@SKi~[@SKi;T;:EC;;0;;;[;{;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; @+Q;@F;Ao;B;CT;Di~;Ei;!@K;I"OpenSSL::PKey::EC;F;1@Ko; ;IC;[;&@ZW;'IC;[;&@ZW;(IC;[;&@ZW;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@KiH[@KiN;T;: DHError;;0;;;[;{;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; @ZW;@F;Ao;B;CT;DiH;EiL;!@K;I"OpenSSL::PKey::DHError;F;1@Ko; ;IC;[o; ; F; ;;;;I"OpenSSL::PKey::DH.generate;F;[[@0;[[@Ki;T;;;0;[;{;IC;"Creates a new DH instance from scratch by generating the private and public components alike. === Parameters * _size_ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure. * _generator_ is a small number > 1, typically 2 or 5. ;T;[o;H ;II" overload;F;J0;;;K0;#I"!generate(size [, generator]);T;IC;";T;[;[;I";T;0; @pW;@F;Mi;N0;[[I"size[, generator];T0; @pW;[;I"CCreates a new DH instance from scratch by generating the private and public components alike. === Parameters * _size_ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure. * _generator_ is a small number > 1, typically 2 or 5. @overload generate(size [, generator]);T;0; @pW;@F;Ao;B;CT;Di;Ei;!@nW;"I"xstatic VALUE ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass) { DH *dh ; int g = 2; VALUE size, gen, obj; if (rb_scan_args(argc, argv, "11", &size, &gen) == 2) { g = NUM2INT(gen); } dh = dh_generate(NUM2INT(size), g); obj = dh_instance(klass, dh); if (obj == Qfalse) { DH_free(dh); ossl_raise(eDHError, NULL); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!OpenSSL::PKey::DH#initialize;F;[[@0;[[@Ki;T;;;0;[;{;IC;"(Either generates a DH instance from scratch or by reading already existing DH parameters from _string_. Note that when reading a DH instance from data that was encoded from a DH instance by using DH#to_pem or DH#to_der the result will *not* contain a public/private key pair yet. This needs to be generated using DH#generate_key! first. === Parameters * _size_ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure. * _generator_ is a small number > 1, typically 2 or 5. * _string_ contains the DER or PEM encoded key. === Examples DH.new # -> dh DH.new(1024) # -> dh DH.new(1024, 5) # -> dh #Reading DH parameters dh = DH.new(File.read('parameters.pem')) # -> dh, but no public/private key yet dh.generate_key! # -> dh with public and private key ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[; @Wo;H ;II" overload;F;J0;; ;K0;#I"new(string);T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[[I" string;T0; @Wo;H ;II" overload;F;J0;; ;K0;#I"new(size [, generator]);T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[[I"size[, generator];T0; @W;[;I"pEither generates a DH instance from scratch or by reading already existing DH parameters from _string_. Note that when reading a DH instance from data that was encoded from a DH instance by using DH#to_pem or DH#to_der the result will *not* contain a public/private key pair yet. This needs to be generated using DH#generate_key! first. === Parameters * _size_ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure. * _generator_ is a small number > 1, typically 2 or 5. * _string_ contains the DER or PEM encoded key. === Examples DH.new # -> dh DH.new(1024) # -> dh DH.new(1024, 5) # -> dh #Reading DH parameters dh = DH.new(File.read('parameters.pem')) # -> dh, but no public/private key yet dh.generate_key! # -> dh with public and private key @overload new @overload new(string) @overload new(size [, generator]);T;0; @W;@F;Ao;B;CT;Di;Ei;!@nW;"I"+static VALUE ossl_dh_initialize(int argc, VALUE *argv, VALUE self) { EVP_PKEY *pkey; DH *dh; int g = 2; BIO *in; VALUE arg, gen; GetPKey(self, pkey); if(rb_scan_args(argc, argv, "02", &arg, &gen) == 0) { dh = DH_new(); } else if (RB_INTEGER_TYPE_P(arg)) { if (!NIL_P(gen)) { g = NUM2INT(gen); } if (!(dh = dh_generate(NUM2INT(arg), g))) { ossl_raise(eDHError, NULL); } } else { arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL); if (!dh){ OSSL_BIO_reset(in); dh = d2i_DHparams_bio(in, NULL); } BIO_free(in); if (!dh) { ossl_raise(eDHError, NULL); } } if (!EVP_PKEY_assign_DH(pkey, dh)) { DH_free(dh); ossl_raise(eDHError, NULL); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&OpenSSL::PKey::DH#initialize_copy;F;[[I" other;T0;[[@Ki;T;;];0;[;{;IC;" ;T;[;[;@;0; @W;!@nW;"I"static VALUE ossl_dh_initialize_copy(VALUE self, VALUE other) { EVP_PKEY *pkey; DH *dh, *dh_other; const BIGNUM *pub, *priv; GetPKey(self, pkey); if (EVP_PKEY_base_id(pkey) != EVP_PKEY_NONE) ossl_raise(eDHError, "DH already initialized"); GetDH(other, dh_other); dh = DHparams_dup(dh_other); if (!dh) ossl_raise(eDHError, "DHparams_dup"); EVP_PKEY_assign_DH(pkey, dh); 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); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::DH#public?;F;[;[[@Ki;T;;;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;H ;II" overload;F;J0;;;K0;#I" public?;T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[; @Wo;L ;II" return;F;J@;0;K[@; @W;[;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; @W;@F;Ao;B;CT;Di;Ei;Mi;!@nW;"I"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; ; F; ;,;;;I"OpenSSL::PKey::DH#private?;F;[;[[@Ki.;T;;;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;H ;II" overload;F;J0;;;K0;#I" private?;T;IC;";T;[;[;I";T;0; @W;@F;Mi;N0;[; @Wo;L ;II" return;F;J@;0;K[@; @W;[;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; @W;@F;Ao;B;CT;Di';Ei+;Mi;!@nW;"I" 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; ; F; ;,;;;I"OpenSSL::PKey::DH#to_text;F;[;[[@Ki;T;;;0;[;{;IC;"yPrints all parameters of key to buffer INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_text;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @W;[;I"@return [aString];T;0; @W;@F;Mi;N0;[; @W;[;I"Prints all parameters of key to buffer INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) @overload to_text @return [aString];T;0; @W;@F;Ao;B;CT;Di;Ei;!@nW;"I"?static VALUE ossl_dh_to_text(VALUE self) { DH *dh; BIO *out; VALUE str; GetDH(self, dh); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDHError, NULL); } if (!DHparams_print(out, dh)) { BIO_free(out); ossl_raise(eDHError, NULL); } str = ossl_membio2str(out); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::DH#export;F;[;[[@KiH;T;;;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;H ;II" overload;F;J0;;;K0;#I" export;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @X;[;I"@return [aString];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;;K0;#I" to_pem;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @X;[;I"@return [aString];T;0; @X;@F;Mi;N0;[; @Xo;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @X;[;I"@return [aString];T;0; @X;@F;Mi;N0;[; @X;[;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; ; F; ;,;;;I"OpenSSL::PKey::DH#to_s;F;[;[[@Kis;F;;h;;0;[;{;@X;!@nW;"I"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;Ao;B;CT;Di>;EiH;!@nW;"I"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;#@IX;$To; ; F; ;,;;;I"OpenSSL::PKey::DH#to_pem;F;[;[[@Kir;F;;;;0;[;{;@X;!@nW;"I"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;#@IX@AXo; ; F; ;,;;;I"OpenSSL::PKey::DH#to_der;F;[;[[@Kie;T;; ;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;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @TX;[;I"@return [aString];T;0; @TX;@F;Mi;N0;[; @TX;[;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; @TX;@F;Ao;B;CT;Di\;Eic;!@nW;"I"~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; ; F; ;,;;;I"!OpenSSL::PKey::DH#public_key;F;[;[[@Ki;T;; ;0;[;{;IC;"Returns a new DH instance that carries just the public information, i.e. the prime _p_ and the generator _g_, but no public/private key yet. Such a pair may be generated using DH#generate_key!. The "public key" needed for a key exchange with DH#compute_key is considered as per-session information and may be retrieved with DH#pub_key once a key pair has been generated. If the current instance already contains private information (and thus a valid public/private key pair), this information will no longer be present in the new instance generated by DH#public_key. This feature is helpful for publishing the Diffie-Hellman parameters without leaking any of the private per-session information. === Example dh = OpenSSL::PKey::DH.new(2048) # has public and private key set public_key = dh.public_key # contains only prime and generator parameters = public_key.to_der # it's safe to publish this ;T;[o;H ;II" overload;F;J0;; ;K0;#I"public_key;T;IC;";T;[;[;I";T;0; @oX;@F;Mi;N0;[; @oX;[;I"Returns a new DH instance that carries just the public information, i.e. the prime _p_ and the generator _g_, but no public/private key yet. Such a pair may be generated using DH#generate_key!. The "public key" needed for a key exchange with DH#compute_key is considered as per-session information and may be retrieved with DH#pub_key once a key pair has been generated. If the current instance already contains private information (and thus a valid public/private key pair), this information will no longer be present in the new instance generated by DH#public_key. This feature is helpful for publishing the Diffie-Hellman parameters without leaking any of the private per-session information. === Example dh = OpenSSL::PKey::DH.new(2048) # has public and private key set public_key = dh.public_key # contains only prime and generator parameters = public_key.to_der # it's safe to publish this @overload public_key;T;0; @oX;@F;Ao;B;CT;Di;Ei;!@nW;"I"Dstatic VALUE ossl_dh_to_public_key(VALUE self) { DH *orig_dh, *dh; VALUE obj; GetDH(self, orig_dh); dh = DHparams_dup(orig_dh); /* err check perfomed by dh_instance */ obj = dh_instance(rb_obj_class(self), dh); if (obj == Qfalse) { DH_free(dh); ossl_raise(eDHError, NULL); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!OpenSSL::PKey::DH#params_ok?;F;[;[[@Ki;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.;T;[o;H ;II" overload;F;J0;;F;K0;#I"params_ok?;T;IC;";T;[;[;I";T;0; @X;@F;Mi;N0;[; @Xo;L ;II" return;F;J@;0;K[@; @X;[;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. @overload params_ok?;T;0; @X;@F;Ao;B;CT;Di;Ei;Mi;!@nW;"I"static VALUE ossl_dh_check_params(VALUE self) { DH *dh; int codes; GetDH(self, dh); if (!DH_check(dh, &codes)) { return Qfalse; } return codes == 0 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"$OpenSSL::PKey::DH#generate_key!;F;[;[[@Ki;T;;>;0;[;{;IC;"Generates a private and public key unless a private key already exists. If this DH instance was generated from public DH parameters (e.g. by encoding the result of DH#public_key), then this method needs to be called first in order to generate the per-session keys before performing the actual key exchange. === Example dh = OpenSSL::PKey::DH.new(2048) public_key = dh.public_key #contains no private/public key yet public_key.generate_key! puts public_key.private? # => true ;T;[o;H ;II" overload;F;J0;;>;K0;#I"generate_key!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @X;[;I"@return [self];T;0; @X;@F;Mi;N0;[; @X;[;I" Generates a private and public key unless a private key already exists. If this DH instance was generated from public DH parameters (e.g. by encoding the result of DH#public_key), then this method needs to be called first in order to generate the per-session keys before performing the actual key exchange. === Example dh = OpenSSL::PKey::DH.new(2048) public_key = dh.public_key #contains no private/public key yet public_key.generate_key! puts public_key.private? # => true @overload generate_key! @return [self];T;0; @X;@F;Ao;B;CT;Di;Ei;!@nW;"I"static VALUE ossl_dh_generate_key(VALUE self) { DH *dh; GetDH(self, dh); if (!DH_generate_key(dh)) ossl_raise(eDHError, "Failed to generate key"); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""OpenSSL::PKey::DH#compute_key;F;[[I"pub;T0;[[@Ki;T;:compute_key;0;[;{;IC;"Returns a String containing a shared secret computed from the other party's public value. See DH_compute_key() for further information. === Parameters * _pub_bn_ is a OpenSSL::BN, *not* the DH instance returned by DH#public_key as that contains the DH parameters only. ;T;[o;H ;II" overload;F;J0;;G;K0;#I"compute_key(pub_bn);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @X;[;I"@return [aString];T;0; @X;@F;Mi;N0;[[I" pub_bn;T0; @X;[;I"BReturns a String containing a shared secret computed from the other party's public value. See DH_compute_key() for further information. === Parameters * _pub_bn_ is a OpenSSL::BN, *not* the DH instance returned by DH#public_key as that contains the DH parameters only. @overload compute_key(pub_bn) @return [aString];T;0; @X;@F;Ao;B;CT;Di ;Ei;!@nW;"I"static VALUE ossl_dh_compute_key(VALUE self, VALUE pub) { DH *dh; const BIGNUM *pub_key, *dh_p; VALUE str; int len; GetDH(self, dh); DH_get0_pqg(dh, &dh_p, NULL, NULL); if (!dh_p) ossl_raise(eDHError, "incomplete DH"); pub_key = GetBNPtr(pub); len = DH_size(dh); str = rb_str_new(0, len); if ((len = DH_compute_key((unsigned char *)RSTRING_PTR(str), pub_key, dh)) < 0) { ossl_raise(eDHError, NULL); } rb_str_set_len(str, len); return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKey::DH#set_pqg;F;[;[;F;; ;;0;[;{;IC;"+Sets _p_, _q_, _g_ to the DH instance. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"set_pqg(p, q, g);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @X;[;I"@return [self];T;0; @X;@F;Mi;N0;[[I"p;T0[I"q;T0[I"g;T0; @X;[;I"YSets _p_, _q_, _g_ to the DH instance. @overload set_pqg(p, q, g) @return [self];T;0; @X;@F;Ao;B;CT;Di+;Ei/;!@nW;$To; ; F; ;,;;;I"OpenSSL::PKey::DH#set_key;F;[;[;F;;;;0;[;{;IC;"PSets _pub_key_ and _priv_key_ for the DH instance. _priv_key_ may be +nil+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"set_key(pub_key, priv_key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @X;[;I"@return [self];T;0; @X;@F;Mi;N0;[[I" pub_key;T0[I" priv_key;T0; @X;[;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; @X;@F;Ao;B;CT;Di3;Ei7;!@nW;$To; ; F; ;,;;;I"OpenSSL::PKey::DH#params;F;[;[[@Ki;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;H ;II" overload;F;J0;;;K0;#I" params;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @Y;[;I"@return [Hash];T;0; @Y;@F;Mi;N0;[; @Y;[;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; @Y;@F;Ao;B;CT;Diy;Ei;!@nW;"I"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;&@nW;'IC;[;&@nW;(IC;[;&@nW;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@LX;@AX;;.[;[[@KiO[@Kij;T;:DH;;0;;;[;{;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 dh1 = OpenSSL::PKey::DH.new(2048) der = dh1.public_key.to_der #you may send this publicly to the participating party dh2 = OpenSSL::PKey::DH.new(der) dh2.generate_key! #generate the per-session key pair symm_key1 = dh1.compute_key(dh2.pub_key) symm_key2 = dh2.compute_key(dh1.pub_key) 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 dh1 = OpenSSL::PKey::DH.new(2048) der = dh1.public_key.to_der #you may send this publicly to the participating party dh2 = OpenSSL::PKey::DH.new(der) dh2.generate_key! #generate the per-session key pair symm_key1 = dh1.compute_key(dh2.pub_key) symm_key2 = dh2.compute_key(dh1.pub_key) puts symm_key1 == symm_key2 # => true ;T;0; @nW;@F;Ao;B;CT;DiO;Eih;!@K;I"OpenSSL::PKey::DH;F;1@K;&@K;'IC;[;&@K;(IC;[;&@K;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[ [@QKi[@QKi[@Kid[@Kis[@SKiv[@KiC;T;;;;0;;;[;{;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; @K;@F;Ao;B;CT;Di;Ei;Mi;!@DK;I"OpenSSL::PKey;Fo; ;IC;[&o; ;IC;[;&@WY;'IC;[;&@WY;(IC;[;&@WY;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@UKi;F;:PKCS7Error;;0;;;[;{;IC;" ;T;[;[;@;0; @WY;!@UY;I"OpenSSL::PKCS7::PKCS7Error;F;1@FKo; ; F; ;;;;I"OpenSSL::PKCS7.read_smime;F;[[I"arg;T0;[[@UKi;T;:read_smime;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;J;K0;#I"read_smime(string);T;IC;";T;[;[;I";T;0; @hY;@F;Mi;N0;[[I" string;T0; @hY;[;I"" @overload read_smime(string);T;0; @hY;@F;Ao;B;CT;Di;Ei;!@UY;"I"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; ; F; ;;;;I"OpenSSL::PKCS7.write_smime;F;[[@0;[[@UKi;T;:write_smime;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;K;K0;#I"*write_smime(pkcs7 [, data [, flags]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[[I"pkcs7[, data [, flags]];T0; @Y;[;I"H @overload write_smime(pkcs7 [, data [, flags]]) @return [String];T;0; @Y;@F;Ao;B;CT;Di;Ei;!@UY;"I"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; ; F; ;;;;I"OpenSSL::PKCS7.sign;F;[[@0;[[@UKi;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"/sign(cert, key, data, [, certs [, flags]]);T;IC;";T;[;[;I";T;0; @Y;@F;Mi;N0;[ [I" cert;T0[I"key;T0[I" data;T0[I"[, certs [, flags]];T0; @Y;[;I": @overload sign(cert, key, data, [, certs [, flags]]);T;0; @Y;@F;Ao;B;CT;Di;Ei;!@UY;"I"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; ; F; ;;;;I"OpenSSL::PKCS7.encrypt;F;[[@0;[[@UKi(;T;: encrypt;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;L;K0;#I"/encrypt(certs, data, [, cipher [, flags]]);T;IC;";T;[;[;I";T;0; @Y;@F;Mi;N0;[[I" certs;T0[I" data;T0[I"[, cipher [, flags]];T0; @Y;[;I": @overload encrypt(certs, data, [, cipher [, flags]]);T;0; @Y;@F;Ao;B;CT;Di$;Ei%;!@UY;"I"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; ; F; ;,;;;I"#OpenSSL::PKCS7#initialize_copy;F;[[I" other;T0;[[@UKi;T;;];0;[;{;IC;" ;T;[;[;@;0; @Y;!@UY;"I"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; ; F; ;,;;;I"OpenSSL::PKCS7#initialize;F;[[@0;[[@UKin;T;;;0;[;{;IC;"2Many methods in this class aren't documented. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[;[;I";T;0; @Y;@F;Mi;N0;[; @Yo;H ;II" overload;F;J0;; ;K0;#I"new(string);T;IC;";T;[;[;I";T;0; @Y;@F;Mi;N0;[[I" string;T0; @Y;[;I"XMany methods in this class aren't documented. @overload new @overload new(string);T;0; @Y;@F;Ao;B;CT;Dig;Eik;!@UY;"I"static VALUE ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self) { PKCS7 *p7, *pkcs = 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); p7 = PEM_read_bio_PKCS7(in, &pkcs, NULL, NULL); if (!p7) { OSSL_BIO_reset(in); p7 = d2i_PKCS7_bio(in, &pkcs); if (!p7) { BIO_free(in); PKCS7_free(pkcs); DATA_PTR(self) = NULL; ossl_raise(rb_eArgError, "Could not parse the PKCS7"); } } DATA_PTR(self) = pkcs; BIO_free(in); ossl_pkcs7_set_data(self, Qnil); ossl_pkcs7_set_err_string(self, Qnil); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKCS7#type=;F;[[I" type;T0;[[@UKi;T;: type=;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;M;K0;#I"type=(type);T;IC;";T;[;[;I";T;0; @ Z;@F;Mi;N0;[[I" type;T0; @ Z;[;I" @overload type=(type);T;0; @ Z;@F;Ao;B;CT;Di;Ei;!@UY;"I"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; ; F; ;,;;;I"OpenSSL::PKCS7#type;F;[;[[@UKi;T;;s;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;s;K0;#I" type;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @%Z;[;I"@return [String, nil];T;0; @%Z;@F;Mi;N0;[; @%Z;[;I", @overload type @return [String, nil];T;0; @%Z;@F;Ao;B;CT;Di;Ei;!@UY;"I"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; ; F; ;,;;;I"OpenSSL::PKCS7#detached=;F;[[I" flag;T0;[[@UKi;T;:detached=;0;[;{;IC;" ;T;[;[;@;0; @AZ;!@UY;"I"-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; ; F; ;,;;;I"OpenSSL::PKCS7#detached;F;[;[[@UKi;T;: detached;0;[;{;IC;" ;T;[;[;@;0; @OZ;!@UY;"I"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; ; F; ;,;;;I"OpenSSL::PKCS7#detached?;F;[;[[@UKi;T;:detached?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @[Z;[;@;0; @[Z;Mi;!@UY;"I"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; ; F; ;,;;;I"OpenSSL::PKCS7#cipher=;F;[[I" cipher;T0;[[@UKi ;T;: cipher=;0;[;{;IC;" ;T;[;[;@;0; @jZ;!@UY;"I"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; ; F; ;,;;;I"OpenSSL::PKCS7#add_signer;F;[[I" signer;T0;[[@UKi;T;:add_signer;0;[;{;IC;" ;T;[;[;@;0; @xZ;!@UY;"I"static VALUE ossl_pkcs7_add_signer(VALUE self, VALUE signer) { PKCS7 *pkcs7; PKCS7_SIGNER_INFO *p7si; p7si = DupPKCS7SignerPtr(signer); /* NEED TO DUP */ GetPKCS7(self, pkcs7); if (!PKCS7_add_signer(pkcs7, p7si)) { PKCS7_SIGNER_INFO_free(p7si); ossl_raise(ePKCS7Error, "Could not add signer."); } if (PKCS7_type_is_signed(pkcs7)){ PKCS7_add_signed_attribute(p7si, NID_pkcs9_contentType, V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data)); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::PKCS7#signers;F;[;[[@UKi+;T;: signers;0;[;{;IC;" ;T;[;[;@;0; @Z;!@UY;"I"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; i[;$T@6[o; ; F; ;,;;;I"OpenSSL::PKCS7#to_der;F;[;[[@UKiX;T;; ;0;[;{;IC;" ;T;[;[;@;0; @@[;!@UY;"I"static VALUE ossl_pkcs7_to_der(VALUE self) { PKCS7 *pkcs7; VALUE str; long len; unsigned char *p; GetPKCS7(self, pkcs7); if((len = i2d_PKCS7(pkcs7, NULL)) <= 0) ossl_raise(ePKCS7Error, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_PKCS7(pkcs7, &p) <= 0) ossl_raise(ePKCS7Error, NULL); ossl_str_adjust(str, p); return str; };T;#I"static VALUE;T;$To; ;IC;[ o; ; F; ;,;;;I"*OpenSSL::PKCS7::SignerInfo#initialize;F;[[I" cert;T0[I"key;T0[I" digest;T0;[[@UKi;T;;;0;[;{;IC;" ;T;[;[;@;0; @N[;!@L[;"I"static VALUE ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest) { PKCS7_SIGNER_INFO *p7si; EVP_PKEY *pkey; X509 *x509; const EVP_MD *md; pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */ md = ossl_evp_get_digestbyname(digest); GetPKCS7si(self, p7si); if (!(PKCS7_SIGNER_INFO_set(p7si, x509, pkey, (EVP_MD*)md))) { ossl_raise(ePKCS7Error, NULL); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&OpenSSL::PKCS7::SignerInfo#issuer;F;[;[[@UKi;T;: issuer;0;[;{;IC;" ;T;[;[;@;0; o; ; F; ;,;;;I"$OpenSSL::PKCS7::SignerInfo#name;F;[;[[@UKiC;F;;>;;0;[;{;@g[;!@L[;"I"static VALUE ossl_pkcs7si_get_issuer(VALUE self) { PKCS7_SIGNER_INFO *p7si; GetPKCS7si(self, p7si); return ossl_x509name_new(p7si->issuer_and_serial->issuer); };T;#I"static VALUE;T;!@L[;"I"static VALUE ossl_pkcs7si_get_issuer(VALUE self) { PKCS7_SIGNER_INFO *p7si; GetPKCS7si(self, p7si); return ossl_x509name_new(p7si->issuer_and_serial->issuer); };T;#@r[;$T@j[o; ; F; ;,;;;I"&OpenSSL::PKCS7::SignerInfo#serial;F;[;[[@UKi;T;: serial;0;[;{;IC;" ;T;[;[;@;0; @t[;!@L[;"I"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; ; F; ;,;;;I"+OpenSSL::PKCS7::SignerInfo#signed_time;F;[;[[@UKi;T;:signed_time;0;[;{;IC;" ;T;[;[;@;0; @[;!@L[;"I"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;&@L[;'IC;[;&@L[;(IC;[;&@L[;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@j[;_;.[;[[@UKi>;F;:SignerInfo;;0;;;[;{;IC;" ;T;[;[;@;0; @L[;!@UY;I"OpenSSL::PKCS7::SignerInfo;F;1@issuer_and_serial->issuer); };T;#I"static VALUE;T;$To; ; F; ;,;;;I")OpenSSL::PKCS7::RecipientInfo#serial;F;[;[[@UKi;T;;`;0;[;{;IC;" ;T;[;[;@;0; @[;!@[;"I"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; ; F; ;,;;;I"*OpenSSL::PKCS7::RecipientInfo#enc_key;F;[;[[@UKi;T;: enc_key;0;[;{;IC;" ;T;[;[;@;0; @[;!@[;"I"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;&@[;'IC;[;&@[;(IC;[;&@[;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@UKiG;F;:RecipientInfo;;0;;;[;{;IC;" ;T;[;[;@;0; @[;!@UY;I""OpenSSL::PKCS7::RecipientInfo;F;1@<;&@UY;'IC;[;&@UY;(IC;[;&@UY;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@[;\@6[;;.[;[[@UKi;F;: PKCS7;;0;;;[;{;IC;" ;T;[;[;@;0; @UY;Mi;!@DK;I"OpenSSL::PKCS7;F;1@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; ; F; ;,;;;I"#OpenSSL::X509::Request#version;F;[;[[@WKi;T;: version;0;[;{;IC;" ;T;[;[;@;0; @S\;!@ \;"I"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; ; F; ;,;;;I"$OpenSSL::X509::Request#version=;F;[[I" version;T0;[[@WKi;T;: version=;0;[;{;IC;" ;T;[;[;@;0; @_\;!@ \;"I"_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; ; F; ;,;;;I"#OpenSSL::X509::Request#subject;F;[;[[@WKi;T;: subject;0;[;{;IC;" ;T;[;[;@;0; @m\;!@ \;"I"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; ; F; ;,;;;I"$OpenSSL::X509::Request#subject=;F;[[I" subject;T0;[[@WKi;T;: subject=;0;[;{;IC;" ;T;[;[;@;0; @y\;!@ \;"I"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; ; F; ;,;;;I"/OpenSSL::X509::Request#signature_algorithm;F;[;[[@WKi;T;:signature_algorithm;0;[;{;IC;" ;T;[;[;@;0; @\;!@ \;"I"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; ; F; ;,;;;I"&OpenSSL::X509::Request#public_key;F;[;[[@WKi;T;; ;0;[;{;IC;" ;T;[;[;@;0; @\;!@ \;"I"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; ; F; ;,;;;I"'OpenSSL::X509::Request#public_key=;F;[[I"key;T0;[[@WKi!;T;;;;0;[;{;IC;"NO DUP - OK ;T;[;[;I"NO DUP - OK;T;0; @\;@F;Ao;B;CT;Di;Ei;!@ \;"I"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; ; F; ;,;;;I" OpenSSL::X509::Request#sign;F;[[I"key;T0[I" digest;T0;[[@WKi/;T;;;0;[;{;IC;" ;T;[;[;@;0; @\;!@ \;"I"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; ; F; ;,;;;I""OpenSSL::X509::Request#verify;F;[[I"key;T0;[[@WKiC;T;;;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; @\;@F;Ao;B;CT;Di@;EiA;!@ \;"I"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; ; F; ;,;;;I"&OpenSSL::X509::Request#attributes;F;[;[[@WKiW;T;:attributes;0;[;{;IC;" ;T;[;[;@;0; @\;!@ \;"I"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; i", rb_obj_class(self), ossl_x509name_to_utf8(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::X509::Name#to_a;F;[;[[@YKiQ;T;;;0;[;{;IC;"\Returns an Array representation of the distinguished name suitable for passing to ::new ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @];[;I"@return [Array];T;0; @];@F;Mi;N0;[; @];[;I"Returns an Array representation of the distinguished name suitable for passing to ::new @overload to_a @return [Array];T;0; @];@F;Ao;B;CT;DiJ;EiO;!@];"I"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; ; F; ;,;;;I"OpenSSL::X509::Name#cmp;F;[[I" other;T0;[[@YKi;T;:cmp;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. ;T;[o;H ;II" overload;F;J0;;t;K0;#I"cmp(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"-1 | 0 | 1;T; @];[;I"@return [-1 | 0 | 1];T;0; @];@F;Mi;N0;[[I" other;T0; @]o;H ;II" overload;F;J0;;V;K0;#I"<=>(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"-1 | 0 | 1;T; @];[;I"@return [-1 | 0 | 1];T;0; @];@F;Mi;N0;[[I" other;T0; @];[;I"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. @overload cmp(other) @return [-1 | 0 | 1] @overload <=>(other) @return [-1 | 0 | 1];T;0; o; ; F; ;,;;;I"OpenSSL::X509::Name#<=>;F;[;[[@YKi;F;;V;;0;[;{;@];!@];"I"static VALUE ossl_x509name_cmp(VALUE self, VALUE other) { int result; 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;Ao;B;CT;Di;Ei;!@];"I"static VALUE ossl_x509name_cmp(VALUE self, VALUE other) { int result; result = ossl_x509name_cmp0(self, other); if (result < 0) return INT2FIX(-1); if (result > 0) return INT2FIX(1); return INT2FIX(0); };T;#@^;$T@ ^o; ; F; ;,;;;I"OpenSSL::X509::Name#eql?;F;[[I" other;T0;[[@YKi;T;;R;0;[;{;IC;"CReturns true if _name_ and _other_ refer to the same hash key.;T;[o;H ;II" overload;F;J0;;R;K0;#I"eql?(other);T;IC;";T;[;[;I";T;0; @^;@F;Mi;N0;[[I" other;T0; @^o;L ;II" return;F;J@;0;K[@; @^;[;I"[Returns true if _name_ and _other_ refer to the same hash key. @overload eql?(other);T;0; @^;@F;Ao;B;CT;Di;Ei;Mi;!@];"I"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; ; F; ;,;;;I"OpenSSL::X509::Name#hash;F;[;[[@YKi;T;;U;0;[;{;IC;"ZThe hash value returned is suitable for use as a certificate's filename in a CA path. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @5^;[;I"@return [Integer];T;0; @5^;@F;Mi;N0;[; @5^;[;I"The hash value returned is suitable for use as a certificate's filename in a CA path. @overload hash @return [Integer];T;0; @5^;@F;Ao;B;CT;Di;Ei;!@];"I"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; ; F; ;,;;;I"!OpenSSL::X509::Name#hash_old;F;[;[[@YKi;T;: hash_old;0;[;{;IC;"5Returns an MD5 based hash used in OpenSSL 0.9.X. ;T;[o;H ;II" overload;F;J0;;u;K0;#I" hash_old;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @P^;[;I"@return [Integer];T;0; @P^;@F;Mi;N0;[; @P^;[;I"^Returns an MD5 based hash used in OpenSSL 0.9.X. @overload hash_old @return [Integer];T;0; @P^;@F;Ao;B;CT;Di;Ei;!@];"I"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; ; F; ;,;;;I"OpenSSL::X509::Name#to_der;F;[;[[@YKi;T;; ;0;[;{;IC;"&Converts the name to DER encoding ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k^;[;I"@return [String];T;0; @k^;@F;Mi;N0;[; @k^;[;I"LConverts the name to DER encoding @overload to_der @return [String];T;0; @k^;@F;Ao;B;CT;Di;Ei;!@];"I"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;9;[[@YKi;F;:DEFAULT_OBJECT_TYPE;;;;;;[;{;IC;".The default object type for name entries. ;T;[;[;I"/The default object type for name entries. ;T;0; @^;@F;Ao;B;CT;Di;Ei;!@];I"-OpenSSL::X509::Name::DEFAULT_OBJECT_TYPE;F;= 0!"); } GetX509CRL(self, crl); if (!X509_CRL_set_version(crl, ver)) { ossl_raise(eX509CRLError, NULL); } return version; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"+OpenSSL::X509::CRL#signature_algorithm;F;[;[[@gKi;T;;l;0;[;{;IC;" ;T;[;[;@;0; @;_;!@_;"I"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; ; F; ;,;;;I"OpenSSL::X509::CRL#issuer;F;[;[[@gKi;T;;_;0;[;{;IC;" ;T;[;[;@;0; @G_;!@_;"I"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; ; F; ;,;;;I"OpenSSL::X509::CRL#issuer=;F;[[I" issuer;T0;[[@gKi;T;: issuer=;0;[;{;IC;"NO DUP - don't free ;T;[;[;I"NO DUP - don't free;T;0; @S_;@F;Ao;B;CT;Di;Ei;!@_;"I"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; ; F; ;,;;;I"#OpenSSL::X509::CRL#last_update;F;[;[[@gKi;T;:last_update;0;[;{;IC;" ;T;[;[;@;0; @c_;!@_;"I"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; ; F; ;,;;;I"$OpenSSL::X509::CRL#last_update=;F;[[I" time;T0;[[@gKi;T;:last_update=;0;[;{;IC;" ;T;[;[;@;0; @o_;!@_;"I"{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; ; F; ;,;;;I"#OpenSSL::X509::CRL#next_update;F;[;[[@gKi;T;:next_update;0;[;{;IC;" ;T;[;[;@;0; @}_;!@_;"I"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; ; F; ;,;;;I"$OpenSSL::X509::CRL#next_update=;F;[[I" time;T0;[[@gKi;T;:next_update=;0;[;{;IC;" ;T;[;[;@;0; @_;!@_;"I"{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; ; F; ;,;;;I"OpenSSL::X509::CRL#revoked;F;[;[[@gKi ;T;: revoked;0;[;{;IC;" ;T;[;[;@;0; @_;!@_;"I"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; ; F; ;,;;;I""OpenSSL::X509::CRL#extensions;F;[;[[@gKi;T;:extensions;0;[;{;IC;"7Gets X509v3 extensions as array of X509Ext objects ;T;[;[;I"8Gets X509v3 extensions as array of X509Ext objects ;T;0; @ `;@F;Ao;B;CT;Di;Ei;!@_;"I"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; ivalue.ptr, -1)) { ASN1_TYPE_free(a1type); ossl_raise(eX509AttrError, NULL); } ASN1_TYPE_free(a1type); } return value; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"#OpenSSL::X509::Attribute#value;F;[;[[@nKi;T;;/;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;/;K0;#I" value;T;IC;";T;[;[;I";T;0; @`;@F;Mi;N0;[; @`;[;I" @overload value;T;0; @`;@F;Ao;B;CT;Di;Ei;!@U`;"I"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; ; F; ;,;;;I"$OpenSSL::X509::Attribute#to_der;F;[;[[@nKi;T;; ;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @`;[;I"@return [String];T;0; @`;@F;Mi;N0;[; @`;[;I") @overload to_der @return [String];T;0; @`;@F;Ao;B;CT;Di;Ei;!@U`;"I"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;&@U`;'IC;[;&@U`;(IC;[;&@U`;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@nKi;;F;:Attribute;;0;;;[;{;IC;" ;T;[;[;@;0; @U`;Mi;!@[;I"OpenSSL::X509::Attribute;F;1@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; ; F; ;,;;;I"*OpenSSL::X509::Store#verify_callback=;F;[[I"cb;T0;[[@pKi;T;:verify_callback=;0;[;{;IC;"(General callback for OpenSSL verify ;T;[;[;I")General callback for OpenSSL verify ;T;0; @Adds _path_ as the hash dir to be looked up by the store. ;T;[o;H ;II" overload;F;J0;;;K0;#I"add_path(path);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @a;[;I"@return [self];T;0; @a;@F;Mi;N0;[[I" path;T0; @a;[;I"jAdds _path_ as the hash dir to be looked up by the store. @overload add_path(path) @return [self];T;0; @a;@F;Ao;B;CT;DiI;EiM;!@#a;"I"static VALUE ossl_x509store_add_path(VALUE self, VALUE dir) { X509_STORE *store; X509_LOOKUP *lookup; char *path = NULL; if(dir != Qnil){ rb_check_safe_obj(dir); path = StringValueCStr(dir); } GetX509Store(self, store); lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()); if(lookup == NULL) ossl_raise(eX509StoreError, NULL); if(X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1){ ossl_raise(eX509StoreError, NULL); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""OpenSSL::X509::Store#add_file;F;[[I" file;T0;[[@pKi+;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. ;T;[o;H ;II" overload;F;J0;;;K0;#I"add_file(file);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @a;[;I"@return [self];T;0; @a;@F;Mi;N0;[[I" file;T0; @a;[;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. @overload add_file(file) @return [self];T;0; @a;@F;Ao;B;CT;Di#;Ei);!@#a;"I"static VALUE ossl_x509store_add_file(VALUE self, VALUE file) { X509_STORE *store; X509_LOOKUP *lookup; char *path = NULL; if(file != Qnil){ rb_check_safe_obj(file); path = StringValueCStr(file); } GetX509Store(self, store); lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()); if(lookup == NULL) ossl_raise(eX509StoreError, NULL); if(X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1){ ossl_raise(eX509StoreError, NULL); } #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; ; F; ;,;;;I"+OpenSSL::X509::Store#set_default_paths;F;[;[[@pKio;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 ;T;[o;H ;II" overload;F;J0;;;K0;#I"set_default_paths;T;IC;";T;[;[;I";T;0; @a;@F;Mi;N0;[; @a;[;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 @overload set_default_paths;T;0; @a;@F;Ao;B;CT;Did;Eil;!@#a;"I"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, NULL); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""OpenSSL::X509::Store#add_cert;F;[[I"arg;T0;[[@pKi;T;: add_cert;0;[;{;IC;"IAdds the OpenSSL::X509::Certificate _cert_ to the certificate store. ;T;[o;H ;II" overload;F;J0;;;K0;#I"add_cert(cert);T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[[I" cert;T0; @b;[;I"dAdds the OpenSSL::X509::Certificate _cert_ to the certificate store. @overload add_cert(cert);T;0; @b;@F;Ao;B;CT;Di|;Ei;!@#a;"I".static 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, NULL); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!OpenSSL::X509::Store#add_crl;F;[[I"arg;T0;[[@pKi;T;;Y;0;[;{;IC;"4Adds the OpenSSL::X509::CRL _crl_ to the store. ;T;[o;H ;II" overload;F;J0;;Y;K0;#I"add_crl(crl);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @"b;[;I"@return [self];T;0; @"b;@F;Mi;N0;[[I"crl;T0; @"b;[;I"^Adds the OpenSSL::X509::CRL _crl_ to the store. @overload add_crl(crl) @return [self];T;0; @"b;@F;Ao;B;CT;Di;Ei;!@#a;"I",static 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, NULL); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" OpenSSL::X509::Store#verify;F;[[@0;[[@pKi;T;;;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;H ;II" overload;F;J0;;;K0;#I"verify(cert, chain = nil);T;IC;";T;[;[;I";T;0; @Ab;@F;Mi;N0;[[I" cert;T0[I" chain;TI"nil;T; @Ab;[;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; @Ab;@F;Ao;B;CT;Di;Ei;!@#a;"I"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;&@#a;'IC;[;&@#a;(IC;[;&@#a;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@pKi[@pKi:;T;: Store;;0;;;[;{;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; @#a;@F;Ao;B;CT;Di;Ei7;!@[;I"OpenSSL::X509::Store;F;1@;Ei@;!@ob;"I"static VALUE ossl_x509stctx_get_chain(VALUE self) { X509_STORE_CTX *ctx; STACK_OF(X509) *chain; X509 *x509; int i, num; VALUE ary; GetX509StCtx(self, ctx); if((chain = X509_STORE_CTX_get0_chain(ctx)) == NULL){ return Qnil; } if((num = sk_X509_num(chain)) < 0){ OSSL_Debug("certs in chain < 0???"); return rb_ary_new(); } ary = rb_ary_new2(num); for(i = 0; i < num; i++) { x509 = sk_X509_value(chain, i); rb_ary_push(ary, ossl_x509_new(x509)); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&OpenSSL::X509::StoreContext#error;F;[;[[@pKi`;T;: error;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" error;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @b;[;I"@return [Integer];T;0; @b;@F;Mi;N0;[; @b;[;I") @overload error @return [Integer];T;0; @b;@F;Ao;B;CT;Di\;Ei^;!@ob;"I"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; ; F; ;,;;;I"'OpenSSL::X509::StoreContext#error=;F;[[I"err;T0;[[@pKin;T;: error=;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"error=(error_code);T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[[I"error_code;T0; @b;[;I"" @overload error=(error_code);T;0; @b;@F;Ao;B;CT;Dij;Eik;!@ob;"I"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; ; F; ;,;;;I"-OpenSSL::X509::StoreContext#error_string;F;[;[[@pKi;T;:error_string;0;[;{;IC;"RReturns the error string corresponding to the error code retrieved by #error. ;T;[o;H ;II" overload;F;J0;;;K0;#I"error_string;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @b;[;I"@return [String];T;0; @b;@F;Mi;N0;[; @b;[;I"~Returns the error string corresponding to the error code retrieved by #error. @overload error_string @return [String];T;0; @b;@F;Ao;B;CT;Diy;Ei};!@ob;"I"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; ; F; ;,;;;I",OpenSSL::X509::StoreContext#error_depth;F;[;[[@pKi;T;:error_depth;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"error_depth;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @c;[;I"@return [Integer];T;0; @c;@F;Mi;N0;[; @c;[;I"/ @overload error_depth @return [Integer];T;0; @c;@F;Ao;B;CT;Di;Ei;!@ob;"I"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; ; F; ;,;;;I"-OpenSSL::X509::StoreContext#current_cert;F;[;[[@pKi;T;:current_cert;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"current_cert;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"X509::Certificate;T; @,c;[;I" @return [X509::Certificate];T;0; @,c;@F;Mi;N0;[; @,c;[;I": @overload current_cert @return [X509::Certificate];T;0; @,c;@F;Ao;B;CT;Di;Ei;!@ob;"I"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; ; F; ;,;;;I",OpenSSL::X509::StoreContext#current_crl;F;[;[[@pKi;T;:current_crl;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"current_crl;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"X509::CRL;T; @Gc;[;I"@return [X509::CRL];T;0; @Gc;@F;Mi;N0;[; @Gc;[;I"1 @overload current_crl @return [X509::CRL];T;0; @Gc;@F;Ao;B;CT;Di;Ei;!@ob;"I"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; ; F; ;,;;;I"'OpenSSL::X509::StoreContext#flags=;F;[[I" flags;T0;[[@pKi;T;;;0;[;{;IC;"BSets the verification flags to the context. See Store#flags=. ;T;[o;H ;II" overload;F;J0;;;K0;#I"flags=(flags);T;IC;";T;[;[;I";T;0; @bc;@F;Mi;N0;[[I" flags;T0; @bc;[;I"\Sets the verification flags to the context. See Store#flags=. @overload flags=(flags);T;0; @bc;@F;Ao;B;CT;Di;Ei;!@ob;"I"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; ; F; ;,;;;I")OpenSSL::X509::StoreContext#purpose=;F;[[I" purpose;T0;[[@pKi;T;;;0;[;{;IC;"9Sets the purpose of the context. See Store#purpose=. ;T;[o;H ;II" overload;F;J0;;;K0;#I"purpose=(purpose);T;IC;";T;[;[;I";T;0; @|c;@F;Mi;N0;[[I" purpose;T0; @|c;[;I"WSets the purpose of the context. See Store#purpose=. @overload purpose=(purpose);T;0; @|c;@F;Ao;B;CT;Di;Ei;!@ob;"I"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; ; F; ;,;;;I"'OpenSSL::X509::StoreContext#trust=;F;[[I" trust;T0;[[@pKi;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"trust=(trust);T;IC;";T;[;[;I";T;0; @c;@F;Mi;N0;[[I" trust;T0; @c;[;I" @overload trust=(trust);T;0; @c;@F;Ao;B;CT;Di;Ei;!@ob;"I"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; ; F; ;,;;;I"&OpenSSL::X509::StoreContext#time=;F;[[I" time;T0;[[@pKi;T;;;0;[;{;IC;"RSets the time used in the verification. If not set, the current time is used. ;T;[o;H ;II" overload;F;J0;;;K0;#I"time=(time);T;IC;";T;[;[;I";T;0; @c;@F;Mi;N0;[[I" time;T0; @c;[;I"jSets the time used in the verification. If not set, the current time is used. @overload time=(time);T;0; @c;@F;Ao;B;CT;Di;Ei;!@ob;"I"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;&@ob;'IC;[;&@ob;(IC;[;&@ob;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@pKi_[@pKie;T;:StoreContext;;0;;;[;{;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; @ob;@F;Ao;B;CT;Di_;Eib;!@[;I" OpenSSL::X509::StoreContext;F;1@issuer_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */ return cert; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"9OpenSSL::X509::ExtensionFactory#subject_certificate=;F;[[I" cert;T0;[[@tKi;T;:subject_certificate=;0;[;{;IC;" ;T;[;[;@;0; @ d;!@c;"I" 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; ; F; ;,;;;I"5OpenSSL::X509::ExtensionFactory#subject_request=;F;[[I"req;T0;[[@tKi;T;:subject_request=;0;[;{;IC;" ;T;[;[;@;0; @d;!@c;"I"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; ; F; ;,;;;I")OpenSSL::X509::ExtensionFactory#crl=;F;[[I"crl;T0;[[@tKi;T;: crl=;0;[;{;IC;" ;T;[;[;@;0; @&d;!@c;"I"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; ; F; ;,;;;I"/OpenSSL::X509::ExtensionFactory#create_ext;F;[[@0;[[@tKi;T;:create_ext;0;[;{;IC;"QCreates a new X509::Extension with passed values. See also x509v3_config(5). ;T;[o;H ;II" overload;F;J0;;;K0;#I"4create_ext(ln_or_sn, "value", critical = false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"X509::Extension;T; @4d;[;I"@return [X509::Extension];T;0; @4d;@F;Mi;N0;[[I" ln_or_sn;T0[" "value"0[I" critical;TI" false;T; @4do;H ;II" overload;F;J0;;;K0;#I"+create_ext(ln_or_sn, "critical,value");T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"X509::Extension;T; @4d;[;I"@return [X509::Extension];T;0; @4d;@F;Mi;N0;[[I" ln_or_sn;T0[""critical,value"0; @4d;[;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; @4d;@F;Ao;B;CT;Di;Ei;!@c;"I"Zstatic 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 : DupConfigPtr(rconf); X509V3_set_nconf(ctx, conf); ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING_PTR(valstr)); X509V3_set_ctx_nodb(ctx); NCONF_free(conf); if (!ext){ ossl_raise(eX509ExtError, "%"PRIsVALUE" = %"PRIsVALUE, oid, valstr); } SetX509Ext(obj, ext); return obj; };T;#I"static VALUE;T;$T;&@c;'IC;[;&@c;(IC;[;&@c;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@tKi;F;:ExtensionFactory;;0;;;[;{;IC;" ;T;[;[;@;0; @c;Mi;!@[;I"$OpenSSL::X509::ExtensionFactory;F;1@= 0!"); } GetX509(self, x509); if (!X509_set_version(x509, ver)) { ossl_raise(eX509CertError, NULL); } return version; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"3OpenSSL::X509::Certificate#signature_algorithm;F;[;[[@|KiC;T;;l;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;l;K0;#I"signature_algorithm;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @f;[;I"@return [String];T;0; @f;@F;Mi;N0;[; @f;[;I"6 @overload signature_algorithm @return [String];T;0; @f;@F;Ao;B;CT;Di?;EiA;!@e;"I"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; ; F; ;,;;;I"&OpenSSL::X509::Certificate#serial;F;[;[[@|Ki&;T;;`;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;`;K0;#I" serial;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @f;[;I"@return [Integer];T;0; @f;@F;Mi;N0;[; @f;[;I"* @overload serial @return [Integer];T;0; @f;@F;Ao;B;CT;Di";Ei$;!@e;"I"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; ; F; ;,;;;I"'OpenSSL::X509::Certificate#serial=;F;[[I"num;T0;[[@|Ki4;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"serial=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @f;[;I"@return [Integer];T;0; @f;@F;Mi;N0;[[I" integer;T0; @f;[;I"4 @overload serial=(integer) @return [Integer];T;0; @f;@F;Ao;B;CT;Di0;Ei2;!@e;"I"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; ; F; ;,;;;I"'OpenSSL::X509::Certificate#subject;F;[;[[@|Ki[;T;;j;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;j;K0;#I" subject;T;IC;";T;[;[;I";T;0; @f;@F;Mi;N0;[; @f;[;I" @overload subject;T;0; @f;@F;Ao;B;CT;DiW;EiX;!@e;"I" 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; ; F; ;,;;;I"(OpenSSL::X509::Certificate#subject=;F;[[I" subject;T0;[[@|Kim;T;;k;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;k;K0;#I"subject=(name);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I" name;T0; @g;[;I" @overload subject=(name);T;0; @g;@F;Ao;B;CT;Dii;Eij;!@e;"I"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; ; F; ;,;;;I"&OpenSSL::X509::Certificate#issuer;F;[;[[@|Ki~;T;;_;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;_;K0;#I" issuer;T;IC;";T;[;[;I";T;0; @)g;@F;Mi;N0;[; @)g;[;I" @overload issuer;T;0; @)g;@F;Ao;B;CT;Diz;Ei{;!@e;"I"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; ; F; ;,;;;I"'OpenSSL::X509::Certificate#issuer=;F;[[I" issuer;T0;[[@|Ki;T;;~;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;~;K0;#I"issuer=(name);T;IC;";T;[;[;I";T;0; @?g;@F;Mi;N0;[[I" name;T0; @?g;[;I" @overload issuer=(name);T;0; @?g;@F;Ao;B;CT;Di;Ei;!@e;"I"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; ; F; ;,;;;I"*OpenSSL::X509::Certificate#not_before;F;[;[[@|Ki;T;:not_before;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"not_before;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @Yg;[;I"@return [Time];T;0; @Yg;@F;Mi;N0;[; @Yg;[;I"+ @overload not_before @return [Time];T;0; @Yg;@F;Ao;B;CT;Di;Ei;!@e;"I"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; ; F; ;,;;;I"+OpenSSL::X509::Certificate#not_before=;F;[[I" time;T0;[[@|Ki;T;:not_before=;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"not_before=(time);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @tg;[;I"@return [Time];T;0; @tg;@F;Mi;N0;[[I" time;T0; @tg;[;I"2 @overload not_before=(time) @return [Time];T;0; @tg;@F;Ao;B;CT;Di;Ei;!@e;"I"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; ; F; ;,;;;I")OpenSSL::X509::Certificate#not_after;F;[;[[@|Ki;T;:not_after;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"not_after;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @g;[;I"@return [Time];T;0; @g;@F;Mi;N0;[; @g;[;I"* @overload not_after @return [Time];T;0; @g;@F;Ao;B;CT;Di;Ei;!@e;"I"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; ; F; ;,;;;I"*OpenSSL::X509::Certificate#not_after=;F;[[I" time;T0;[[@|Ki;T;:not_after=;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"not_after=(time);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @g;[;I"@return [Time];T;0; @g;@F;Mi;N0;[[I" time;T0; @g;[;I"1 @overload not_after=(time) @return [Time];T;0; @g;@F;Ao;B;CT;Di;Ei;!@e;"I"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; ; F; ;,;;;I"*OpenSSL::X509::Certificate#public_key;F;[;[[@|Ki;T;; ;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;; ;K0;#I"public_key;T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[; @g;[;I" @overload public_key;T;0; @g;@F;Ao;B;CT;Di;Ei;!@e;"I"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; ; F; ;,;;;I"+OpenSSL::X509::Certificate#public_key=;F;[[I"key;T0;[[@|Ki;T;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;;K0;#I"public_key=(key);T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[[I"key;T0; @g;[;I" @overload public_key=(key);T;0; @g;@F;Ao;B;CT;Di;Ei;!@e;"I"&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; ; F; ;,;;;I"$OpenSSL::X509::Certificate#sign;F;[[I"key;T0[I" digest;T0;[[@|Ki;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"sign(key, digest);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @g;[;I"@return [self];T;0; @g;@F;Mi;N0;[[I"key;T0[I" digest;T0; @g;[;I"2 @overload sign(key, digest) @return [self];T;0; @g;@F;Ao;B;CT;Di;Ei;!@e;"I"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; ; F; ;,;;;I"&OpenSSL::X509::Certificate#verify;F;[[I"key;T0;[[@|Ki+;T;;;0;[;{;IC;"vVerifies the signature of the certificate, with the public key _key_. _key_ must be an instance of OpenSSL::PKey. ;T;[o;H ;II" overload;F;J0;;;K0;#I"verify(key);T;IC;";T;[;[;I";T;0; @ h;@F;Mi;N0;[[I"key;T0; @ h;[;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; @ h;@F;Ao;B;CT;Di$;Ei(;!@e;"I"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; ; F; ;,;;;I"1OpenSSL::X509::Certificate#check_private_key;F;[[I"key;T0;[[@|KiF;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;H ;II" overload;F;J0;;;K0;#I"check_private_key(key);T;IC;";T;[;[;I";T;0; @:h;@F;Mi;N0;[[I"key;T0; @:h;[;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; @:h;@F;Ao;B;CT;Di?;EiC;!@e;"I"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; ; F; ;,;;;I"*OpenSSL::X509::Certificate#extensions;F;[;[[@|Ki[;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"extensions;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @Th;[;I"@return [Array];T;0; @Th;@F;Mi;N0;[; @Th;[;I", @overload extensions @return [Array];T;0; @Th;@F;Ao;B;CT;DiW;EiY;!@e;"I"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; i", 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; ; F; ;,;;;I""OpenSSL::X509::Certificate#==;F;[[I" other;T0;[[@|Ki;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"==(cert2);T;IC;";T;[;[;I";T;0; @h;@F;Mi;N0;[[I" cert2;T0; @h;[;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; @h;@F;Ao;B;CT;Di;Ei;!@e;"I"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;&@e;'IC;[;&@e;(IC;[;&@e;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@Df;;.[;[[@|Ki[@|Ki-;T;:Certificate;;0;;;[;{;IC;"[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.read "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::SHA256.new) 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::SHA256.new) ;T;[;[;I"^ 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.read "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::SHA256.new) 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::SHA256.new) ;T;0; @e;@F;Ao;B;CT;Di;Ei+;!@[;I"OpenSSL::X509::Certificate;F;1@<;&@[;'IC;[;&@[;(IC;[;&@[;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@WKi[@YKi[@gKi[@nKi6[@pKi [@tKi[I"ext/openssl/ossl_x509.c;Ti)[@xKi[@|Ki;F;;|;;0;;;[;{;IC;" ;T;[;[;@;0; @[;Mi;!@DK;I"OpenSSL::X509;Fo; ;IC;[o; ;IC;[;&@h;'IC;[;&@h;(IC;[;&@h;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@[Ki;F;:RandomError;;0;;;[;{;IC;" ;T;[;[;@;0; @h;!@h;I"!OpenSSL::Random::RandomError;F;1@FKo; ; F; ;,;;;I"OpenSSL::Random#seed;F;[[I"str;T0;[[@[Ki;T;;;0;[;{;IC;"F::seed is equivalent to ::add where _entropy_ is length of _str_. ;T;[o;H ;II" overload;F;J0;;;K0;#I"seed(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @h;[;I"@return [String];T;0; @h;@F;Mi;N0;[[I"str;T0; @h;[;I"n::seed is equivalent to ::add where _entropy_ is length of _str_. @overload seed(str) @return [String];T;0; @h;@F;N0;!@h;"I"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; ; T; ;;;;I"OpenSSL::Random.seed;F;@h;@i;T;;;0;@i;{;IC;"F::seed is equivalent to ::add where _entropy_ is length of _str_.;T;[o;H ;II" overload;F;J0;;;K0;#I"seed(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @i;[;I"@return [String];T;0; @i;@F;Mi;N0;[[I"str;T0; @i;[;I"o::seed is equivalent to ::add where _entropy_ is length of _str_. @overload seed(str) @return [String];T;0; @i;@F;Ao;B;CT;Di;Ei;Mi;!@h;"@i;#@i;$To; ; F; ;,;;;I"OpenSSL::Random#random_add;F;[[I"str;T0[I" entropy;T0;[[@[Ki9;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;H ;II" overload;F;J0;;;K0;#I"add(str, entropy);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @1i;[;I"@return [self];T;0; @1i;@F;Mi;N0;[[I"str;T0[I" entropy;T0; @1i;[;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; @1i;@F;N0;!@h;"I"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; ; T; ;;;;I"OpenSSL::Random.random_add;F;@3i;@8i;T;;;0;@:i;{;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;H ;II" overload;F;J0;;;K0;#I"add(str, entropy);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @Si;[;I"@return [self];T;0; @Si;@F;Mi;N0;[[I"str;T0[I" entropy;T0; @Si;[;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; @Si;@F;Ao;B;CT;Di#;Ei7;Mi;!@h;"@Qi;#@Ri;$To; ; F; ;,;;;I"%OpenSSL::Random#load_random_file;F;[[I" filename;T0;[[@[KiH;T;:load_random_file;0;[;{;IC;";Reads bytes from _filename_ and adds them to the PRNG. ;T;[o;H ;II" overload;F;J0;;;K0;#I"load_random_file(filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @li;[;I"@return [true];T;0; @li;@F;Mi;N0;[[I" filename;T0; @li;[;I"rReads bytes from _filename_ and adds them to the PRNG. @overload load_random_file(filename) @return [true];T;0; @li;@F;N0;!@h;"I"static VALUE ossl_rand_load_file(VALUE self, VALUE filename) { rb_check_safe_obj(filename); if(!RAND_load_file(StringValueCStr(filename), -1)) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;#I"static VALUE;T;$To; ; T; ;;;;I"%OpenSSL::Random.load_random_file;F;@ni;@qi;T;;;0;@si;{;IC;";Reads bytes from _filename_ and adds them to the PRNG.;T;[o;H ;II" overload;F;J0;;;K0;#I"load_random_file(filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @i;[;I"@return [true];T;0; @i;@F;Mi;N0;[[I" filename;T0; @i;[;I"sReads bytes from _filename_ and adds them to the PRNG. @overload load_random_file(filename) @return [true];T;0; @i;@F;Ao;B;CT;DiB;EiF;Mi;!@h;"@i;#@i;$To; ; F; ;,;;;I"&OpenSSL::Random#write_random_file;F;[[I" filename;T0;[[@[Ki[;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;H ;II" overload;F;J0;;;K0;#I" write_random_file(filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @i;[;I"@return [true];T;0; @i;@F;Mi;N0;[[I" filename;T0; @i;[;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; @i;@F;N0;!@h;"I"static VALUE ossl_rand_write_file(VALUE self, VALUE filename) { rb_check_safe_obj(filename); if (RAND_write_file(StringValueCStr(filename)) == -1) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;#I"static VALUE;T;$To; ; T; ;;;;I"&OpenSSL::Random.write_random_file;F;@i;@i;T;;;0;@i;{;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;H ;II" overload;F;J0;;;K0;#I" write_random_file(filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @i;[;I"@return [true];T;0; @i;@F;Mi;N0;[[I" filename;T0; @i;[;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; @i;@F;Ao;B;CT;DiS;EiY;Mi;!@h;"@i;#@i;$To; ; F; ;,;;;I"!OpenSSL::Random#random_bytes;F;[[I"len;T0;[[@[Kir;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; @i;@F;N0;!@h;"I"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; ; T; ;;;;I"!OpenSSL::Random.random_bytes;F;@i;@i;T;;;0;@i;{;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; @i;@F;Ao;B;CT;Dif;Eip;Mi;!@h;"@i;#@i;$To; ; F; ;,;;;I"!OpenSSL::Random#pseudo_bytes;F;[[I"len;T0;[[@[Ki;T;:pseudo_bytes;0;[;{;IC;".pseudo_bytes(length) -> string Generates a String with _length_ number of pseudo-random bytes. Pseudo-random byte sequences generated by ::pseudo_bytes will be unique if they are of sufficient length, but are not necessarily unpredictable. === Example OpenSSL::Random.pseudo_bytes(12) #=> "..." ;T;[;[;I".pseudo_bytes(length) -> string Generates a String with _length_ number of pseudo-random bytes. Pseudo-random byte sequences generated by ::pseudo_bytes will be unique if they are of sufficient length, but are not necessarily unpredictable. === Example OpenSSL::Random.pseudo_bytes(12) #=> "...";T;0; @i;@F;N0;!@h;"I"static VALUE ossl_rand_pseudo_bytes(VALUE self, VALUE len) { VALUE str; int n = NUM2INT(len); str = rb_str_new(0, n); if (RAND_pseudo_bytes((unsigned char *)RSTRING_PTR(str), n) < 1) { ossl_raise(eRandomError, NULL); } return str; };T;#I"static VALUE;T;$To; ; T; ;;;;I"!OpenSSL::Random.pseudo_bytes;F;@i;@i;T;;;0;@i;{;IC;".pseudo_bytes(length) -> string Generates a String with _length_ number of pseudo-random bytes. Pseudo-random byte sequences generated by ::pseudo_bytes will be unique if they are of sufficient length, but are not necessarily unpredictable. === Example OpenSSL::Random.pseudo_bytes(12) #=> "...";T;[;[;I"0pseudo_bytes(length) -> string Generates a String with _length_ number of pseudo-random bytes. Pseudo-random byte sequences generated by ::pseudo_bytes will be unique if they are of sufficient length, but are not necessarily unpredictable. === Example OpenSSL::Random.pseudo_bytes(12) #=> "..." ;T;0; @i;@F;Ao;B;CT;Di;Ei;Mi;!@h;"@i;#@i;$To; ; F; ;,;;;I"OpenSSL::Random#egd;F;[[I" filename;T0;[[@[Ki;T;:egd;0;[;{;IC;":Same as ::egd_bytes but queries 255 bytes by default. ;T;[o;H ;II" overload;F;J0;;;K0;#I"egd(filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @j;[;I"@return [true];T;0; @j;@F;Mi;N0;[[I" filename;T0; @j;[;I"dSame as ::egd_bytes but queries 255 bytes by default. @overload egd(filename) @return [true];T;0; @j;@F;N0;!@h;"I"static VALUE ossl_rand_egd(VALUE self, VALUE filename) { rb_check_safe_obj(filename); if (RAND_egd(StringValueCStr(filename)) == -1) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL::Random.egd;F;@j;@ j;T;;;0;@ j;{;IC;":Same as ::egd_bytes but queries 255 bytes by default.;T;[o;H ;II" overload;F;J0;;;K0;#I"egd(filename);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @"j;[;I"@return [true];T;0; @"j;@F;Mi;N0;[[I" filename;T0; @"j;[;I"eSame as ::egd_bytes but queries 255 bytes by default. @overload egd(filename) @return [true];T;0; @"j;@F;Ao;B;CT;Di;Ei;Mi;!@h;"@ j;#@!j;$To; ; F; ;,;;;I"OpenSSL::Random#egd_bytes;F;[[I" filename;T0[I"len;T0;[[@[Ki;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;H ;II" overload;F;J0;;;K0;#I" egd_bytes(filename, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @9j;[;I"@return [true];T;0; @9j;@F;Mi;N0;[[I" filename;T0[I" length;T0; @9j;[;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; @9j;@F;N0;!@h;"I"static VALUE ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len) { int n = NUM2INT(len); rb_check_safe_obj(filename); if (RAND_egd_bytes(StringValueCStr(filename), n) == -1) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL::Random.egd_bytes;F;@;j;@@j;T;;;0;@Bj;{;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;H ;II" overload;F;J0;;;K0;#I" egd_bytes(filename, length);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @[j;[;I"@return [true];T;0; @[j;@F;Mi;N0;[[I" filename;T0[I" length;T0; @[j;[;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; @[j;@F;Ao;B;CT;Di;Ei;Mi;!@h;"@Yj;#@Zj;$To; ; F; ;,;;;I"OpenSSL::Random#status?;F;[;[[@[Ki;T;: status?;0;[;{;IC;"SReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise. ;T;[o;H ;II" overload;F;J0;;;K0;#I" status?;T;IC;";T;[;[;I";T;0; @tj;@F;Mi;N0;[; @tjo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @tj;[;I"yReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise. @overload status? @return [Boolean] ;T;0; @tj;@F;N0;!@h;"I"]static VALUE ossl_rand_status(VALUE self) { return RAND_status() ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL::Random.status?;F;@vj;@wj;T;;;0;@yj;{;IC;"SReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise.;T;[o;H ;II" overload;F;J0;;;K0;#I" status?;T;IC;";T;[;[;I";T;0; @j;@F;Mi;N0;[; @jo;L ;II" return;F;J@;0;K[@; @j;[;I"gReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise. @overload status?;T;0; @j;@F;Ao;B;CT;Di;Ei;Mi;!@h;"@j;#@j;$T;&@h;'IC;[;&@h;(IC;[;&@h;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@[Ki;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @h;Mi;!@DK;I"OpenSSL::Random;Fo; ;IC;[;&@j;'IC;[;&@j;(IC;[;&@j;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@]Kip;F;:HMACError;;0;;;[;{;IC;" ;T;[;[;@;0; @j;!@DK;I"OpenSSL::HMACError;F;1@FKo; ;IC;[o; ; F; ;;;;I"OpenSSL::HMAC.digest;F;[[I" digest;T0[I"key;T0[I" data;T0;[[@]Ki;T;: digest;0;[;{;IC;"Returns the authentication code as a binary string. The _digest_ parameter specifies the digest algorithm to use. This may be a String representing the algorithm name or an instance of OpenSSL::Digest. === Example key = 'key' data = 'The quick brown fox jumps over the lazy dog' hmac = OpenSSL::HMAC.digest('sha1', key, data) #=> "\xDE|\x9B\x85\xB8\xB7\x8A\xA6\xBC\x8Az6\xF7\n\x90p\x1C\x9D\xB4\xD9" ;T;[o;H ;II" overload;F;J0;;;K0;#I"digest(digest, key, data);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @j;[;I"@return [aString];T;0; @j;@F;Mi;N0;[[I" digest;T0[I"key;T0[I" data;T0; @j;[;I"Returns the authentication code as a binary string. The _digest_ parameter specifies the digest algorithm to use. This may be a String representing the algorithm name or an instance of OpenSSL::Digest. === Example key = 'key' data = 'The quick brown fox jumps over the lazy dog' hmac = OpenSSL::HMAC.digest('sha1', key, data) #=> "\xDE|\x9B\x85\xB8\xB7\x8A\xA6\xBC\x8Az6\xF7\n\x90p\x1C\x9D\xB4\xD9" @overload digest(digest, key, data) @return [aString];T;0; @j;@F;Ao;B;CT;Di;Ei;!@j;"I"static VALUE ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data) { unsigned char *buf; unsigned int buf_len; StringValue(key); StringValue(data); buf = HMAC(ossl_evp_get_digestbyname(digest), RSTRING_PTR(key), RSTRING_LENINT(key), (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len); return rb_str_new((const char *)buf, buf_len); };T;#I"static VALUE;T;$To; ; F; ;;;;I"OpenSSL::HMAC.hexdigest;F;[[I" digest;T0[I"key;T0[I" data;T0;[[@]Ki4;T;:hexdigest;0;[;{;IC;"Returns the authentication code as a hex-encoded string. The _digest_ parameter specifies the digest algorithm to use. This may be a String representing the algorithm name or an instance of OpenSSL::Digest. === Example key = 'key' data = 'The quick brown fox jumps over the lazy dog' hmac = OpenSSL::HMAC.hexdigest('sha1', key, data) #=> "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9" ;T;[o;H ;II" overload;F;J0;;;K0;#I"!hexdigest(digest, key, data);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @j;[;I"@return [aString];T;0; @j;@F;Mi;N0;[[I" digest;T0[I"key;T0[I" data;T0; @j;[;I"Returns the authentication code as a hex-encoded string. The _digest_ parameter specifies the digest algorithm to use. This may be a String representing the algorithm name or an instance of OpenSSL::Digest. === Example key = 'key' data = 'The quick brown fox jumps over the lazy dog' hmac = OpenSSL::HMAC.hexdigest('sha1', key, data) #=> "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9" @overload hexdigest(digest, key, data) @return [aString];T;0; @j;@F;Ao;B;CT;Di#;Ei2;!@j;"I"static VALUE ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data) { unsigned char buf[EVP_MAX_MD_SIZE]; unsigned int buf_len; VALUE ret; StringValue(key); StringValue(data); if (!HMAC(ossl_evp_get_digestbyname(digest), RSTRING_PTR(key), RSTRING_LENINT(key), (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), buf, &buf_len)) ossl_raise(eHMACError, "HMAC"); ret = rb_str_new(NULL, buf_len * 2); ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len); return ret; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::HMAC#initialize;F;[[I"key;T0[I" digest;T0;[[@]Kij;T;;;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' digest = OpenSSL::Digest.new('sha1') instance = OpenSSL::HMAC.new(key, digest) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.class #=> OpenSSL::HMAC === A note about comparisons Two instances won't be equal when they're compared, even if they have the same value. Use #to_s or #hexdigest to return the authentication code that the instance represents. For example: other_instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1')) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance == other_instance #=> false instance.to_s == other_instance.to_s #=> true ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(key, digest);T;IC;";T;[;[;I";T;0; @k;@F;Mi;N0;[[I"key;T0[I" digest;T0; @k;[;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' digest = OpenSSL::Digest.new('sha1') instance = OpenSSL::HMAC.new(key, digest) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.class #=> OpenSSL::HMAC === A note about comparisons Two instances won't be equal when they're compared, even if they have the same value. Use #to_s or #hexdigest to return the authentication code that the instance represents. For example: other_instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1')) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance == other_instance #=> false instance.to_s == other_instance.to_s #=> true @overload new(key, digest);T;0; @k;@F;Ao;B;CT;DiG;Eig;!@j;"I"static VALUE ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest) { HMAC_CTX *ctx; StringValue(key); GetHMAC(self, ctx); HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key), ossl_evp_get_digestbyname(digest), NULL); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""OpenSSL::HMAC#initialize_copy;F;[[I" other;T0;[[@]Kiw;T;;];0;[;{;IC;" ;T;[;[;@;0; @/k;!@j;"I"'static VALUE ossl_hmac_copy(VALUE self, VALUE other) { HMAC_CTX *ctx1, *ctx2; rb_check_frozen(self); if (self == other) return self; GetHMAC(self, ctx1); GetHMAC(other, ctx2); if (!HMAC_CTX_copy(ctx1, ctx2)) ossl_raise(eHMACError, "HMAC_CTX_copy"); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::HMAC#reset;F;[;[[@]Ki;T;: reset;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', OpenSSL::Digest.new('sha1')) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.update(data) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 instance.reset #=> f42bb0eeb018ebbd4597ae7213711ec60760843f ;T;[o;H ;II" overload;F;J0;;;K0;#I" reset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @=k;[;I"@return [self];T;0; @=k;@F;Mi;N0;[; @=k;[;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', OpenSSL::Digest.new('sha1')) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.update(data) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 instance.reset #=> f42bb0eeb018ebbd4597ae7213711ec60760843f @overload reset @return [self];T;0; @=k;@F;Ao;B;CT;Di;Ei;!@j;"I"static VALUE ossl_hmac_reset(VALUE self) { HMAC_CTX *ctx; GetHMAC(self, ctx); HMAC_Init_ex(ctx, NULL, 0, NULL, NULL); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::HMAC#update;F;[[I" data;T0;[[@]Ki;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;H ;II" overload;F;J0;;;K0;#I"update(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @Xk;[;I"@return [self];T;0; @Xk;@F;Mi;N0;[[I" string;T0; @Xk;[;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; ; F; ;,;;;I"OpenSSL::HMAC#<<;F;[;[[@]Ki};F;;Q;;0;[;{;@ak;!@j;"I"static VALUE ossl_hmac_update(VALUE self, VALUE data) { HMAC_CTX *ctx; StringValue(data); GetHMAC(self, ctx); HMAC_Update(ctx, (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data)); return self; };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei;!@j;"I"static VALUE ossl_hmac_update(VALUE self, VALUE data) { HMAC_CTX *ctx; StringValue(data); GetHMAC(self, ctx); HMAC_Update(ctx, (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data)); return self; };T;#@|k;$T@tko; ; F; ;,;;;I"OpenSSL::HMAC#digest;F;[;[[@]Ki;T;;;0;[;{;IC;"Returns the authentication code an instance represents as a binary string. === Example instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1')) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.digest #=> "\xF4+\xB0\xEE\xB0\x18\xEB\xBDE\x97\xAEr\x13q\x1E\xC6\a`\x84?" ;T;[o;H ;II" overload;F;J0;;;K0;#I" digest;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k;[;I"@return [String];T;0; @k;@F;Mi;N0;[; @k;[;I">Returns the authentication code an instance represents as a binary string. === Example instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1')) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.digest #=> "\xF4+\xB0\xEE\xB0\x18\xEB\xBDE\x97\xAEr\x13q\x1E\xC6\a`\x84?" @overload digest @return [String];T;0; @k;@F;Ao;B;CT;Di;Ei;!@j;"I"Lstatic VALUE ossl_hmac_digest(VALUE self) { HMAC_CTX *ctx; unsigned int buf_len; VALUE ret; GetHMAC(self, ctx); ret = rb_str_new(NULL, EVP_MAX_MD_SIZE); hmac_final(ctx, (unsigned char *)RSTRING_PTR(ret), &buf_len); assert(buf_len <= EVP_MAX_MD_SIZE); rb_str_set_len(ret, buf_len); return ret; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::HMAC#hexdigest;F;[;[[@]Ki;T;;;0;[;{;IC;"TReturns the authentication code an instance represents as a hex-encoded string. ;T;[o;H ;II" overload;F;J0;;;K0;#I"hexdigest;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k;[;I"@return [String];T;0; @k;@F;Mi;N0;[; @k;[;I"}Returns the authentication code an instance represents as a hex-encoded string. @overload hexdigest @return [String];T;0; o; ; F; ;,;;;I"OpenSSL::HMAC#to_s;F;[;[[@]Ki;F;;h;;0;[;{;@k;!@j;"I"=static VALUE ossl_hmac_hexdigest(VALUE self) { HMAC_CTX *ctx; unsigned char buf[EVP_MAX_MD_SIZE]; unsigned int buf_len; VALUE ret; GetHMAC(self, ctx); hmac_final(ctx, buf, &buf_len); ret = rb_str_new(NULL, buf_len * 2); ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len); return ret; };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei;!@j;"I"=static VALUE ossl_hmac_hexdigest(VALUE self) { HMAC_CTX *ctx; unsigned char buf[EVP_MAX_MD_SIZE]; unsigned int buf_len; VALUE ret; GetHMAC(self, ctx); hmac_final(ctx, buf, &buf_len); ret = rb_str_new(NULL, buf_len * 2); ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len); return ret; };T;#@k;$To; ; F; ;,;;;I"OpenSSL::HMAC#inspect;F;[;[[@]Ki;F;;i;;0;[;{;@k;!@j;"I"=static VALUE ossl_hmac_hexdigest(VALUE self) { HMAC_CTX *ctx; unsigned char buf[EVP_MAX_MD_SIZE]; unsigned int buf_len; VALUE ret; GetHMAC(self, ctx); hmac_final(ctx, buf, &buf_len); ret = rb_str_new(NULL, buf_len * 2); ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len); return ret; };T;#@k@k;&@j;'IC;[;&@j;(IC;[;&@j;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@tk;@k;@k;;.[;[[@]KiT[@]Kir;T;: HMAC;;0;;;[;{;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.read("file1") data2 = File.read("file2") key = "key" digest = OpenSSL::Digest::SHA256.new hmac = OpenSSL::HMAC.new(key, digest) 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.read("file1") data2 = File.read("file2") key = "key" digest = OpenSSL::Digest::SHA256.new hmac = OpenSSL::HMAC.new(key, digest) hmac << data1 hmac << data2 mac = hmac.digest ;T;0; @j;@F;Ao;B;CT;DiT;Eim;!@DK;I"OpenSSL::HMAC;F;1@;0;[;{;IC;"^Returns the name of the cipher which may differ slightly from the original name provided. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @l;[;I"@return [String];T;0; @l;@F;Mi;N0;[; @l;[;I"}Returns the name of the cipher which may differ slightly from the original name provided. @overload name @return [String];T;0; @l;@F;Ao;B;CT;Di;Ei;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#key=;F;[[I"key;T0;[[@_Ki;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;H ;II" overload;F;J0;;;K0;#I"key=(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @m;[;I"@return [String];T;0; @m;@F;Mi;N0;[[I" string;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#auth_data=;F;[[I" data;T0;[[@_Ki1;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;H ;II" overload;F;J0;;;K0;#I"auth_data=(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @$m;[;I"@return [String];T;0; @$m;@F;Mi;N0;[[I" string;T0; @$m;[;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; @$m;@F;Ao;B;CT;Di;Ei/;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#auth_tag=;F;[[I" vtag;T0;[[@_Ki|;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;H ;II" overload;F;J0;;;K0;#I"auth_tag=(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Cm;[;I"@return [String];T;0; @Cm;@F;Mi;N0;[[I" string;T0; @Cm;[;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; @Cm;@F;Ao;B;CT;Dio;Eiz;!@k;"I"<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; ; F; ;,;;;I"OpenSSL::Cipher#auth_tag;F;[[@0;[[@_KiV;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;H ;II" overload;F;J0;;;K0;#I"auth_tag(tag_len = 16);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @bm;[;I"@return [String];T;0; @bm;@F;Mi;N0;[[I" tag_len;TI"16;T; @bm;[;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; @bm;@F;Ao;B;CT;DiG;EiT;!@k;"I"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; ; F; ;,;;;I""OpenSSL::Cipher#auth_tag_len=;F;[[I" vlen;T0;[[@_Ki;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;H ;II" overload;F;J0;;;K0;#I"auth_tag_len=(Integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @m;[;I"@return [Integer];T;0; @m;@F;Mi;N0;[[I" Integer;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;!@k;"I"$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; ; F; ;,;;;I"#OpenSSL::Cipher#authenticated?;F;[;[[@_Ki;T;:authenticated?;0;[;{;IC;"RIndicated whether this Cipher instance uses an Authenticated Encryption mode.;T;[o;H ;II" overload;F;J0;;;K0;#I"authenticated?;T;IC;";T;[;[;I";T;0; @m;@F;Mi;N0;[; @mo;L ;II" return;F;J@;0;K[@; @m;[;I"mIndicated whether this Cipher instance uses an Authenticated Encryption mode. @overload authenticated?;T;0; @m;@F;Ao;B;CT;Di;Ei;Mi;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#key_len=;F;[[I"key_length;T0;[[@_Ki;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;H ;II" overload;F;J0;;;K0;#I"key_len=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @m;[;I"@return [Integer];T;0; @m;@F;Mi;N0;[[I" integer;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#key_len;F;[;[[@_Ki;T;: key_len;0;[;{;IC;"3Returns the key length in bytes of the Cipher. ;T;[o;H ;II" overload;F;J0;;;K0;#I" key_len;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @m;[;I"@return [Integer];T;0; @m;@F;Mi;N0;[; @m;[;I"[Returns the key length in bytes of the Cipher. @overload key_len @return [Integer];T;0; @m;@F;Ao;B;CT;Di;Ei;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#iv=;F;[[I"iv;T0;[[@_Ki;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;H ;II" overload;F;J0;;;K0;#I"iv=(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @m;[;I"@return [String];T;0; @m;@F;Mi;N0;[[I" string;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#iv_len=;F;[[I"iv_length;T0;[[@_Ki;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;H ;II" overload;F;J0;;;K0;#I"iv_len=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @n;[;I"@return [Integer];T;0; @n;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#iv_len;F;[;[[@_Ki;T;: iv_len;0;[;{;IC;"DReturns the expected length in bytes for an IV for this Cipher. ;T;[o;H ;II" overload;F;J0;;;K0;#I" iv_len;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @1n;[;I"@return [Integer];T;0; @1n;@F;Mi;N0;[; @1n;[;I"kReturns the expected length in bytes for an IV for this Cipher. @overload iv_len @return [Integer];T;0; @1n;@F;Ao;B;CT;Di ;Ei;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#block_size;F;[;[[@_Ki';T;:block_size;0;[;{;IC;"NReturns the size in bytes of the blocks on which this Cipher operates on. ;T;[o;H ;II" overload;F;J0;;;K0;#I"block_size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Ln;[;I"@return [Integer];T;0; @Ln;@F;Mi;N0;[; @Ln;[;I"yReturns the size in bytes of the blocks on which this Cipher operates on. @overload block_size @return [Integer];T;0; @Ln;@F;Ao;B;CT;Di!;Ei%;!@k;"I"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; ; F; ;,;;;I"OpenSSL::Cipher#padding=;F;[[I" padding;T0;[[@_Ki;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;H ;II" overload;F;J0;;;K0;#I"padding=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @gn;[;I"@return [Integer];T;0; @gn;@F;Mi;N0;[[I" integer;T0; @gn;[;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; @gn;@F;Ao;B;CT;Di;Ei;!@k;"I"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;$T;&@k;'IC;[;&@k;(IC;[;&@k;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@_Ki<[@_Ki ;T;: Cipher;;0;;;[;{;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') For each algorithm supported, there is a class defined under the Cipher class that goes by the name of the cipher, e.g. to obtain an instance of AES, you could also use # these are equivalent cipher = OpenSSL::Cipher::AES.new(128, :CBC) cipher = OpenSSL::Cipher::AES.new(128, 'CBC') cipher = OpenSSL::Cipher::AES.new('128-CBC') Finally, due to its wide-spread use, there are also extra classes defined for the different key sizes of AES cipher = OpenSSL::Cipher::AES128.new(:CBC) cipher = OpenSSL::Cipher::AES192.new(:CBC) cipher = OpenSSL::Cipher::AES256.new(: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::AES256.new(: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::AES.new(128, :CBC) cipher.encrypt key = cipher.random_key iv = cipher.random_iv encrypted = cipher.update(data) + cipher.final ... decipher = OpenSSL::Cipher::AES.new(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::AES.new(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::AES.new(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') For each algorithm supported, there is a class defined under the Cipher class that goes by the name of the cipher, e.g. to obtain an instance of AES, you could also use # these are equivalent cipher = OpenSSL::Cipher::AES.new(128, :CBC) cipher = OpenSSL::Cipher::AES.new(128, 'CBC') cipher = OpenSSL::Cipher::AES.new('128-CBC') Finally, due to its wide-spread use, there are also extra classes defined for the different key sizes of AES cipher = OpenSSL::Cipher::AES128.new(:CBC) cipher = OpenSSL::Cipher::AES192.new(:CBC) cipher = OpenSSL::Cipher::AES256.new(: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::AES256.new(: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::AES.new(128, :CBC) cipher.encrypt key = cipher.random_key iv = cipher.random_iv encrypted = cipher.update(data) + cipher.final ... decipher = OpenSSL::Cipher::AES.new(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::AES.new(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::AES.new(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; @k;@F;Ao;B;CT;Di<;Ei ;!@DK;I"OpenSSL::Cipher;F;1@ "\xDA\xE4\xE2...\x7F\xA1\x01T" ;T;[o;H ;II" overload;F;J0;;;K0;#I"-scrypt(pass, salt:, N:, r:, p:, length:);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @o;[;I"@return [aString];T;0; @o;@F;Mi;N0;[ [I" pass;T0[I" salt:;TI";T[I"N:;TI",r:;T[I"p:;TI";T[I" length:;TI";T; @o;[;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; @o;@F;N0;!@ o;"I"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; ; T; ;;;;I"OpenSSL::KDF.scrypt;F;@o;@o;T;;;0;@o;{;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;H ;II" overload;F;J0;;;K0;#I"-scrypt(pass, salt:, N:, r:, p:, length:);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @o;[;I"@return [aString];T;0; @o;@F;Mi;N0;[ [I" pass;T0[I" salt:;TI";T[I"N:;TI",r:;T[I"p:;TI";T[I" length:;TI";T; @o;[;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; @o;@F;Ao;B;CT;DiL;Eij;Mi;!@ o;"@o;#@o;$To; ; F; ;,;;;I"OpenSSL::KDF#hkdf;F;[[@0;[[@cKi;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. ;T;[o;H ;II" overload;F;J0;;;K0;#I",hkdf(ikm, salt:, info:, length:, hash:);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @o;[;I"@return [String];T;0; @o;@F;Mi;N0;[ [I"ikm;T0[I" salt:;TI";T[I" info:;TI";T[I" length:;TI";T[I" hash:;TI";T; @o;[;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. @overload hkdf(ikm, salt:, info:, length:, hash:) @return [String];T;0; @o;@F;N0;!@ o;"I"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; ; T; ;;;;I"OpenSSL::KDF.hkdf;F;@o;@o;T;;;0;@o;{;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.;T;[o;H ;II" overload;F;J0;;;K0;#I",hkdf(ikm, salt:, info:, length:, hash:);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @o;[;I"@return [String];T;0; @o;@F;Mi;N0;[ [I"ikm;T0[I" salt:;TI";T[I" info:;TI";T[I" length:;TI";T[I" hash:;TI";T; @o;[;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. @overload hkdf(ikm, salt:, info:, length:, hash:) @return [String];T;0; @o;@F;Ao;B;CT;Di;Ei;Mi;!@ o;"@o;#@o;$T;&@ o;'IC;[;&@ o;(IC;[;&@ o;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@cKi[@cKi2;T;:KDF;;0;;;[;{;IC;"XProvides 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::SHA256.new 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 compare two values, the following could be used: def eql_time_cmp(a, b) unless a.length == b.length return false end cmp = b.bytes result = 0 a.bytes.each_with_index {|c,i| result |= c ^ cmp[i] } result == 0 end Please note that the premature return in case of differing lengths typically does not leak valuable information - when using PBKDF2, the length of the values to be compared is of fixed size. ;T;[;[;I"Z 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::SHA256.new 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 compare two values, the following could be used: def eql_time_cmp(a, b) unless a.length == b.length return false end cmp = b.bytes result = 0 a.bytes.each_with_index {|c,i| result |= c ^ cmp[i] } result == 0 end Please note that the premature return in case of differing lengths typically does not leak valuable information - when using PBKDF2, the length of the values to be compared is of fixed size. ;T;0; @ o;@F;Ao;B;CT;Di;Ei/;!@DK;I"OpenSSL::KDF;Fo; ;IC;[;&@)p;'IC;[;&@)p;(IC;[;&@)p;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@eKi[@eKiV;T;:ConfigError;;0;;;[;{;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; @)p;@F;Ao;B;CT;Di;Ei;!o;2 ;30;40;50;: OpenSSL;!@;7@DK;F0;I"OpenSSL::ConfigError;F;1@FKo; ;IC;[o;9;[[@eKiZ;F;:DEFAULT_CONFIG_FILE;;;;;;[;{;IC;"6The default system configuration file for openssl ;T;[;[;I"8 The default system configuration file for openssl ;T;0; @@p;!@>p;I")OpenSSL::Config::DEFAULT_CONFIG_FILE;F;p;'IC;[;&@>p;(IC;[;&@>p;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@eKiW;F;: Config;;0;;;[;{;IC;" ;T;[;[;@;0; @>p;Mi;!@DK;I"OpenSSL::Config;F;1@ Generic error class raised by SSLSocket and SSLContext. ;T;0; @\p;@F;Ao;B;CT;Diz ;Ei| ;!@Zp;I"OpenSSL::SSL::SSLError;F;1@FKo; ;IC;[;&@pp;'IC;[;&@pp;(IC;[@M;&@pp;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Yi ;F;:SSLErrorWaitReadable;;0;;;[;{;IC;" ;T;[;[;@;0; @pp;!@Zp;I"'OpenSSL::SSL::SSLErrorWaitReadable;F;1@\po; ;IC;[;&@p;'IC;[;&@p;(IC;[@`;&@p;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Yi ;F;:SSLErrorWaitWritable;;0;;;[;{;IC;" ;T;[;[;@;0; @p;!@Zp;I"'OpenSSL::SSL::SSLErrorWaitWritable;F;1@\po; ;IC;[#o; ; F; ;,;;;I")OpenSSL::SSL::SSLContext#ssl_timeout;F;[;[[@Yi ;F;:ssl_timeout;;0;[;{;IC;" ;T;[;[;@;0; @p;!@p;#I"def ssl_timeout;To; ; F; ;,;;;I"*OpenSSL::SSL::SSLContext#ssl_timeout=;F;[;[[@Yi ;F;:ssl_timeout=;;0;[;{;IC;" ;T;[;[;@;0; @p;!@p;#I"def ssl_timeout=;To; ; F; ;,;;;I"6OpenSSL::SSL::SSLContext#set_minmax_proto_version;F;[[I" min_v;T0[I" max_v;T0;[[@Yi;T;:set_minmax_proto_version;0;[;{;IC;"cSets the minimum and maximum supported protocol versions. See #min_version= and #max_version=. ;T;[o;H ;II" overload;F;J0;;;K0;#I"'set_minmax_proto_version(min, max);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @p;[;I"@return [nil];T;0; @p;@F;Mi;N0;[[I"min;T0[I"max;T0; @p;[;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; @p;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"%OpenSSL::SSL::SSLContext#ciphers;F;[;[[@Yi;T;;;0;[;{;IC;";The list of cipher suites configured for this context. ;T;[o;H ;II" overload;F;J0;;;K0;#I" ciphers;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @p;[;I"@return [Array];T;0; @p;@F;Mi;N0;[; @p;[;I"aThe list of cipher suites configured for this context. @overload ciphers @return [Array];T;0; @p;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"&OpenSSL::SSL::SSLContext#ciphers=;F;[[I"v;T0;[[@Yi;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; @p;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"*OpenSSL::SSL::SSLContext#ecdh_curves=;F;[[I"arg;T0;[[@Yi2;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. Note that this works differently with old OpenSSL (<= 1.0.1). Only one curve can be set, and this has no effect for TLS clients. === 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;H ;II" overload;F;J0;;;K0;#I"ecdh_curves=(curve_list);T;IC;";T;[;[;I";T;0; @p;@F;Mi;N0;[[I"curve_list;T0; @p;[;I"HSets 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. Note that this works differently with old OpenSSL (<= 1.0.1). Only one curve can be set, and this has no effect for TLS clients. === 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; @p;@F;Ao;B;CT;Di;Ei/;!@p;"I"static VALUE ossl_sslctx_set_ecdh_curves(VALUE self, VALUE arg) { SSL_CTX *ctx; rb_check_frozen(self); GetSSLCTX(self, ctx); StringValueCStr(arg); #if defined(HAVE_SSL_CTX_SET1_CURVES_LIST) if (!SSL_CTX_set1_curves_list(ctx, RSTRING_PTR(arg))) ossl_raise(eSSLError, NULL); #else /* OpenSSL does not have SSL_CTX_set1_curves_list()... Fallback to * SSL_CTX_set_tmp_ecdh(). So only the first curve is used. */ { VALUE curve, splitted; EC_KEY *ec; int nid; splitted = rb_str_split(arg, ":"); if (!RARRAY_LEN(splitted)) ossl_raise(eSSLError, "invalid input format"); curve = RARRAY_AREF(splitted, 0); StringValueCStr(curve); /* SSL_CTX_set1_curves_list() accepts NIST names */ nid = EC_curve_nist2nid(RSTRING_PTR(curve)); if (nid == NID_undef) nid = OBJ_txt2nid(RSTRING_PTR(curve)); if (nid == NID_undef) ossl_raise(eSSLError, "unknown curve name"); ec = EC_KEY_new_by_curve_name(nid); if (!ec) ossl_raise(eSSLError, NULL); EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE); if (!SSL_CTX_set_tmp_ecdh(ctx, ec)) { EC_KEY_free(ec); ossl_raise(eSSLError, "SSL_CTX_set_tmp_ecdh"); } EC_KEY_free(ec); # if defined(HAVE_SSL_CTX_SET_ECDH_AUTO) /* tmp_ecdh and ecdh_auto conflict. tmp_ecdh is ignored when ecdh_auto * is enabled. So disable ecdh_auto. */ if (!SSL_CTX_set_ecdh_auto(ctx, 0)) ossl_raise(eSSLError, "SSL_CTX_set_ecdh_auto"); # endif } #endif return arg; };T;#I"static VALUE;T;$To; ; F; ;,;;;I",OpenSSL::SSL::SSLContext#security_level;F;[;[[@Yis;T;:security_level;0;[;{;IC;"dReturns the security level for the context. See also OpenSSL::SSL::SSLContext#security_level=. ;T;[o;H ;II" overload;F;J0;;;K0;#I"security_level;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @q;[;I"@return [Integer];T;0; @q;@F;Mi;N0;[; @q;[;I"Returns the security level for the context. See also OpenSSL::SSL::SSLContext#security_level=. @overload security_level @return [Integer];T;0; @q;@F;Ao;B;CT;Dik;Eiq;!@p;"I"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; ; F; ;,;;;I"-OpenSSL::SSL::SSLContext#security_level=;F;[[I" value;T0;[[@Yi;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;H ;II" overload;F;J0;;;K0;#I"security_level=(integer);T;IC;";T;[;[;I";T;0; @-q;@F;Mi;N0;[[I" integer;T0; @-q;[;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; @-q;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"2OpenSSL::SSL::SSLContext#enable_fallback_scsv;F;[;[[@Yi;T;:enable_fallback_scsv;0;[;{;IC;"?Activate TLS_FALLBACK_SCSV for this context. See RFC 7507. ;T;[o;H ;II" overload;F;J0;;;K0;#I"enable_fallback_scsv();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @Gq;[;I"@return [nil];T;0; @Gq;@F;Mi;N0;[; @Gq;[;I"rActivate TLS_FALLBACK_SCSV for this context. See RFC 7507. @overload enable_fallback_scsv() @return [nil];T;0; @Gq;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"-OpenSSL::SSL::SSLContext#add_certificate;F;[[@0;[[@Yi;T;;V;0;[;{;IC;"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]) === Note OpenSSL before the version 1.0.2 could handle only one extra chain across all key types. Calling this method discards the chain set previously. ;T;[o;H ;II" overload;F;J0;;V;K0;#I"7add_certificate(certiticate, pkey [, extra_certs]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @bq;[;I"@return [self];T;0; @bq;@F;Mi;N0;[[I"certiticate;T0[I"pkey[, extra_certs];T0; @bq;[;I"RAdds 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]) === Note OpenSSL before the version 1.0.2 could handle only one extra chain across all key types. Calling this method discards the chain set previously. @overload add_certificate(certiticate, pkey [, extra_certs]) @return [self];T;0; @bq;@F;Ao;B;CT;Di;Ei;!@p;"I"Fstatic 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_cmp(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) { #if OPENSSL_VERSION_NUMBER >= 0x10002000 && !defined(LIBRESSL_VERSION_NUMBER) if (!SSL_CTX_set0_chain(ctx, extra_chain)) { sk_X509_pop_free(extra_chain, X509_free); ossl_raise(eSSLError, "SSL_CTX_set0_chain"); } #else STACK_OF(X509) *orig_extra_chain; X509 *x509_tmp; /* First, clear the existing chain */ SSL_CTX_get_extra_chain_certs(ctx, &orig_extra_chain); if (orig_extra_chain && sk_X509_num(orig_extra_chain)) { rb_warning("SSL_CTX_set0_chain() is not available; " \ "clearing previously set certificate chain"); SSL_CTX_clear_extra_chain_certs(ctx); } while ((x509_tmp = sk_X509_shift(extra_chain))) { /* Transfers ownership */ if (!SSL_CTX_add_extra_chain_cert(ctx, x509_tmp)) { X509_free(x509_tmp); sk_X509_pop_free(extra_chain, X509_free); ossl_raise(eSSLError, "SSL_CTX_add_extra_chain_cert"); } } sk_X509_free(extra_chain); #endif } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"#OpenSSL::SSL::SSLContext#setup;F;[;[[@Yi;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;H ;II" overload;F;J0;;;K0;#I" setup;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Qtrue #firstt time;T; @q;[;I"!@return [Qtrue # first time];T;0; @q;@F;Mi;N0;[; @qo;H ;II" overload;F;J0;;;K0;#I" setup;T;IC;";T;[;[;I";T;0; @q;@F;Mi;N0;[; @q;[;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; ; F; ;,;;;I"$OpenSSL::SSL::SSLContext#freeze;F;[;[[@Yi ;F;;f;;0;[;{;@q;!@p;"I"static 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 #if !defined(OPENSSL_NO_EC) /* We added SSLContext#tmp_ecdh_callback= in Ruby 2.3.0, * but SSL_CTX_set_tmp_ecdh_callback() was removed in OpenSSL 1.1.0. */ if (RTEST(rb_attr_get(self, id_i_tmp_ecdh_callback))) { # if defined(HAVE_SSL_CTX_SET_TMP_ECDH_CALLBACK) rb_warn("#tmp_ecdh_callback= is deprecated; use #ecdh_curves= instead"); SSL_CTX_set_tmp_ecdh_callback(ctx, ossl_tmp_ecdh_callback); # if defined(HAVE_SSL_CTX_SET_ECDH_AUTO) /* tmp_ecdh_callback and ecdh_auto conflict; OpenSSL ignores * tmp_ecdh_callback. So disable ecdh_auto. */ if (!SSL_CTX_set_ecdh_auto(ctx, 0)) ossl_raise(eSSLError, "SSL_CTX_set_ecdh_auto"); # endif # else ossl_raise(eSSLError, "OpenSSL does not support tmp_ecdh_callback; " "use #ecdh_curves= instead"); # endif } #endif /* OPENSSL_NO_EC */ 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); #if !defined(HAVE_X509_STORE_UP_REF) /* * WORKAROUND: * X509_STORE can count references, but * X509_STORE_free() doesn't care it. * So we won't increment it but mark it by ex_data. */ SSL_CTX_set_ex_data(ctx, ossl_sslctx_ex_store_p, ctx); #else /* Fixed in OpenSSL 1.0.2; bff9ce4db38b (master), 5b4b9ce976fc (1.0.2) */ X509_STORE_up_ref(store); #endif } 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); if(ca_file || ca_path){ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path)) rb_warning("can't set verify locations"); } 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 *)encoded); 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 #ifdef HAVE_SSL_CTX_SET_ALPN_SELECT_CB 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"); } #endif 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;Ao;B;CT;Di;Ei;!@p;"I"static 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 #if !defined(OPENSSL_NO_EC) /* We added SSLContext#tmp_ecdh_callback= in Ruby 2.3.0, * but SSL_CTX_set_tmp_ecdh_callback() was removed in OpenSSL 1.1.0. */ if (RTEST(rb_attr_get(self, id_i_tmp_ecdh_callback))) { # if defined(HAVE_SSL_CTX_SET_TMP_ECDH_CALLBACK) rb_warn("#tmp_ecdh_callback= is deprecated; use #ecdh_curves= instead"); SSL_CTX_set_tmp_ecdh_callback(ctx, ossl_tmp_ecdh_callback); # if defined(HAVE_SSL_CTX_SET_ECDH_AUTO) /* tmp_ecdh_callback and ecdh_auto conflict; OpenSSL ignores * tmp_ecdh_callback. So disable ecdh_auto. */ if (!SSL_CTX_set_ecdh_auto(ctx, 0)) ossl_raise(eSSLError, "SSL_CTX_set_ecdh_auto"); # endif # else ossl_raise(eSSLError, "OpenSSL does not support tmp_ecdh_callback; " "use #ecdh_curves= instead"); # endif } #endif /* OPENSSL_NO_EC */ 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); #if !defined(HAVE_X509_STORE_UP_REF) /* * WORKAROUND: * X509_STORE can count references, but * X509_STORE_free() doesn't care it. * So we won't increment it but mark it by ex_data. */ SSL_CTX_set_ex_data(ctx, ossl_sslctx_ex_store_p, ctx); #else /* Fixed in OpenSSL 1.0.2; bff9ce4db38b (master), 5b4b9ce976fc (1.0.2) */ X509_STORE_up_ref(store); #endif } 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); if(ca_file || ca_path){ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path)) rb_warning("can't set verify locations"); } 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 *)encoded); 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 #ifdef HAVE_SSL_CTX_SET_ALPN_SELECT_CB 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"); } #endif 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;#@q;$T@qo;9;[[@Yi ;F;:SESSION_CACHE_OFF;;;;;;[;{;IC;",No session caching for client or server ;T;[;[;I"-No session caching for client or server ;T;0; @q;@F;Ao;B;CT;Di ;Ei ;!@p;I"0OpenSSL::SSL::SSLContext::SESSION_CACHE_OFF;F;Never automatically store sessions in the internal store. ;T;[;[;I"?Never automatically store sessions in the internal store. ;T;0; @q;@F;Ao;B;CT;Di ;Ei ;!@p;I">OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE;F;;!@p;"I"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; ; F; ;,;;;I"0OpenSSL::SSL::SSLContext#session_cache_mode;F;[;[[@YiS;T;:session_cache_mode;0;[;{;IC;"$The current session cache mode. ;T;[o;H ;II" overload;F;J0;;;K0;#I"session_cache_mode;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Ar;[;I"@return [Integer];T;0; @Ar;@F;Mi;N0;[; @Ar;[;I"WThe current session cache mode. @overload session_cache_mode @return [Integer];T;0; @Ar;@F;Ao;B;CT;DiM;EiQ;!@p;"I"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; ; F; ;,;;;I"1OpenSSL::SSL::SSLContext#session_cache_mode=;F;[[I"arg;T0;[[@Yie;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;H ;II" overload;F;J0;;;K0;#I"!session_cache_mode=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @\r;[;I"@return [Integer];T;0; @\r;@F;Mi;N0;[[I" integer;T0; @\r;[;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; @\r;@F;Ao;B;CT;Di];Eic;!@p;"I"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; ; F; ;,;;;I"0OpenSSL::SSL::SSLContext#session_cache_size;F;[;[[@Yix;T;:session_cache_size;0;[;{;IC;"`Returns the current session cache size. Zero is used to represent an unlimited cache size. ;T;[o;H ;II" overload;F;J0;;;K0;#I"session_cache_size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @{r;[;I"@return [Integer];T;0; @{r;@F;Mi;N0;[; @{r;[;I"Returns the current session cache size. Zero is used to represent an unlimited cache size. @overload session_cache_size @return [Integer];T;0; @{r;@F;Ao;B;CT;Diq;Eiv;!@p;"I"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; ; F; ;,;;;I"1OpenSSL::SSL::SSLContext#session_cache_size=;F;[[I"arg;T0;[[@Yi;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;H ;II" overload;F;J0;;;K0;#I"!session_cache_size=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @r;[;I"@return [Integer];T;0; @r;@F;Mi;N0;[[I" integer;T0; @r;[;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; @r;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"1OpenSSL::SSL::SSLContext#session_cache_stats;F;[;[[@Yi;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;H ;II" overload;F;J0;;;K0;#I"session_cache_stats;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @r;[;I"@return [Hash];T;0; @r;@F;Mi;N0;[; @r;[;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; @r;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I",OpenSSL::SSL::SSLContext#flush_sessions;F;[[@0;[[@Yi;T;:flush_sessions;0;[;{;IC;"HRemoves sessions in the internal cache that have expired at _time_. ;T;[o;H ;II" overload;F;J0;;;K0;#I"flush_sessions(time);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @r;[;I"@return [self];T;0; @r;@F;Mi;N0;[[I" time;T0; @r;[;I"zRemoves sessions in the internal cache that have expired at _time_. @overload flush_sessions(time) @return [self];T;0; @r;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"%OpenSSL::SSL::SSLContext#options;F;[;[[@Yi;T;;;0;[;{;IC;""Gets various OpenSSL options. ;T;[;[;I"#Gets various OpenSSL options. ;T;0; @r;@F;Ao;B;CT;Di;Ei;!@p;"I"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; ; F; ;,;;;I"&OpenSSL::SSL::SSLContext#options=;F;[[I" options;T0;[[@Yi;T;: options=;0;[;{;IC;""Sets various OpenSSL options. ;T;[;[;I"#Sets various OpenSSL options. ;T;0; @r;@F;Ao;B;CT;Di;Ei;!@p;"I"\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;&@p;'IC;[;&@p;(IC;[;&@p;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@p: timeout@p: timeout=@q;;.[;[[@Yi [@Yi ;T;:SSLContext;;0;;;[;{;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; @p;@F;Ao;B;CT;Di ;Ei ;!@Zp;I"OpenSSL::SSL::SSLContext;F;1@ DON'T FREE. */ if (!cert) { return Qnil; } return ossl_x509_new(cert); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&OpenSSL::SSL::SSLSocket#peer_cert;F;[;[[@Yi;T;:peer_cert;0;[;{;IC;"1The X509 certificate for this socket's peer. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"peer_cert;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @t;[;I"@return [nil];T;0; @t;@F;Mi;N0;[; @t;[;I"WThe X509 certificate for this socket's peer. @overload peer_cert @return [nil];T;0; @t;@F;Ao;B;CT;Di;Ei;!@s;"I">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; ; F; ;,;;;I",OpenSSL::SSL::SSLSocket#peer_cert_chain;F;[;[[@Yi7;T;:peer_cert_chain;0;[;{;IC;"7The X509 certificate chain for this socket's peer. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"peer_cert_chain;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @t;[;I"@return [Array, nil];T;0; @t;@F;Mi;N0;[; @t;[;I"jThe X509 certificate chain for this socket's peer. @overload peer_cert_chain @return [Array, nil];T;0; @t;@F;Ao;B;CT;Di1;Ei5;!@s;"I"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; ; F; ;,;;;I"(OpenSSL::SSL::SSLSocket#ssl_version;F;[;[[@YiU;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;H ;II" overload;F;J0;;;K0;#I"ssl_version;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @t;[;I"@return [String];T;0; @t;@F;Mi;N0;[; @t;[;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; @t;@F;Ao;B;CT;DiN;EiS;!@s;"I"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; ; F; ;,;;;I"#OpenSSL::SSL::SSLSocket#cipher;F;[;[[@Yif;T;: cipher;0;[;{;IC;"nReturns the cipher suite actually used in the current session, or nil if no session has been established. ;T;[o;H ;II" overload;F;J0;;;K0;#I" cipher;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;TI" Array;T; @t;[;I"@return [nil, Array];T;0; @t;@F;Mi;N0;[; @t;[;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; @t;@F;Ao;B;CT;Di_;Eid;!@s;"I"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; ; F; ;,;;;I""OpenSSL::SSL::SSLSocket#state;F;[;[[@Yix;T;;;0;[;{;IC;"YA description of the current connection state. This is for diagnostic purposes only. ;T;[o;H ;II" overload;F;J0;;;K0;#I" state;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @u;[;I"@return [String];T;0; @u;@F;Mi;N0;[; @u;[;I"~A description of the current connection state. This is for diagnostic purposes only. @overload state @return [String];T;0; @u;@F;Ao;B;CT;Diq;Eiv;!@s;"I"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; ; F; ;,;;;I"$OpenSSL::SSL::SSLSocket#pending;F;[;[[@Yi;T;: pending;0;[;{;IC;"DThe number of bytes that are immediately available for reading. ;T;[o;H ;II" overload;F;J0;;;K0;#I" pending;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @u;[;I"@return [Integer];T;0; @u;@F;Mi;N0;[; @u;[;I"lThe number of bytes that are immediately available for reading. @overload pending @return [Integer];T;0; @u;@F;Ao;B;CT;Di;Ei;!@s;"I"static VALUE ossl_ssl_pending(VALUE self) { SSL *ssl; GetSSL(self, ssl); return INT2NUM(SSL_pending(ssl)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I",OpenSSL::SSL::SSLSocket#session_reused?;F;[;[[@Yi;T;:session_reused?;0;[;{;IC;"LReturns +true+ if a reused session was negotiated during the handshake.;T;[o;H ;II" overload;F;J0;;;K0;#I"session_reused?;T;IC;";T;[;[;I";T;0; @7u;@F;Mi;N0;[; @7uo;L ;II" return;F;J@;0;K[@; @7u;[;I"hReturns +true+ if a reused session was negotiated during the handshake. @overload session_reused?;T;0; @7u;@F;Ao;B;CT;Di;Ei;Mi;!@s;"I"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; ; F; ;,;;;I"%OpenSSL::SSL::SSLSocket#session=;F;[[I" arg1;T0;[[@Yi;T;: session=;0;[;{;IC;"DSets the Session to be used when the connection is established. ;T;[o;H ;II" overload;F;J0;;;K0;#I"session=(session);T;IC;";T;[;[;I";T;0; @Pu;@F;Mi;N0;[[I" session;T0; @Pu;[;I"bSets the Session to be used when the connection is established. @overload session=(session);T;0; @Pu;@F;Ao;B;CT;Di;Ei;!@s;"I"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; ; F; ;,;;;I"*OpenSSL::SSL::SSLSocket#verify_result;F;[;[[@Yi;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;H ;II" overload;F;J0;;;K0;#I"verify_result;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @ju;[;I"@return [Integer];T;0; @ju;@F;Mi;N0;[; @ju;[;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; @ju;@F;Ao;B;CT;Di;Ei;!@s;"I"static VALUE ossl_ssl_get_verify_result(VALUE self) { SSL *ssl; GetSSL(self, ssl); return INT2NUM(SSL_get_verify_result(ssl)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"&OpenSSL::SSL::SSLSocket#client_ca;F;[;[[@Yi;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;H ;II" overload;F;J0;;;K0;#I"client_ca;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @u;[;I"@return [Array];T;0; @u;@F;Mi;N0;[; @u;[;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; @u;@F;Ao;B;CT;Di;Ei;!@s;"I"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; ; F; ;,;;;I"&OpenSSL::SSL::SSLSocket#hostname=;F;[[I"arg;T0;[[@Yi;T;:hostname=;0;[;{;IC;"ZSets the server hostname used for SNI. This needs to be set before SSLSocket#connect. ;T;[o;H ;II" overload;F;J0;;;K0;#I"hostname=(hostname);T;IC;";T;[;[;I";T;0; @u;@F;Mi;N0;[[I" hostname;T0; @u;[;I"zSets the server hostname used for SNI. This needs to be set before SSLSocket#connect. @overload hostname=(hostname);T;0; @u;@F;Ao;B;CT;Di;Ei;!@s;"I"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; ; F; ;,;;;I"$OpenSSL::SSL::SSLSocket#tmp_key;F;[;[[@Yi; ;T;: tmp_key;0;[;{;IC;"FReturns the ephemeral key used in case of forward secrecy cipher. ;T;[o;H ;II" overload;F;J0;;;K0;#I" tmp_key;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" PKey;TI"nil;T; @u;[;I"@return [PKey, nil];T;0; @u;@F;Mi;N0;[; @u;[;I"pReturns the ephemeral key used in case of forward secrecy cipher. @overload tmp_key @return [PKey, nil];T;0; @u;@F;Ao;B;CT;Di5 ;Ei9 ;!@s;"I"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; ; F; ;,;;;I"*OpenSSL::SSL::SSLSocket#alpn_protocol;F;[;[[@Yi# ;T;:alpn_protocol;0;[;{;IC;"cReturns the ALPN protocol string that was finally selected by the server during the handshake. ;T;[o;H ;II" overload;F;J0;;;K0;#I"alpn_protocol;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"String | nil;T; @u;[;I"@return [String | nil];T;0; @u;@F;Mi;N0;[; @u;[;I"Returns the ALPN protocol string that was finally selected by the server during the handshake. @overload alpn_protocol @return [String | nil];T;0; @u;@F;Ao;B;CT;Di ;Ei! ;!@s;"I"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; ; F; ;,;;;I")OpenSSL::SSL::SSLSocket#npn_protocol;F;[;[[@Yi ;T;:npn_protocol;0;[;{;IC;"^Returns the protocol string that was finally selected by the client during the handshake. ;T;[o;H ;II" overload;F;J0;;;K0;#I"npn_protocol;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"String | nil;T; @u;[;I"@return [String | nil];T;0; @u;@F;Mi;N0;[; @u;[;I"Returns the protocol string that was finally selected by the client during the handshake. @overload npn_protocol @return [String | nil];T;0; @u;@F;Ao;B;CT;Di ;Ei ;!@s;"I" 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;&@s;'IC;[;&@s;(IC;[;&@s;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Yi ;F;:SSLSocket;;0;;;[;{;IC;" ;T;[;[;@;0; @s;Mi;!@Zp;I"OpenSSL::SSL::SSLSocket;F;1@ ;F;:OP_SINGLE_DH_USE;;;;;;[;{;IC;"!Deprecated in OpenSSL 1.1.0. ;T;[;[;I"!Deprecated in OpenSSL 1.1.0.;T;0; @w;@F;Ao;B;CT;Di= ;Ei= ;!@Zp;I"#OpenSSL::SSL::OP_SINGLE_DH_USE;F;data) 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 = PEM_read_bio_SSL_SESSION(in, NULL, NULL, NULL); if (!ctx) { OSSL_BIO_reset(in); ctx = d2i_SSL_SESSION_bio(in, NULL); } BIO_free(in); if (!ctx) ossl_raise(rb_eArgError, "unknown type"); } /* should not happen */ if (ctx == NULL) ossl_raise(eSSLSession, "ctx not set - internal error"); RDATA(self)->data = ctx; return self; };T;#I"Estatic VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1);T;$To; ; F; ;,;;;I"*OpenSSL::SSL::Session#initialize_copy;F;[[I" other;T0;[[@rKiQ;T;;];0;[;{;IC;" ;T;[;[;@;0; @~x;!@=x;"I"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; ; F; ;,;;;I"OpenSSL::SSL::Session#==;F;[[I" val2;T0;[[@rKi{;T;;S;0;[;{;IC;"CReturns +true+ if the two Session is the same, +false+ if not. ;T;[o;H ;II" overload;F;J0;;S;K0;#I"==(session2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @x;[;I"@return [Boolean];T;0; @x;@F;Mi;N0;[[I" session2;T0; @x;[;I"pReturns +true+ if the two Session is the same, +false+ if not. @overload ==(session2) @return [Boolean];T;0; @x;@F;Ao;B;CT;Diu;Eiy;!@=x;"I"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; ; F; ;,;;;I"OpenSSL::SSL::Session#time;F;[;[[@rKi;T;;;0;[;{;IC;";Returns the time at which the session was established. ;T;[o;H ;II" overload;F;J0;;;K0;#I" time;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @x;[;I"@return [Time];T;0; @x;@F;Mi;N0;[; @x;[;I"]Returns the time at which the session was established. @overload time @return [Time];T;0; @x;@F;Ao;B;CT;Di;Ei;!@=x;"I"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; ; F; ;,;;;I" OpenSSL::SSL::Session#time=;F;[[I" time_v;T0;[[@rKi;T;;;0;[;{;IC;"CSets start time of the session. Time resolution is in seconds. ;T;[o;H ;II" overload;F;J0;;;K0;#I"time=(time);T;IC;";T;[;[;I";T;0; @x;@F;Mi;N0;[[I" time;T0; @xo;H ;II" overload;F;J0;;;K0;#I"time=(integer);T;IC;";T;[;[;I";T;0; @x;@F;Mi;N0;[[I" integer;T0; @x;[;I"uSets start time of the session. Time resolution is in seconds. @overload time=(time) @overload time=(integer);T;0; @x;@F;Ao;B;CT;Di;Ei;!@=x;"I"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; ; F; ;,;;;I""OpenSSL::SSL::Session#timeout;F;[;[[@rKi;T;;;0;[;{;IC;"YReturns the timeout value set for the session, in seconds from the established time. ;T;[o;H ;II" overload;F;J0;;;K0;#I" timeout;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @x;[;I"@return [Integer];T;0; @x;@F;Mi;N0;[; @x;[;I"}Returns the timeout value set for the session, in seconds from the established time. @overload timeout @return [Integer];T;0; @x;@F;Ao;B;CT;Di;Ei;!@=x;"I"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; ; F; ;,;;;I"#OpenSSL::SSL::Session#timeout=;F;[[I" time_v;T0;[[@rKi;T;;;0;[;{;IC;"8Sets how long until the session expires in seconds. ;T;[o;H ;II" overload;F;J0;;;K0;#I"timeout=(integer);T;IC;";T;[;[;I";T;0; @y;@F;Mi;N0;[[I" integer;T0; @y;[;I"VSets how long until the session expires in seconds. @overload timeout=(integer);T;0; @y;@F;Ao;B;CT;Di;Ei;!@=x;"I"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; ; F; ;,;;;I"OpenSSL::SSL::Session#id;F;[;[[@rKi;T;:id;0;[;{;IC;"Returns the Session ID. ;T;[o;H ;II" overload;F;J0;;M;K0;#I"id;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @y;[;I"@return [String];T;0; @y;@F;Mi;N0;[; @y;[;I">Returns the Session ID. @overload id @return [String];T;0; @y;@F;Ao;B;CT;Di;Ei;!@=x;"I"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; ; F; ;,;;;I"!OpenSSL::SSL::Session#to_der;F;[;[[@rKi;T;; ;0;[;{;IC;"EReturns an ASN1 encoded String that contains the Session object. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @:y;[;I"@return [String];T;0; @:y;@F;Mi;N0;[; @:y;[;I"kReturns an ASN1 encoded String that contains the Session object. @overload to_der @return [String];T;0; @:y;@F;Ao;B;CT;Di;Ei;!@=x;"I"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; ; F; ;,;;;I"!OpenSSL::SSL::Session#to_pem;F;[;[[@rKi;T;;;0;[;{;IC;"CReturns a PEM encoded String that contains the Session object. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_pem;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Uy;[;I"@return [String];T;0; @Uy;@F;Mi;N0;[; @Uy;[;I"iReturns a PEM encoded String that contains the Session object. @overload to_pem @return [String];T;0; @Uy;@F;Ao;B;CT;Di;Ei;!@=x;"I"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; ; F; ;,;;;I""OpenSSL::SSL::Session#to_text;F;[;[[@rKi ;T;;;0;[;{;IC;"MShows everything in the Session object. This is for diagnostic purposes. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_text;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @py;[;I"@return [String];T;0; @py;@F;Mi;N0;[; @py;[;I"tShows everything in the Session object. This is for diagnostic purposes. @overload to_text @return [String];T;0; @py;@F;Ao;B;CT;Di;Ei;!@=x;"I"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;&@=x;'IC;[;&@=x;(IC;[;&@=x;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@rKi;;F;: Session;;0;;;[;{;IC;" ;T;[;[;@;0; @=x;Mi;!@Zp;I"OpenSSL::SSL::Session;F;1@<;&@Zp;'IC;[;&@Zp;(IC;[;&@Zp;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Yig [@Yin [@rKi8;T;:SSL;;0;;;[;{;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; @Zp;@F;Ao;B;CT;Dig ;Eil ;Mi;!@DK;I"OpenSSL::SSL;Fo; ;IC;[o;9;[[@Yi* ;F;:HAVE_TLSEXT_HOST_NAME;;;;;;[;{;IC;" ;T;[;[;@;0; @y;!@y;I".OpenSSL::ExtConfig::HAVE_TLSEXT_HOST_NAME;F;;Ei?;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#mod_mul;F;[;[;F;: mod_mul;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;[;K0;#I"mod_mul(bn1, bn2);T;IC;";T;[;[;I";T;0; @:{;@F;Mi;N0;[[I"bn1;T0[I"bn2;T0; @:{;[;I"! @overload mod_mul(bn1, bn2);T;0; @:{;@F;Ao;B;CT;DiE;EiF;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#mod_sqr;F;[;[;F;: mod_sqr;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;\;K0;#I"mod_sqr(bn2);T;IC;";T;[;[;I";T;0; @Q{;@F;Mi;N0;[[I"bn2;T0; @Q{;[;I" @overload mod_sqr(bn2);T;0; @Q{;@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#**;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" **(bn2);T;IC;";T;[;[;I";T;0; @f{;@F;Mi;N0;[[I"bn2;T0; @f{;[;I" @overload **(bn2);T;0; @f{;@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#mod_exp;F;[;[;F;: mod_exp;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;];K0;#I"mod_exp(bn1, bn2);T;IC;";T;[;[;I";T;0; @{{;@F;Mi;N0;[[I"bn1;T0[I"bn2;T0; @{{;[;I"! @overload mod_exp(bn1, bn2);T;0; @{{;@F;Ao;B;CT;DiL;EiM;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#gcd;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" gcd(bn2);T;IC;";T;[;[;I";T;0; @{;@F;Mi;N0;[[I"bn2;T0; @{;[;I" @overload gcd(bn2);T;0; @{;@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#cmp;F;[;[;F;;t;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;t;K0;#I" cmp(bn2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @{;[;I"@return [Integer];T;0; @{;@F;Mi;N0;[[I"bn2;T0; @{;[;I", @overload cmp(bn2) @return [Integer];T;0; o; ; F; ;,;;;I"OpenSSL::BN#<=>;F;[;[[@jKir;F;;V;;0;[;{;@{;!@y;"I";F;#0;@F;Ao;B;CT;Di;Ei;!@y;$T@{o; ; F; ;,;;;I"OpenSSL::BN#ucmp;F;[;[;F;: ucmp;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;^;K0;#I"ucmp(bn2);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @{;[;I"@return [Integer];T;0; @{;@F;Mi;N0;[[I"bn2;T0; @{;[;I"- @overload ucmp(bn2) @return [Integer];T;0; @{;@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#eql?;F;[[I" other;T0;[[@jKi;T;;R;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;H ;II" overload;F;J0;;R;K0;#I"eql?(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @{;[;I"@return [Boolean];T;0; @{;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@y;"I"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; ; F; ;,;;;I"OpenSSL::BN#hash;F;[;[[@jKi;T;;U;0;[;{;IC;"@Returns a hash code for this object. See also Object#hash. ;T;[o;H ;II" overload;F;J0;;U;K0;#I" hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|;[;I"@return [Integer];T;0; @|;@F;Mi;N0;[; @|;[;I"eReturns a hash code for this object. See also Object#hash. @overload hash @return [Integer];T;0; @|;@F;Ao;B;CT;Di;Ei;!@y;"I"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; ; F; ;,;;;I"OpenSSL::BN#==;F;[;[;F;;S;;0;[;{;IC;" ;T;[;[;@;0; o; ; F; ;,;;;I"OpenSSL::BN#===;F;[;[[@jKiw;F;;O;;0;[;{;@#|;!@y;"I";F;#0;!@y;$T@&|o; ; F; ;,;;;I"OpenSSL::BN#zero?;F;[;[;F;;;;0;[;{;IC;";T;[o;H ;II" overload;F;J0;;;K0;#I" zero?;T;IC;";T;[;[;I";T;0; @.|;@F;Mi;N0;[; @.|o;L ;II" return;F;J@;0;K[@; @.|;[;I" @overload zero?;T;0; @.|;@F;Ao;B;CT;Did;Eie;Mi;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#one?;F;[;[;F;;;;0;[;{;IC;";T;[o;H ;II" overload;F;J0;;;K0;#I" one?;T;IC;";T;[;[;I";T;0; @D|;@F;Mi;N0;[; @D|o;L ;II" return;F;J@;0;K[@; @D|;[;I" @overload one?;T;0; @D|;@F;Ao;B;CT;Dik;Eil;Mi;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#odd?;F;[;[;F;;;;0;[;{;IC;";T;[o;H ;II" overload;F;J0;;;K0;#I" odd?;T;IC;";T;[;[;I";T;0; @Z|;@F;Mi;N0;[; @Z|o;L ;II" return;F;J@;0;K[@; @Z|;[;I" @overload odd?;T;0; @Z|;@F;Ao;B;CT;Dir;Eis;Mi;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#negative?;F;[;[;F;;;;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @p|;[;@;0; @p|;Mi;!@y;$To; ; F; ;;;;I"OpenSSL::BN.rand;F;[;[;F;;;;0;[;{;IC;"*BN.rand(bits [, fill [, odd]]) -> aBN ;T;[;[;I"- BN.rand(bits [, fill [, odd]]) -> aBN ;T;0; @||;@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;;;;I"OpenSSL::BN.pseudo_rand;F;[;[;F;:pseudo_rand;;0;[;{;IC;"1BN.pseudo_rand(bits [, fill [, odd]]) -> aBN ;T;[;[;I"4 BN.pseudo_rand(bits [, fill [, odd]]) -> aBN ;T;0; @|;@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;;;;I"OpenSSL::BN.rand_range;F;[;[;F;:rand_range;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;`;K0;#I"rand_range(range);T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[[I" range;T0; @|;[;I"" @overload rand_range(range);T;0; @|;@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;;;;I""OpenSSL::BN.pseudo_rand_range;F;[;[;F;:pseudo_rand_range;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;a;K0;#I"pseudo_rand_range(range);T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[[I" range;T0; @|;[;I") @overload pseudo_rand_range(range);T;0; @|;@F;Ao;B;CT;Di;Ei ;!@y;$To; ; F; ;;;;I"OpenSSL::BN.generate_prime;F;[;[;F;:generate_prime;;0;[;{;IC;" ;T;[;[;@;0; @|;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#prime?;F;[[@0;[[@jKi;T;: prime?;0;[;{;IC;"Performs a Miller-Rabin probabilistic primality test with _checks_ iterations. If _checks_ is not specified, a number of iterations is used that yields a false positive rate of at most 2^-80 for random input. === Parameters * _checks_ - integer;T;[o;H ;II" overload;F;J0;;c;K0;#I" prime?;T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[; @|o;H ;II" overload;F;J0;;c;K0;#I"prime?(checks);T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[[I" checks;T0; @|o;L ;II" return;F;J@;0;K[@; @|;[;I"!Performs a Miller-Rabin probabilistic primality test with _checks_ iterations. If _checks_ is not specified, a number of iterations is used that yields a false positive rate of at most 2^-80 for random input. === Parameters * _checks_ - integer @overload prime? @overload prime?(checks);T;0; @|;@F;Ao;B;CT;Di;Ei;Mi;!@y;"I"static VALUE ossl_bn_is_prime(int argc, VALUE *argv, VALUE self) { BIGNUM *bn; VALUE vchecks; int checks = BN_prime_checks; if (rb_scan_args(argc, argv, "01", &vchecks) == 1) { checks = NUM2INT(vchecks); } GetBN(self, bn); switch (BN_is_prime_ex(bn, checks, ossl_bn_ctx, NULL)) { case 1: return Qtrue; case 0: return Qfalse; default: ossl_raise(eBNError, NULL); } /* not reachable */ return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" OpenSSL::BN#prime_fasttest?;F;[[@0;[[@jKi;T;:prime_fasttest?;0;[;{;IC;"Performs a Miller-Rabin primality test. This is same as #prime? except this first attempts trial divisions with some small primes. === Parameters * _checks_ - integer * _trial_div_ - boolean;T;[ o;H ;II" overload;F;J0;;d;K0;#I"prime_fasttest?;T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[; @|o;H ;II" overload;F;J0;;d;K0;#I"prime_fasttest?(checks);T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[[I" checks;T0; @|o;H ;II" overload;F;J0;;d;K0;#I"'prime_fasttest?(checks, trial_div);T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[[I" checks;T0[I"trial_div;T0; @|o;L ;II" return;F;J@;0;K[@; @|;[;I"*Performs a Miller-Rabin primality test. This is same as #prime? except this first attempts trial divisions with some small primes. === Parameters * _checks_ - integer * _trial_div_ - boolean @overload prime_fasttest? @overload prime_fasttest?(checks) @overload prime_fasttest?(checks, trial_div);T;0; @|;@F;Ao;B;CT;Di;Ei;Mi;!@y;"I"static VALUE ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self) { BIGNUM *bn; VALUE vchecks, vtrivdiv; int checks = BN_prime_checks, do_trial_division = 1; rb_scan_args(argc, argv, "02", &vchecks, &vtrivdiv); if (!NIL_P(vchecks)) { checks = NUM2INT(vchecks); } GetBN(self, bn); /* handle true/false */ if (vtrivdiv == Qfalse) { do_trial_division = 0; } switch (BN_is_prime_fasttest_ex(bn, checks, ossl_bn_ctx, do_trial_division, NULL)) { case 1: return Qtrue; case 0: return Qfalse; default: ossl_raise(eBNError, NULL); } /* not reachable */ return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::BN#set_bit!;F;[;[;F;: set_bit!;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;e;K0;#I"set_bit!(bit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @};[;I"@return [self];T;0; @};@F;Mi;N0;[[I"bit;T0; @};[;I". @overload set_bit!(bit) @return [self];T;0; @};@F;Ao;B;CT;Di_;Eia;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#clear_bit!;F;[;[;F;:clear_bit!;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;f;K0;#I"clear_bit!(bit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @3};[;I"@return [self];T;0; @3};@F;Mi;N0;[[I"bit;T0; @3};[;I"0 @overload clear_bit!(bit) @return [self];T;0; @3};@F;Ao;B;CT;Dif;Eih;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#bit_set?;F;[;[;F;: bit_set?;;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @M};[;@;0; @M};Mi;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#mask_bits!;F;[;[;F;:mask_bits!;;0;[;{;IC;" ;T;[;[;@;0; @Y};!@y;$To; ; F; ;,;;;I"OpenSSL::BN#<<;F;[;[;F;;Q;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;Q;K0;#I" <<(bits);T;IC;";T;[;[;I";T;0; @b};@F;Mi;N0;[[I" bits;T0; @b};[;I" @overload <<(bits);T;0; @b};@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#>>;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" >>(bits);T;IC;";T;[;[;I";T;0; @w};@F;Mi;N0;[[I" bits;T0; @w};[;I" @overload >>(bits);T;0; @w};@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#lshift!;F;[;[;F;: lshift!;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;i;K0;#I"lshift!(bits);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @};[;I"@return [self];T;0; @};@F;Mi;N0;[[I" bits;T0; @};[;I". @overload lshift!(bits) @return [self];T;0; @};@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#rshift!;F;[;[;F;: rshift!;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;j;K0;#I"rshift!(bits);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @};[;I"@return [self];T;0; @};@F;Mi;N0;[[I" bits;T0; @};[;I". @overload rshift!(bits) @return [self];T;0; @};@F;Ao;B;CT;Di;Ei;!@y;$To; ; F; ;,;;;I"OpenSSL::BN#to_s;F;[[@0;[[@jKi;T;;h;0;[;{;IC;"s=== Parameters * _base_ - Integer Valid values: * 0 - MPI * 2 - binary * 10 - the default * 16 - hex ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @};[;I"@return [String];T;0; @};@F;Mi;N0;[; @}o;H ;II" overload;F;J0;;h;K0;#I"to_s(base);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @};[;I"@return [String];T;0; @};@F;Mi;N0;[[I" base;T0; @};[;I"=== Parameters * _base_ - Integer Valid values: * 0 - MPI * 2 - binary * 10 - the default * 16 - hex @overload to_s @return [String] @overload to_s(base) @return [String];T;0; @};@F;Ao;B;CT;Di;Ei;!@y;"I"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; ; F; ;,;;;I"OpenSSL::BN#to_i;F;[;[[@jKi-;T;;=;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @};[;I"@return [Integer];T;0; @};@F;Mi;N0;[; @};[;I"( @overload to_i @return [Integer];T;0; o; ; F; ;,;;;I"OpenSSL::BN#to_int;F;[;[[@jKi;F;;;;0;[;{;@};!@y;"I"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;Ao;B;CT;Di);Ei+;!@y;"I"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; ; F; ;,;;;I"OpenSSL::BN#to_bn;F;[;[[@jKi?;T;: to_bn;0;[;{;IC;" ;T;[;[;@;0; @~;!@y;"I"@static VALUE ossl_bn_to_bn(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"OpenSSL::BN#coerce;F;[[I" other;T0;[[@jKiE;T;;;0;[;{;IC;" ;T;[;[;@;0; @~;!@y;"I"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; ; F; ;,;;;I"OpenSSL::BN#mod_inverse;F;[;[;F;:mod_inverse;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;l;K0;#I"mod_inverse(bn2);T;IC;";T;[;[;I";T;0; @(~;@F;Mi;N0;[[I"bn2;T0; @(~;[;I" @overload mod_inverse(bn2);T;0; @(~;@F;Ao;B;CT;Di;Ei;!@y;$T;&@y;'IC;[;&@y;(IC;[;&@y;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@{;t@&|;S@~;=;.[;[[@jKiJ;F;:BN;;0;;;[;{;IC;" ;T;[;[;@;0; @y;Mi;!@DK;I"OpenSSL::BN;F;1@ # See OpenSSL::Engine.engines for the currently loaded engines. ;T;[o;H ;II" overload;F;J0;:OpenSSL::Engine.by_id;K0;#I" OpenSSL::Engine.by_id(name);T;IC;";T;[;[;I";T;0; @~;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@L~;"I" 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; ; F; ;,;;;I"OpenSSL::Engine#id;F;[;[[@lKi;T;;M;0;[;{;IC;"Gets the id for this engine. OpenSSL::Engine.load OpenSSL::Engine.engines #=> [#, ...] OpenSSL::Engine.engines.first.id #=> "rsax" ;T;[o;H ;II" overload;F;J0;;M;K0;#I"id;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @~;[;I"@return [String];T;0; @~;@F;Mi;N0;[; @~;[;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; @~;@F;Ao;B;CT;Di;Ei;!@L~;"I"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; ; F; ;,;;;I"OpenSSL::Engine#name;F;[;[[@lKi;T;;>;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;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @~;[;I"@return [String];T;0; @~;@F;Mi;N0;[; @~;[;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; @~;@F;Ao;B;CT;Di;Ei ;!@L~;"I"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; ; F; ;,;;;I"OpenSSL::Engine#finish;F;[;[[@lKi;T;;;0;[;{;IC;"xReleases all internal structural references for this engine. May raise an EngineError if the engine is unavailable ;T;[o;H ;II" overload;F;J0;;;K0;#I" finish;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@L~;"I"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; ; F; ;,;;;I"OpenSSL::Engine#cipher;F;[[I" name;T0;[[@lKi9;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;H ;II" overload;F;J0;;;K0;#I"cipher(name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"OpenSSL::Cipher;T; @;[;I"@return [OpenSSL::Cipher];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di*;Ei7;!@L~;"I"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; ; F; ;,;;;I"OpenSSL::Engine#digest;F;[[I" name;T0;[[@lKiY;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;H ;II" overload;F;J0;;;K0;#I"digest(name);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"OpenSSL::Digest;T; @:;[;I"@return [OpenSSL::Digest];T;0; @:;@F;Mi;N0;[[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;Ao;B;CT;DiJ;EiW;!@L~;"I"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; ; F; ;,;;;I"%OpenSSL::Engine#load_private_key;F;[[@0;[[@lKis;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;H ;II" overload;F;J0;;w;K0;#I"+load_private_key(id = nil, data = nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"OpenSSL::PKey;T; @Y;[;I"@return [OpenSSL::PKey];T;0; @Y;@F;Mi;N0;[[I"id;TI"nil;T[I" data;TI"nil;T; @Y;[;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; @Y;@F;Ao;B;CT;Dij;Eiq;!@L~;"I" 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; ; F; ;,;;;I"$OpenSSL::Engine#load_public_key;F;[[@0;[[@lKi;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;H ;II" overload;F;J0;;x;K0;#I"*load_public_key(id = nil, data = nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"OpenSSL::PKey;T; @{;[;I"@return [OpenSSL::PKey];T;0; @{;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@L~;"I"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; ; F; ;,;;;I" OpenSSL::Engine#set_default;F;[[I" flag;T0;[[@lKi;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;H ;II" overload;F;J0;;y;K0;#I"set_default(flag);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@L~;"I"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; ; F; ;,;;;I"OpenSSL::Engine#ctrl_cmd;F;[[@0;[[@lKi;T;: ctrl_cmd;0;[;{;IC;"[Sends the given _command_ to this engine. Raises an EngineError if the command fails. ;T;[o;H ;II" overload;F;J0;;z;K0;#I"#ctrl_cmd(command, value = nil);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" command;T0[I" value;TI"nil;T; @;[;I"Sends the given _command_ to this engine. Raises an EngineError if the command fails. @overload ctrl_cmd(command, value = nil);T;0; @;@F;Ao;B;CT;Di;Ei;!@L~;"I"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; ; F; ;,;;;I"OpenSSL::Engine#cmds;F;[;[[@lKi;T;: cmds;0;[;{;IC;"CReturns an array of command definitions for the current engine ;T;[o;H ;II" overload;F;J0;;{;K0;#I" cmds;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"fReturns an array of command definitions for the current engine @overload cmds @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@L~;"I"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; ; F; ;,;;;I"OpenSSL::Engine#inspect;F;[;[[@lKi;T;;i;0;[;{;IC;"Pretty prints this engine. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"FPretty prints this engine. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@L~;"I"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;&@L~;'IC;[;&@L~;(IC;[;&@L~;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@lKi%[@lKi;T;;o;;0;;;[;{;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; @L~;@F;Ao;B;CT;Di%;Ei*;Mi;!@c~;I"OpenSSL::Engine;F;1@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;H ;II" overload;F;J0;:OpenSSL::ASN1.decode_all;K0;#I""OpenSSL::ASN1.decode_all(der);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Array of ASN1Data;T; @;[;I" @return [Array of ASN1Data];T;0; @;@F;Mi;N0;[[I"der;T0; @;[;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;N0;!@;"I"{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; ; T; ;;;;I"OpenSSL::ASN1.decode_all;F;@;@;T;;;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;H ;II" overload;F;J0;;;K0;#I""OpenSSL::ASN1.decode_all(der);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Array of ASN1Data;T; @;[;I" @return [Array of ASN1Data];T;0; @;@F;Mi;N0;[[I"der;T0; @;[;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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To;9;[[@vKi;F;:UNIVERSAL_TAG_NAME;;;;;;[;{;IC;"0Array storing tag names at the tag's index. ;T;[;[;I"1Array storing tag names at the tag's index. ;T;0; @Ѐ;@F;Ao;B;CT;Di;Ei;!@;I"&OpenSSL::ASN1::UNIVERSAL_TAG_NAME;F; Same as OpenSSL::ASN1::Integer.new(42) tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER ;T;[o;H ;II" overload;F;J0;: OpenSSL::ASN1::ASN1Data.new;K0;#I"7OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" ASN1Data;T; @;[;I"@return [ASN1Data];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dit;Ei;!@܀;"I"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; ; F; ;,;;;I"#OpenSSL::ASN1::ASN1Data#to_der;F;[;[[@vKi;T;; ;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;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"DER-encoded String;T; @;[;I"!@return [DER-encoded String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@܀;"I"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=;.[;[[@vKi[@vKiS;T;: ASN1Data;;0;;;[;{;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;Ao;B;CT;Di;EiQ;!@;I"OpenSSL::ASN1::ASN1Data;F;1@ 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; ; F; ;,;;;I"$OpenSSL::ASN1::Primitive#to_der;F;[;[[@vKig;T;; ;0;[;{;IC;"%See ASN1Data#to_der for details. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"DER-encoded String;T; @h;[;I"!@return [DER-encoded String];T;0; @h;@F;Mi;N0;[; @h;[;I"WSee ASN1Data#to_der for details. @overload to_der @return [DER-encoded String];T;0; @h;@F;Ao;B;CT;Dia;Eie;!@H;"I"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;&@H;'IC;[;&@H;(IC;[;&@H;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@vKiz[@vKi;T;:Primitive;;0;;;[;{;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; @H;@F;Ao;B;CT;Diz;Ei;!@;I"OpenSSL::ASN1::Primitive;F;1@܀o; ;IC;[o; ; F; ;,;;;I"+OpenSSL::ASN1::Constructive#initialize;F;[[@0;[[@vKi%;T;;;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;H ;II" overload;F;J0;;;K0;#I"EOpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Primitive;T; @;[;I"@return [Primitive];T;0; @;@F;Mi;N0;[[I"&value[, tag, tagging, tag_class ];T0; @;[;@d;0; @;@F;Ao;B;CT;Di;Ei#;!@;"I"=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; ; F; ;,;;;I"'OpenSSL::ASN1::Constructive#to_der;F;[;[[@vKi;T;; ;0;[;{;IC;"%See ASN1Data#to_der for details. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"DER-encoded String;T; @;[;I"!@return [DER-encoded String];T;0; @;@F;Mi;N0;[; @;[;I"WSee ASN1Data#to_der for details. @overload to_der @return [DER-encoded String];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"%OpenSSL::ASN1::Constructive#each;F;[;[[@vKi;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;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" asn1;T; @ρ;[;I"@yield [asn1];T;0; @ρ;@F;Mi;N0;[; @ρ;[;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; @ρ;@F;Ao;B;CT;Di;Ei;!@;"I"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;[@C;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@vKi[@vKi;T;:Constructive;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I" OpenSSL::ASN1::Constructive;F;1@܀o; ;IC;[ o; ; F; ;;;;I"%OpenSSL::ASN1::ObjectId.register;F;[[I"oid;T0[I"sn;T0[I"ln;T0;[[@vKi;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;H ;II" overload;F;J0;:%OpenSSL::ASN1::ObjectId.register;K0;#I"GOpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"OpenSSL::ASN1::ObjectId#sn;F;[;[[@vKi;T;:sn;0;[;{;IC;"GThe short name of the ObjectId, as defined in . ;T;[o;H ;II" overload;F;J0;;;K0;#I"sn;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;:short_name;K0;#I"short_name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;I"The short name of the ObjectId, as defined in . @overload sn @return [String] @overload short_name @return [String];T;0; o; ; F; ;,;;;I"'OpenSSL::ASN1::ObjectId#short_name;F;[;[[@vKi;F;;;;0;[;{;@';!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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;#@M;$To; ; F; ;,;;;I"OpenSSL::ASN1::ObjectId#ln;F;[;[[@vKi;T;:ln;0;[;{;IC;"FThe long name of the ObjectId, as defined in . ;T;[o;H ;II" overload;F;J0;;;K0;#I"ln;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @P;[;I"@return [String];T;0; @P;@F;Mi;N0;[; @Po;H ;II" overload;F;J0;:long_name;K0;#I"long_name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @P;[;I"@return [String];T;0; @P;@F;Mi;N0;[; @P;[;I"The long name of the ObjectId, as defined in . @overload ln @return [String] @overload long_name @return [String];T;0; o; ; F; ;,;;;I"&OpenSSL::ASN1::ObjectId#long_name;F;[;[[@vKi;F;;;;0;[;{;@W;!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" OpenSSL::ASN1::ObjectId#oid;F;[;[[@vKi%;T;;;0;[;{;IC;"^Returns a String representing the Object Identifier in the dot notation, e.g. "1.2.3.4.5" ;T;[o;H ;II" overload;F;J0;;;K0;#I"oid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei#;!@;"I"/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@E@u;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@E;@u;;.[;[[@vKi[@vKi;T;: ObjectId;;0;;;[;{;IC;"9Represents the primitive object id for OpenSSL::ASN1 ;T;[;[;I"; Represents the primitive object id for OpenSSL::ASN1 ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"OpenSSL::ASN1::ObjectId;F;1@H;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@vKij[@vKi;T;: ASN1;;0;;;[;{;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;Ao;B;CT;Dij;Ei;Mi;!@DK;I"OpenSSL::ASN1;Fo; ;IC;[+o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@zKi;F;:OCSPError;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I"OpenSSL::OCSP::OCSPError;F;1@FKo; ;IC;[o; ; F; ;,;;;I"+OpenSSL::OCSP::Request#initialize_copy;F;[[I" other;T0;[[@zKi;T;;];0;[;{;IC;" ;T;[;[;@;0; @Ԃ;!@҂;"I"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; ; F; ;,;;;I"&OpenSSL::OCSP::Request#initialize;F;[[@0;[[@zKi;T;;;0;[;{;IC;"lCreates a new OpenSSL::OCSP::Request. The request may be created empty or from a _request_der_ string. ;T;[o;H ;II" overload;F;J0;:OpenSSL::OCSP::Request.new;K0;#I"OpenSSL::OCSP::Request.new;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I",OpenSSL::OCSP::Request.new(request_der);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@҂;"I"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; ; F; ;,;;;I"%OpenSSL::OCSP::Request#add_nonce;F;[[@0;[[@zKi;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;H ;II" overload;F;J0;;;K0;#I"add_nonce(nonce = nil);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@҂;"I"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; ; F; ;,;;;I"'OpenSSL::OCSP::Request#check_nonce;F;[[I"basic_resp;T0;[[@zKi;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;H ;II" overload;F;J0;;;K0;#I"check_nonce(response);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@҂;"I"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; ; F; ;,;;;I"&OpenSSL::OCSP::Request#add_certid;F;[[I" certid;T0;[[@zKi,;T;:add_certid;0;[;{;IC;"*Adds _certificate_id_ to the request. ;T;[o;H ;II" overload;F;J0;;;K0;#I"add_certid(certificate_id);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I"certificate_id;T0; @7;[;I"QAdds _certificate_id_ to the request. @overload add_certid(certificate_id);T;0; @7;@F;Ao;B;CT;Di%;Ei(;!@҂;"I"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; ; F; ;,;;;I""OpenSSL::OCSP::Request#certid;F;[;[[@zKiF;T;: certid;0;[;{;IC;"1Returns all certificate IDs in this request. ;T;[o;H ;II" overload;F;J0;;;K0;#I" certid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @Q;[;I"@return [Array];T;0; @Q;@F;Mi;N0;[; @Q;[;I"VReturns all certificate IDs in this request. @overload certid @return [Array];T;0; @Q;@F;Ao;B;CT;Di?;EiC;!@҂;"I"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; ; F; ;,;;;I"#OpenSSL::OCSP::Request#signed?;F;[;[[@zKi;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;H ;II" overload;F;J0;;;K0;#I" signed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @l;[;I"@return [Boolean];T;0; @l;@F;Mi;N0;[; @l;[;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; @l;@F;Ao;B;CT;Di;Ei;Mi;!@҂;"I"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; ; F; ;,;;;I" OpenSSL::OCSP::Request#sign;F;[[@0;[[@zKin;T;;;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;H ;II" overload;F;J0;;;K0;#I":sign(cert, key, certs = nil, flags = 0, digest = nil);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[ [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;Ao;B;CT;Di^;Eil;!@҂;"I"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; ; F; ;,;;;I""OpenSSL::OCSP::Request#verify;F;[[@0;[[@zKi;T;;;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;H ;II" overload;F;J0;;;K0;#I"+verify(certificates, store, flags = 0);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@҂;"I"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; ; F; ;,;;;I""OpenSSL::OCSP::Request#to_der;F;[;[[@zKi;T;; ;0;[;{;IC;"1Returns this request as a DER-encoded string ;T;[;[;I"2Returns this request as a DER-encoded string ;T;0; @Ӄ;@F;Ao;B;CT;Di;Ei;!@҂;"I"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;-{;.[;[[@zKi%;F;;p;;0;;;[;{;IC;" ;T;[;[;@;0; @҂;Mi;!@;I"OpenSSL::OCSP::Request;F;1@;T;;5;0;[;{;IC;"(Returns the status of the response. ;T;[o;H ;II" overload;F;J0;;5;K0;#I" status;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @@;[;I"@return [Integer];T;0; @@;@F;Mi;N0;[; @@;[;I"OReturns the status of the response. @overload status @return [Integer];T;0; @@;@F;Ao;B;CT;Di7;Ei;;!@;"I"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; ; F; ;,;;;I"*OpenSSL::OCSP::Response#status_string;F;[;[[@zKiQ;T;:status_string;0;[;{;IC;".Returns a status string for the response. ;T;[o;H ;II" overload;F;J0;;;K0;#I"status_string;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @[;[;I"@return [String];T;0; @[;@F;Mi;N0;[; @[;[;I"[Returns a status string for the response. @overload status_string @return [String];T;0; @[;@F;Ao;B;CT;DiJ;EiN;!@;"I"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; ; F; ;,;;;I""OpenSSL::OCSP::Response#basic;F;[;[[@zKid;T;: basic;0;[;{;IC;".Returns a BasicResponse for this response ;T;[o;H ;II" overload;F;J0;;;K0;#I" basic;T;IC;";T;[;[;I";T;0; @v;@F;Mi;N0;[; @v;[;I"@Returns a BasicResponse for this response @overload basic;T;0; @v;@F;Ao;B;CT;Di];Ei`;!@;"I"#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; ; F; ;,;;;I"#OpenSSL::OCSP::Response#to_der;F;[;[[@zKi{;T;; ;0;[;{;IC;"3Returns this response as a DER-encoded string. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"YReturns this response as a DER-encoded string. @overload to_der @return [String];T;0; @;@F;Ao;B;CT;Dit;Eix;!@;"I"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;-{;.[;[[@zKi7;F;: Response;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"OpenSSL::OCSP::Response;F;1@certs)) { int i; bs = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_BASICRESP), bs); if (!bs) { sk_X509_pop_free(x509s, X509_free); ossl_raise(eOCSPError, "ASN1_item_dup"); } for (i = 0; i < sk_X509_num(x509s); i++) { if (!OCSP_basic_add1_cert(bs, sk_X509_value(x509s, i))) { sk_X509_pop_free(x509s, X509_free); OCSP_BASICRESP_free(bs); ossl_raise(eOCSPError, "OCSP_basic_add1_cert"); } } result = OCSP_basic_verify(bs, x509s, x509st, flg); OCSP_BASICRESP_free(bs); } else { result = OCSP_basic_verify(bs, x509s, x509st, flg); } #else result = OCSP_basic_verify(bs, x509s, x509st, flg); #endif sk_X509_pop_free(x509s, X509_free); if (result <= 0) ossl_clear_error(); return result > 0 ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"(OpenSSL::OCSP::BasicResponse#to_der;F;[;[[@zKin;T;; ;0;[;{;IC;";Encodes this basic response into a DER-encoded string. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"aEncodes this basic response into a DER-encoded string. @overload to_der @return [String];T;0; @;@F;Ao;B;CT;Dih;Eil;!@;"I"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;-{;.[;[[@zKiG;F;:BasicResponse;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"!OpenSSL::OCSP::BasicResponse;F;1@length * 2); ossl_bin2hex(name_hash->data, RSTRING_PTR(ret), name_hash->length); return ret; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"1OpenSSL::OCSP::CertificateId#issuer_key_hash;F;[;[[@zKi[;T;:issuer_key_hash;0;[;{;IC;"[Returns the issuerKeyHash of this certificate ID, the hash of the issuer's public key. ;T;[o;H ;II" overload;F;J0;;;K0;#I"issuer_key_hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiT;EiY;!@D;"I"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; ; F; ;,;;;I"0OpenSSL::OCSP::CertificateId#hash_algorithm;F;[;[[@zKir;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;H ;II" overload;F;J0;;;K0;#I"hash_algorithm;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Dik;Eip;!@D;"I"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; ; F; ;,;;;I"(OpenSSL::OCSP::CertificateId#to_der;F;[;[[@zKi;T;; ;0;[;{;IC;"CEncodes this certificate identifier into a DER-encoded string. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[; @&;[;I"iEncodes this certificate identifier into a DER-encoded string. @overload to_der @return [String];T;0; @&;@F;Ao;B;CT;Di;Ei;!@D;"I"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;&@D;'IC;[;&@D;(IC;[;&@D;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@zKim;F;:CertificateId;;0;;;[;{;IC;" ;T;[;[;@;0; @D;Mi;!@;I"!OpenSSL::OCSP::CertificateId;F;1@#ifdef OPENSSL_FIPS Qtrue #else Qfalse #endif;To; ; F; ;,;;;I"OpenSSL#fips_mode;F;[;[[@~Ki;T;:fips_mode;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"fips_mode;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"@overload fips_mode ;T;0; @;@F;N0;!@DK;"I"static VALUE ossl_fips_mode_get(VALUE self) { #ifdef OPENSSL_FIPS VALUE enabled; enabled = FIPS_mode() ? Qtrue : Qfalse; return enabled; #else return Qfalse; #endif };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL.fips_mode;F;@;@;T;;;0;@;{;IC;";T;[o;H ;II" overload;F;J0;;;K0;#I"fips_mode;T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[; @-;[;I" @overload fips_mode;T;0; @-;@F;Ao;B;CT;Di;Ei;Mi;!@DK;"@+;#@,;$To; ; F; ;,;;;I"OpenSSL#fips_mode=;F;[[I" enabled;T0;[[@~Ki;T;:fips_mode=;0;[;{;IC;"(Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an effect for FIPS-capable installations of the OpenSSL library. Trying to do so otherwise will result in an error. === Examples OpenSSL.fips_mode = true # turn FIPS mode on OpenSSL.fips_mode = false # and off again ;T;[o;H ;II" overload;F;J0;;;K0;#I"fips_mode=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @=;[;I"@return [Boolean];T;0; @=;@F;Mi;N0;[[I" boolean;T0; @=;[;I"[Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an effect for FIPS-capable installations of the OpenSSL library. Trying to do so otherwise will result in an error. === Examples OpenSSL.fips_mode = true # turn FIPS mode on OpenSSL.fips_mode = false # and off again @overload fips_mode=(boolean) @return [Boolean];T;0; @=;@F;N0;!@DK;"I",static VALUE ossl_fips_mode_set(VALUE self, VALUE enabled) { #ifdef OPENSSL_FIPS if (RTEST(enabled)) { int mode = FIPS_mode(); if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */ ossl_raise(eOSSLError, "Turning on FIPS mode failed"); } else { if(!FIPS_mode_set(0)) /* turning off twice is OK */ ossl_raise(eOSSLError, "Turning off FIPS mode failed"); } return enabled; #else if (RTEST(enabled)) ossl_raise(eOSSLError, "This version of OpenSSL does not support FIPS mode"); return enabled; #endif };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL.fips_mode=;F;@?;@B;T;;;0;@D;{;IC;"(Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an effect for FIPS-capable installations of the OpenSSL library. Trying to do so otherwise will result in an error. === Examples OpenSSL.fips_mode = true # turn FIPS mode on OpenSSL.fips_mode = false # and off again;T;[o;H ;II" overload;F;J0;;;K0;#I"fips_mode=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @[;[;I"@return [Boolean];T;0; @[;@F;Mi;N0;[[I" boolean;T0; @[;[;I"\Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an effect for FIPS-capable installations of the OpenSSL library. Trying to do so otherwise will result in an error. === Examples OpenSSL.fips_mode = true # turn FIPS mode on OpenSSL.fips_mode = false # and off again @overload fips_mode=(boolean) @return [Boolean];T;0; @[;@F;Ao;B;CT;Di;Ei;Mi;!@DK;"@Y;#@Z;$To; ; F; ;,;;;I"OpenSSL#debug;F;[;[[@~Ki{;T;: debug;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" debug;T;IC;";T;[;[;I";T;0; @r;@F;Mi;N0;[; @r;[;I"@overload debug ;T;0; @r;@F;N0;!@DK;"I"Bstatic VALUE ossl_debug_get(VALUE self) { return dOSSL; };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL.debug;F;@t;@u;T;;;0;@w;{;IC;";T;[o;H ;II" overload;F;J0;;;K0;#I" debug;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I" @overload debug;T;0; @;@F;Ao;B;CT;Diw;Eix;Mi;!@DK;"@;#@;$To; ; F; ;,;;;I"OpenSSL#debug=;F;[[I"val;T0;[[@~Ki;T;: debug=;0;[;{;IC;"wTurns on or off debug mode. With debug mode, all erros added to the OpenSSL error queue will be printed to stderr. ;T;[o;H ;II" overload;F;J0;;;K0;#I"debug=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" boolean;T0; @;[;I"Turns on or off debug mode. With debug mode, all erros added to the OpenSSL error queue will be printed to stderr. @overload debug=(boolean) @return [Boolean];T;0; @;@F;N0;!@DK;"I"ustatic VALUE ossl_debug_set(VALUE self, VALUE val) { dOSSL = RTEST(val) ? Qtrue : Qfalse; return val; };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL.debug=;F;@;@;T;;;0;@;{;IC;"wTurns on or off debug mode. With debug mode, all erros added to the OpenSSL error queue will be printed to stderr.;T;[o;H ;II" overload;F;J0;;;K0;#I"debug=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" boolean;T0; @;[;I"Turns on or off debug mode. With debug mode, all erros added to the OpenSSL error queue will be printed to stderr. @overload debug=(boolean) @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@DK;"@;#@;$To; ; F; ;,;;;I"OpenSSL#errors;F;[;[[@~KiT;T;: errors;0;[;{;IC;"|See any remaining errors held in queue. Any errors you see here are probably due to a bug in Ruby's OpenSSL implementation. ;T;[o;H ;II" overload;F;J0;;;K0;#I" errors;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @̊;[;I"@return [Array];T;0; @̊;@F;Mi;N0;[; @̊;[;I"See any remaining errors held in queue. Any errors you see here are probably due to a bug in Ruby's OpenSSL implementation. @overload errors @return [Array];T;0; @̊;@F;N0;!@DK;"I"VALUE ossl_get_errors(void) { VALUE ary; long e; ary = rb_ary_new(); while ((e = ERR_get_error()) != 0){ rb_ary_push(ary, rb_str_new2(ERR_error_string(e, NULL))); } return ary; };T;#I" VALUE;T;$To; ; T; ;;;;I"OpenSSL.errors;F;@Ί;@ϊ;T;;;0;@ъ;{;IC;"|See any remaining errors held in queue. Any errors you see here are probably due to a bug in Ruby's OpenSSL implementation.;T;[o;H ;II" overload;F;J0;;;K0;#I" errors;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"See any remaining errors held in queue. Any errors you see here are probably due to a bug in Ruby's OpenSSL implementation. @overload errors @return [Array];T;0; @;@F;Ao;B;CT;DiK;EiR;Mi;!@DK;"@;#@;$To; ; F; ;,;;;I"OpenSSL#mem_check_start;F;[;[[@~Ki;T;:mem_check_start;0;[;{;IC;"Calls CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON). Starts tracking memory allocations. See also OpenSSL.print_mem_leaks. This is available only when built with a capable OpenSSL and --enable-debug configure option. ;T;[o;H ;II" overload;F;J0;;;K0;#I"mem_check_start;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;I"Calls CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON). Starts tracking memory allocations. See also OpenSSL.print_mem_leaks. This is available only when built with a capable OpenSSL and --enable-debug configure option. @overload mem_check_start @return [nil];T;0; @;@F;N0;!@DK;"I"fstatic VALUE mem_check_start(VALUE self) { CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL.mem_check_start;F;@;@;T;;;0;@;{;IC;"Calls CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON). Starts tracking memory allocations. See also OpenSSL.print_mem_leaks. This is available only when built with a capable OpenSSL and --enable-debug configure option.;T;[o;H ;II" overload;F;J0;;;K0;#I"mem_check_start;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;I"Calls CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON). Starts tracking memory allocations. See also OpenSSL.print_mem_leaks. This is available only when built with a capable OpenSSL and --enable-debug configure option. @overload mem_check_start @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@DK;"@;#@;$To; ; F; ;,;;;I"OpenSSL#print_mem_leaks;F;[;[[@~Ki;T;:print_mem_leaks;0;[;{;IC;"For debugging the Ruby/OpenSSL library. Calls CRYPTO_mem_leaks_fp(stderr). Prints detected memory leaks to standard error. This cleans the global state up thus you cannot use any methods of the library after calling this. Returns +true+ if leaks detected, +false+ otherwise. This is available only when built with a capable OpenSSL and --enable-debug configure option. === Example OpenSSL.mem_check_start NOT_GCED = OpenSSL::PKey::RSA.new(256) END { GC.start OpenSSL.print_mem_leaks # will print the leakage } ;T;[o;H ;II" overload;F;J0;;;K0;#I"print_mem_leaks;T;IC;";T;[;[;I";T;0; @*;@F;Mi;N0;[; @*;[;I",For debugging the Ruby/OpenSSL library. Calls CRYPTO_mem_leaks_fp(stderr). Prints detected memory leaks to standard error. This cleans the global state up thus you cannot use any methods of the library after calling this. Returns +true+ if leaks detected, +false+ otherwise. This is available only when built with a capable OpenSSL and --enable-debug configure option. === Example OpenSSL.mem_check_start NOT_GCED = OpenSSL::PKey::RSA.new(256) END { GC.start OpenSSL.print_mem_leaks # will print the leakage } @overload print_mem_leaks ;T;0; @*;@F;N0;!@DK;"I"static VALUE print_mem_leaks(VALUE self) { #if OPENSSL_VERSION_NUMBER >= 0x10100000 int ret; #endif BN_CTX_free(ossl_bn_ctx); ossl_bn_ctx = NULL; #if OPENSSL_VERSION_NUMBER >= 0x10100000 ret = CRYPTO_mem_leaks_fp(stderr); if (ret < 0) ossl_raise(eOSSLError, "CRYPTO_mem_leaks_fp"); return ret ? Qfalse : Qtrue; #else CRYPTO_mem_leaks_fp(stderr); return Qnil; #endif };T;#I"static VALUE;T;$To; ; T; ;;;;I"OpenSSL.print_mem_leaks;F;@,;@-;T;;;0;@/;{;IC;"For debugging the Ruby/OpenSSL library. Calls CRYPTO_mem_leaks_fp(stderr). Prints detected memory leaks to standard error. This cleans the global state up thus you cannot use any methods of the library after calling this. Returns +true+ if leaks detected, +false+ otherwise. This is available only when built with a capable OpenSSL and --enable-debug configure option. === Example OpenSSL.mem_check_start NOT_GCED = OpenSSL::PKey::RSA.new(256) END { GC.start OpenSSL.print_mem_leaks # will print the leakage };T;[o;H ;II" overload;F;J0;;;K0;#I"print_mem_leaks;T;IC;";T;[;[;I";T;0; @?;@F;Mi;N0;[; @?;[;I"-For debugging the Ruby/OpenSSL library. Calls CRYPTO_mem_leaks_fp(stderr). Prints detected memory leaks to standard error. This cleans the global state up thus you cannot use any methods of the library after calling this. Returns +true+ if leaks detected, +false+ otherwise. This is available only when built with a capable OpenSSL and --enable-debug configure option. === Example OpenSSL.mem_check_start NOT_GCED = OpenSSL::PKey::RSA.new(256) END { GC.start OpenSSL.print_mem_leaks # will print the leakage } @overload print_mem_leaks;T;0; @?;@F;Ao;B;CT;Di;Ei;Mi;!@DK;"@=;#@>;$To; ;IC;[o; ;IC;[;&@Q;'IC;[;&@Q;(IC;[;&@Q;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Ki;T;:DigestError;;0;;;[;{;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; @Q;@F;Ao;B;CT;Di;Ei;!o;2 ;3@;4I"OpenSSL::Digest;T;50;: Digest;!o;2 ;30;40;50;;;!@;7@DK;F0;7@O;F0;I"!OpenSSL::Digest::DigestError;F;1o;2 ;30;40;50;;6;!@;7@<;F0;&@O;'IC;[;&@O;(IC;[;&@O;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@KiC;T;;;;0;;;[;{;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. Among the supported message digest algorithms are: * SHA, SHA1, SHA224, SHA256, SHA384 and SHA512 * MD2, MD4, MDC2 and MD5 * RIPEMD160 * DSS, DSS1 (Pseudo algorithms to be used for DSA signatures. DSS is equal to SHA and DSS1 is equal to SHA1) For each of these algorithms, there is a sub-class of Digest that can be instantiated as simply as e.g. digest = OpenSSL::Digest::SHA1.new === Mapping between Digest class and sn/ln The sn (short names) and ln (long names) are defined in and . They are textual representations of ASN.1 OBJECT IDENTIFIERs. Each supported digest algorithm has an OBJECT IDENTIFIER associated to it and those again have short/long names assigned to them. E.g. the OBJECT IDENTIFIER for SHA-1 is 1.3.14.3.2.26 and its sn is "SHA1" and its ln is "sha1". ==== MD2 * sn: MD2 * ln: md2 ==== MD4 * sn: MD4 * ln: md4 ==== MD5 * sn: MD5 * ln: md5 ==== SHA * sn: SHA * ln: SHA ==== SHA-1 * sn: SHA1 * ln: sha1 ==== SHA-224 * sn: SHA224 * ln: sha224 ==== SHA-256 * sn: SHA256 * ln: sha256 ==== SHA-384 * sn: SHA384 * ln: sha384 ==== SHA-512 * sn: SHA512 * ln: sha512 "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.read('document') sha256 = OpenSSL::Digest::SHA256.new digest = sha256.digest(data) === Hashing several pieces of data at once data1 = File.read('file1') data2 = File.read('file2') data3 = File.read('file3') sha256 = OpenSSL::Digest::SHA256.new sha256 << data1 sha256 << data2 sha256 << data3 digest = sha256.digest === Reuse a Digest instance data1 = File.read('file1') sha256 = OpenSSL::Digest::SHA256.new digest1 = sha256.digest(data1) data2 = File.read('file2') sha256.reset digest2 = sha256.digest(data2);T;[;[;I" 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. Among the supported message digest algorithms are: * SHA, SHA1, SHA224, SHA256, SHA384 and SHA512 * MD2, MD4, MDC2 and MD5 * RIPEMD160 * DSS, DSS1 (Pseudo algorithms to be used for DSA signatures. DSS is equal to SHA and DSS1 is equal to SHA1) For each of these algorithms, there is a sub-class of Digest that can be instantiated as simply as e.g. digest = OpenSSL::Digest::SHA1.new === Mapping between Digest class and sn/ln The sn (short names) and ln (long names) are defined in and . They are textual representations of ASN.1 OBJECT IDENTIFIERs. Each supported digest algorithm has an OBJECT IDENTIFIER associated to it and those again have short/long names assigned to them. E.g. the OBJECT IDENTIFIER for SHA-1 is 1.3.14.3.2.26 and its sn is "SHA1" and its ln is "sha1". ==== MD2 * sn: MD2 * ln: md2 ==== MD4 * sn: MD4 * ln: md4 ==== MD5 * sn: MD5 * ln: md5 ==== SHA * sn: SHA * ln: SHA ==== SHA-1 * sn: SHA1 * ln: sha1 ==== SHA-224 * sn: SHA224 * ln: sha224 ==== SHA-256 * sn: SHA256 * ln: sha256 ==== SHA-384 * sn: SHA384 * ln: sha384 ==== SHA-512 * sn: SHA512 * ln: sha512 "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.read('document') sha256 = OpenSSL::Digest::SHA256.new digest = sha256.digest(data) === Hashing several pieces of data at once data1 = File.read('file1') data2 = File.read('file2') data3 = File.read('file3') sha256 = OpenSSL::Digest::SHA256.new sha256 << data1 sha256 << data2 sha256 << data3 digest = sha256.digest === Reuse a Digest instance data1 = File.read('file1') sha256 = OpenSSL::Digest::SHA256.new digest1 = sha256.digest(data1) data2 = File.read('file2') sha256.reset digest2 = sha256.digest(data2) ;T;0; @O;@F;Ao;B;CT;DiC;Ei;Mi;!@e;I"OpenSSL::Digest;F;1o;2 ;30;40;50;;6;!@;7@<;F0o; ;IC;[o; ;IC;[;&@|;'IC;[;&@|;(IC;[;&@|;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Kit[@Ki;T;:SPKIError;;0;;;[;{;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;Ao;B;CT;Dit;Eiw;!o;2 ;3@;4I"OpenSSL::Netscape;T;50;: Netscape;!o;2 ;30;40;50;;;!@;7@DK;F0;7@z;F0;I"!OpenSSL::Netscape::SPKIError;F;1@FKo; ;IC;[o; ; F; ;,;;;I"'OpenSSL::Netscape::SPKI#initialize;T;[[@0;[[@KiS;T;;;0;[;{;IC;"T=== Parameters * _request_ - optional raw request, either in PEM or DER format. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new([request]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[request];T0; @;[;I"o=== Parameters * _request_ - optional raw request, either in PEM or DER format. @overload new([request]);T;0; @;@F;Ao;B;CT;DiL;EiP;!@;"I"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; ; F; ;,;;;I"#OpenSSL::Netscape::SPKI#to_der;T;[;[[@Kiq;T;; ;0;[;{;IC;"+Returns the DER encoding of this SPKI. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" to_der;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I">Returns the DER encoding of this SPKI. @overload to_der;T;0; @;@F;Ao;B;CT;Dik;Ein;!@;"I"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; ; F; ;,;;;I"#OpenSSL::Netscape::SPKI#to_pem;T;[;[[@Ki;T;;;0;[;{;IC;"+Returns the PEM encoding of this SPKI. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_pem;T;IC;";T;[;[;I";T;0; @ċ;@F;Mi;N0;[; @ċ;[;I">Returns the PEM encoding of this SPKI. @overload to_pem;T;0; o; ; F; ;,;;;I"!OpenSSL::Netscape::SPKI#to_s;T;[;[[@Ki;F;;h;;0;[;{;@ˋ;!@;"I""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;Ao;B;CT;Di;Ei;!@;"I""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; ; F; ;,;;;I"$OpenSSL::Netscape::SPKI#to_text;T;[;[[@Ki;T;;;0;[;{;IC;"RReturns a textual representation of this SPKI, useful for debugging purposes. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_text;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"yReturns a textual representation of this SPKI, useful for debugging purposes. @overload to_text @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"=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; ; F; ;,;;;I"'OpenSSL::Netscape::SPKI#public_key;T;[;[[@Ki;T;; ;0;[;{;IC;"SReturns the public key associated with the SPKI, an instance of OpenSSL::PKey. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"public_key;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"jReturns the public key associated with the SPKI, an instance of OpenSSL::PKey. @overload public_key;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I" 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; ; F; ;,;;;I"(OpenSSL::Netscape::SPKI#public_key=;T;[[I"key;T0;[[@Ki;T;;;;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;H ;II" overload;F;J0;;;;K0;#I"public_key=(pub);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"pub;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"=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; ; F; ;,;;;I"!OpenSSL::Netscape::SPKI#sign;T;[[I"key;T0[I" digest;T0;[[@Ki;T;;;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;H ;II" overload;F;J0;;;K0;#I"sign(key, digest);T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[[I"key;T0[I" digest;T0; @-;[;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; @-;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"#OpenSSL::Netscape::SPKI#verify;T;[[I"key;T0;[[@Ki3;T;;;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;H ;II" overload;F;J0;;;K0;#I"verify(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @K;[;I"@return [Boolean];T;0; @K;@F;Mi;N0;[[I"key;T0; @K;[;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; @K;@F;Ao;B;CT;Di);Ei1;!@;"I"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; ; F; ;,;;;I"&OpenSSL::Netscape::SPKI#challenge;T;[;[[@Ki;T;:challenge;0;[;{;IC;"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; ; F; ;,;;;I"'OpenSSL::Netscape::SPKI#challenge=;T;[[I"str;T0;[[@Ki;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;H ;II" overload;F;J0;;;K0;#I"challenge=(str);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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;-{@׋;;.[;[[@KiG[@Ki;T;: SPKI;;0;;;[;{;IC;"7A 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::SHA256.new) #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"9 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::SHA256.new) #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;Ao;B;CT;DiG;Eii;Mi;!o;2 ;3@;4I"OpenSSL::Netscape;T;50;;;!@;7@z;F0;I"OpenSSL::Netscape::SPKI;T;1@<;&@z;'IC;[;&@z;(IC;[;&@z;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Kil[@Ki;T;;;;0;;;[;{;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; @z;@F;Ao;B;CT;Dil;Eiq;Mi;!@;I"OpenSSL::Netscape;F;&@DK;'IC;[;&@DK;(IC;[;&@DK;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@QKi[@UKi[@WKi[@YKi[@[Ki[@]KiP[@_Ki8[@aKi[@cKi[@eKiR[@gKi[@YiO [@jKi@[@lKi[@nKi4[@pKi[@rKi7[@tKi[@vKiX[@hi&[@xKi[@zKi[@|Ki[@~Kif[@Ki?[@Ki~;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @DK;Mi;!@;I" OpenSSL;Fo; ;IC;[o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/win32/resolv/resolv.c;Ti=;F;: Resolv;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"Win32::Resolv;F;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i<;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I" Win32;Fo; ;IC;[4o; ; F; ;,;;;I"WIN32OLE#initialize;F;[[@0;[[@ti ;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(server, [host]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE object;T; @;[;I"@return [WIN32OLE object];T;0; @;@F;Mi;N0;[[I" server;T0[I" [host];T0; @o;H ;II" overload;F;J0;; ;K0;#I" new(server, license: 'key');T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE object;T; @;[;I"@return [WIN32OLE object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I" 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 (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) { rb_raise(rb_eSecurityError, "insecure object creation - `%s'", StringValuePtr(svr_name)); } if (!NIL_P(host)) { StringValue(host); if (rb_safe_level() > 0 && OBJ_TAINTED(host)) { rb_raise(rb_eSecurityError, "insecure object creation - `%s'", StringValuePtr(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; ; F; ;;;;I"WIN32OLE.connect;F;[[@0;[[@ti;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;H ;II" overload;F;J0;;;K0;#I"!connect( ole ) --> aWIN32OLE;T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[[I"ole;T0; @I;[;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; @I;@F;Ao;B;CT;Di;Ei;!@;"I"{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); if (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) { rb_raise(rb_eSecurityError, "insecure connection - `%s'", StringValuePtr(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; ; F; ;;;;I"WIN32OLE.const_load;F;[[@0;[[@ti;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;H ;II" overload;F;J0;;;K0;#I"%const_load( ole, mod = WIN32OLE);T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[[I"ole;T0[I"mod;TI" WIN32OLE;T; @b;[;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; @b;@F;Ao;B;CT;Di;Ei;!@;"I" 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; ; F; ;;;;I"WIN32OLE.ole_free;F;[[I"obj;T0;[[@tii;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;H ;II" overload;F;J0;;;K0;#I"#ole_free(aWIN32OLE) --> number;T;IC;";T;[;[;I";T;0; @~;@F;Mi;N0;[[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;Ao;B;CT;Di`;Eif;!@;"I"%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; ; F; ;;;;I"!WIN32OLE.ole_reference_count;F;[[I"obj;T0;[[@tiX;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;H ;II" overload;F;J0;;;K0;#I".ole_reference_count(aWIN32OLE) --> number;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiP;EiU;!@;"I"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; ; F; ;;;;I"WIN32OLE.ole_show_help;F;[[@0;[[@ti;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;H ;II" overload;F;J0;;;K0;#I"&ole_show_help(obj [,helpcontext]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I">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; ; F; ;;;;I"WIN32OLE.codepage;F;[;[[@ti;T;: codepage;0;[;{;IC;"IReturns current codepage. WIN32OLE.codepage # => WIN32OLE::CP_ACP ;T;[o;H ;II" overload;F;J0;;;K0;#I" codepage;T;IC;";T;[;[;I";T;0; @ˍ;@F;Mi;N0;[; @ˍ;[;I"^Returns current codepage. WIN32OLE.codepage # => WIN32OLE::CP_ACP @overload codepage;T;0; @ˍ;@F;Ao;B;CT;Di;Ei;!@;"I"[static VALUE fole_s_get_code_page(VALUE self) { return RB_INT2FIX(cWIN32OLE_cp); };T;#I"static VALUE;T;$To; ; F; ;;;;I"WIN32OLE.codepage=;F;[[I"vcp;T0;[[@ti;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;H ;II" overload;F;J0;;;K0;#I"codepage=(CP);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"WIN32OLE.locale;F;[;[[@ti;T;: locale;0;[;{;IC;"xReturns current locale id (lcid). The default locale is WIN32OLE::LOCALE_SYSTEM_DEFAULT. lcid = WIN32OLE.locale ;T;[o;H ;II" overload;F;J0;;;K0;#I" locale;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"Returns current locale id (lcid). The default locale is WIN32OLE::LOCALE_SYSTEM_DEFAULT. lcid = WIN32OLE.locale @overload locale;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Zstatic VALUE fole_s_get_locale(VALUE self) { return RB_INT2FIX(cWIN32OLE_lcid); };T;#I"static VALUE;T;$To; ; F; ;;;;I"WIN32OLE.locale=;F;[[I" vlcid;T0;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I"locale=(lcid);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;;;;I"WIN32OLE.create_guid;F;[;[[@ti4 ;T;:create_guid;0;[;{;IC;"VCreates GUID. WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8} ;T;[o;H ;II" overload;F;J0;;;K0;#I"create_guid;T;IC;";T;[;[;I";T;0; @+;@F;Mi;N0;[; @+;[;I"nCreates GUID. WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8} @overload create_guid;T;0; @+;@F;Ao;B;CT;Di- ;Ei1 ;!@;"I"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; ; F; ;;;;I"WIN32OLE.ole_initialize;F;[;[[@tiM ;T;:ole_initialize;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @A;@F;Ao;B;CT;DiL ;EiL ;!@;"I"^static VALUE fole_s_ole_initialize(VALUE self) { ole_initialize(); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"WIN32OLE.ole_uninitialize;F;[;[[@tiU ;T;:ole_uninitialize;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @O;@F;Ao;B;CT;DiT ;EiT ;!@;"I"bstatic VALUE fole_s_ole_uninitialize(VALUE self) { ole_uninitialize(); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE#invoke;F;[[@0;[[@ti# ;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;H ;II" overload;F;J0;;;K0;#I"invoke(method, [arg1,...]);T;IC;";T;[;[;I";T;0; @];@F;Mi;N0;[[I" method;T0[I"[arg1,...];T0; @];[;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; @];@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#[];F;[[@0;[[@tic ;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;H ;II" overload;F;J0;;;K0;#I"[](a1,a2,...);T;IC;";T;[;[;I";T;0; @x;@F;Mi;N0;[[I"a1;T0[I"a2;T0[I"...;T0; @x;[;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; @x;@F;Ao;B;CT;DiS ;Ei` ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#_invoke;F;[[I" dispid;T0[I" args;T0[I" types;T0;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I"!_invoke(dispid, args, types);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#_getproperty;F;[[I" dispid;T0[I" args;T0[I" types;T0;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I"&_getproperty(dispid, args, types);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#_setproperty;F;[[I" dispid;T0[I" args;T0[I" types;T0;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I"&_setproperty(dispid, args, types);T;IC;";T;[;[;I";T;0; @َ;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#[]=;F;[[@0;[[@ti2 ;T;;+;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;H ;II" overload;F;J0;;+;K0;#I"[]=(a1, a2, ...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei/ ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#ole_free;F;[;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I" ole_free;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#each;F;[;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"i;T; @.;[;I"@yield [i];T;0; @.;@F;Mi;N0;[; @.;[;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; @.;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#method_missing;F;[[@0;[[@ti ;T;;;0;[;{;IC;""Calls WIN32OLE#invoke method. ;T;[o;H ;II" overload;F;J0;;;K0;#I"*method_missing(id [,arg1, arg2, ...]);T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[[I"id[,arg1, arg2, ...];T0; @I;[;I"TCalls WIN32OLE#invoke method. @overload method_missing(id [,arg1, arg2, ...]);T;0; @I;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#setproperty;F;[[@0;[[@tiI ;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;H ;II" overload;F;J0;;;K0;#I"2setproperty('property', [arg1, arg2,...] val);T;IC;";T;[;[;I";T;0; @b;@F;Mi;N0;[["'property'0[I"[arg1, arg2,...];T0; @b;[;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; @b;@F;Ao;B;CT;Di< ;EiF ;!@;"I"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; ; F; ;,;;;I"WIN32OLE#ole_methods;F;[;[[@ti ;T;:ole_methods;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;H ;II" overload;F;J0;;;K0;#I"ole_methods;T;IC;";T;[;[;I";T;0; @};@F;Mi;N0;[; @};[;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;Ao;B;CT;Diz ;Ei ;!@;"I"static VALUE fole_methods(VALUE self) { return ole_methods( self, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE#ole_get_methods;F;[;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I"ole_get_methods;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei ;!@;"I"estatic VALUE fole_get_methods(VALUE self) { return ole_methods( self, INVOKE_PROPERTYGET); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE#ole_put_methods;F;[;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I"ole_put_methods;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei ;!@;"I"{static VALUE fole_put_methods(VALUE self) { return ole_methods( self, INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE#ole_func_methods;F;[;[[@ti ;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;H ;II" overload;F;J0;;;K0;#I"ole_func_methods;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei ;!@;"I"_static VALUE fole_func_methods(VALUE self) { return ole_methods( self, INVOKE_FUNC); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE#ole_method;F;[[I" cmdname;T0;[[@ti;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;H ;II" overload;F;J0;:ole_method_help;K0;#I"ole_method_help(method);T;IC;";T;[;[;I";T;0; @Տ;@F;Mi;N0;[[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; ; F; ;,;;;I"WIN32OLE#ole_method_help;F;[;[[@ti;F;;;;0;[;{;@ޏ;!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"$WIN32OLE#ole_activex_initialize;F;[;[[@ti3;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;H ;II" overload;F;J0;;;K0;#I"ole_activex_initialize();T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Qnil;T; @;[;I"@return [Qnil];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei1;!@;"I"~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; ; F; ;,;;;I"WIN32OLE#ole_type;F;[;[[@ti ;T;: ole_type;0;[;{;IC;"iReturns WIN32OLE_TYPE object. excel = WIN32OLE.new('Excel.Application') tobj = excel.ole_type ;T;[o;H ;II" overload;F;J0;;;K0;#I" ole_type;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"~Returns WIN32OLE_TYPE object. excel = WIN32OLE.new('Excel.Application') tobj = excel.ole_type @overload ole_type;T;0; o; ; F; ;,;;;I"WIN32OLE#ole_obj_help;F;[;[[@ti;F;:ole_obj_help;;0;[;{;@;!@;"I"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;Ao;B;CT;Di ;Ei ;!@;"I"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;#@-;$T@%o; ; F; ;,;;;I"WIN32OLE#ole_typelib;F;[;[[@ti ;T;:ole_typelib;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;H ;II" overload;F;J0;; ;K0;#I"ole_typelib;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" The WIN32OLE_TYPELIB object;T; @0;[;I"*@return [The WIN32OLE_TYPELIB object];T;0; @0;@F;Mi;N0;[; @0;[;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; @0;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"!WIN32OLE#ole_query_interface;F;[[I" str_iid;T0;[[@ti;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;H ;II" overload;F;J0;; ;K0;#I"ole_query_interface(iid);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE object;T; @K;[;I"@return [WIN32OLE object];T;0; @K;@F;Mi;N0;[[I"iid;T0; @K;[;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; @K;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE#ole_respond_to?;F;[[I" method;T0;[[@ti5;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;H ;II" overload;F;J0;; ;K0;#I"ole_respond_to?(method);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @j;[;I"@return [Boolean];T;0; @j;@F;Mi;N0;[[I" method;T0; @j;[;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; @j;@F;Ao;B;CT;Di,;Ei3;Mi;!@;"I"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;9;[[@ti;F;;^;;;;;;[;{;IC;" Version string of WIN32OLE. ;T;[;[;I"!Version string of WIN32OLE. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"WIN32OLE::VERSION;F; 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;Ao;B;CT;Di;Ei;!@;I"WIN32OLE::ARGV;F;;Ei?;!@ ;I"WIN32OLE::VARIANT::VT_BSTR;F; 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;Ao;B;CT;Di ;Ei;!@;I"WIN32OLE::VARIANT;F;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@;@%;;.[;[[@ti\ [@ti;T;: WIN32OLE;;0;;;[;{;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;Ao;B;CT;Di\ ;Ei ;Mi;!@;I" WIN32OLE;F;1@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;H ;II" overload;F;J0;; ;K0;#I"new(ole_type, method);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE_METHOD object;T; @n;[;I"%@return [WIN32OLE_METHOD object];T;0; @n;@F;Mi;N0;[[I" ole_type;T0[I" method;T0; @n;[;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; @n;@F;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#name;F;[;[[@wi(;T;;>;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;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; ; F; ;,;;;I"WIN32OLE_METHOD#to_s;F;[;[[@wi;F;;h;;0;[;{;@;!@l;"I"bstatic VALUE folemethod_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei%;!@l;"I"bstatic VALUE folemethod_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#@;$To; ; F; ;,;;;I" WIN32OLE_METHOD#return_type;F;[;[[@wiH;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;H ;II" overload;F;J0;;) ;K0;#I"return_type;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di>;EiE;!@l;"I"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; ; F; ;,;;;I"!WIN32OLE_METHOD#return_vtype;F;[;[[@wij;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;H ;II" overload;F;J0;;* ;K0;#I"return_vtype;T;IC;";T;[;[;I";T;0; @ƒ;@F;Mi;N0;[; @ƒ;[;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; @ƒ;@F;Ao;B;CT;Di`;Eig;!@l;"I"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; ; F; ;,;;;I"'WIN32OLE_METHOD#return_type_detail;F;[;[[@wi;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;H ;II" overload;F;J0;;+ ;K0;#I"return_type_detail;T;IC;";T;[;[;I";T;0; @ܒ;@F;Mi;N0;[; @ܒ;[;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; @ܒ;@F;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I" WIN32OLE_METHOD#invoke_kind;F;[;[[@wi;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;H ;II" overload;F;J0;;, ;K0;#I"invoke_kind;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#invkind;F;[;[[@wi;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;H ;II" overload;F;J0;;- ;K0;#I" invkind;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#visible?;F;[;[[@wi;T;: visible?;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;H ;II" overload;F;J0;;. ;K0;#I" visible?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Di;Ei;Mi;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#event?;F;[;[[@wiJ;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;H ;II" overload;F;J0;;/ ;K0;#I" event?;T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[; @7o;L ;II" return;F;J@;0;K[@; @7;[;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; @7;@F;Ao;B;CT;Di@;EiG;Mi;!@l;"I"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; ; F; ;,;;;I"$WIN32OLE_METHOD#event_interface;F;[;[[@wi_;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;H ;II" overload;F;J0;;0 ;K0;#I"event_interface;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @P;[;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; @P;@F;Ao;B;CT;DiV;Ei\;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#helpstring;F;[;[[@wi;T;:helpstring;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;H ;II" overload;F;J0;;1 ;K0;#I"helpstring;T;IC;";T;[;[;I";T;0; @f;@F;Mi;N0;[; @f;[;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;@F;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#helpfile;F;[;[[@wi;T;: helpfile;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;H ;II" overload;F;J0;;2 ;K0;#I" helpfile;T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[; @|;[;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;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I" WIN32OLE_METHOD#helpcontext;F;[;[[@wi;T;:helpcontext;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;H ;II" overload;F;J0;;3 ;K0;#I"helpcontext;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#dispid;F;[;[[@wi;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;H ;II" overload;F;J0;;4 ;K0;#I" dispid;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@l;"I"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; ; F; ;,;;;I" WIN32OLE_METHOD#offset_vtbl;F;[;[[@wi;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;H ;II" overload;F;J0;;5 ;K0;#I"offset_vtbl;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di ;Ei;!@l;"I"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; ; F; ;,;;;I" WIN32OLE_METHOD#size_params;F;[;[[@wi5;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;H ;II" overload;F;J0;;6 ;K0;#I"size_params;T;IC;";T;[;[;I";T;0; @ԓ;@F;Mi;N0;[; @ԓ;[;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; @ԓ;@F;Ao;B;CT;Di+;Ei2;!@l;"I"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; ; F; ;,;;;I"$WIN32OLE_METHOD#size_opt_params;F;[;[[@wiT;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;H ;II" overload;F;J0;;7 ;K0;#I"size_opt_params;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiK;EiQ;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#params;F;[;[[@wi;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;H ;II" overload;F;J0;;;K0;#I" params;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di};Ei;!@l;"I"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; ; F; ;,;;;I"WIN32OLE_METHOD#inspect;F;[;[[@wi;T;;i;0;[;{;IC;"-Returns the method name with class name. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"UReturns the method name with class name. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@l;"I"istatic VALUE folemethod_inspect(VALUE self) { return default_inspect(self, "WIN32OLE_METHOD"); };T;#I"static VALUE;T;$T;&@l;'IC;[;&@l;(IC;[;&@l;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@;>;.[;[[@wi[@wi;T;:WIN32OLE_METHOD;;0;;;[;{;IC;"KWIN32OLE_METHOD objects represent OLE method information.;T;[;[;I"O WIN32OLE_METHOD objects represent OLE method information. ;T;0; @l;@F;Ao;B;CT;Di;Ei;Mi;!@;I"WIN32OLE_METHOD;F;1@ WIN32OLE_EVENT object.;T;IC;";T;[;[;I";T;0; @\;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@C;"I"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; ; F; ;,;;;I"WIN32OLE_EVENT#on_event;F;[[@0;[[@Ji>;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;H ;II" overload;F;J0;;: ;K0;#I"on_event([event]);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @w;[;I"@yield [];T;0; @w;@F;Mi;N0;[[I" [event];T0; @w;[;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; @w;@F;Ao;B;CT;Di!;Ei<;!@C;"I"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; ; F; ;,;;;I")WIN32OLE_EVENT#on_event_with_outargs;F;[[@0;[[@JiR;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;H ;II" overload;F;J0;;; ;K0;#I"#on_event_with_outargs([event]);T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiD;EiP;!@C;"I"~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; ; F; ;,;;;I"WIN32OLE_EVENT#off_event;F;[[@0;[[@Jig;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;H ;II" overload;F;J0;;< ;K0;#I"off_event([event]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiX;Eid;!@C;"I"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; ; F; ;,;;;I"WIN32OLE_EVENT#unadvise;F;[;[[@Ji;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;H ;II" overload;F;J0;;= ;K0;#I" unadvise;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @Ȕ;[;I"@return [nil];T;0; @Ȕ;@F;Mi;N0;[; @Ȕ;[;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;Ao;B;CT;Di~;Ei;!@C;"I"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; ; F; ;,;;;I"WIN32OLE_EVENT#handler=;F;[[I"val;T0;[[@Ji;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;H ;II" overload;F;J0;;> ;K0;#I" handler=;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@C;"I"ustatic VALUE fev_set_handler(VALUE self, VALUE val) { return rb_ivar_set(self, rb_intern("handler"), val); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_EVENT#handler;F;[;[[@Ji;T;: handler;0;[;{;IC;"returns handler object. ;T;[o;H ;II" overload;F;J0;;? ;K0;#I" handler;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"1returns handler object. @overload handler;T;0; @;@F;Ao;B;CT;Di;Ei;!@C;"I"estatic VALUE fev_get_handler(VALUE self) { return rb_ivar_get(self, rb_intern("handler")); };T;#I"static VALUE;T;$T;&@C;'IC;[;&@C;(IC;[;&@C;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Ji[@Ji;T;:WIN32OLE_EVENT;;0;;;[;{;IC;"<WIN32OLE_EVENT objects controls OLE event.;T;[;[;I"@ WIN32OLE_EVENT objects controls OLE event. ;T;0; @C;@F;Ao;B;CT;Di;Ei ;Mi;!@;I"WIN32OLE_EVENT;F;1@;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;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[; @%;[;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; ; F; ;,;;;I"WIN32OLE_VARIABLE#to_s;F;[;[[@*i{;F;;h;;0;[;{;@-;!@#;"I"dstatic VALUE folevariable_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#I"static VALUE;T;@F;Ao;B;CT;DiE;EiV;!@#;"I"dstatic VALUE folevariable_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#@A;$To; ; F; ;,;;;I"WIN32OLE_VARIABLE#ole_type;F;[;[[@*i|;T;;;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;H ;II" overload;F;J0;;;K0;#I" ole_type;T;IC;";T;[;[;I";T;0; @D;@F;Mi;N0;[; @D;[;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; @D;@F;Ao;B;CT;Dim;Ei~;!@#;"I"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; ; F; ;,;;;I"&WIN32OLE_VARIABLE#ole_type_detail;F;[;[[@*i;T;:ole_type_detail;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;H ;II" overload;F;J0;;A ;K0;#I"ole_type_detail;T;IC;";T;[;[;I";T;0; @Z;@F;Mi;N0;[; @Z;[;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; @Z;@F;Ao;B;CT;Di;Ei;!@#;"I"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; ; F; ;,;;;I"WIN32OLE_VARIABLE#value;F;[;[[@*i;T;;/;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;H ;II" overload;F;J0;;/;K0;#I" value;T;IC;";T;[;[;I";T;0; @p;@F;Mi;N0;[; @p;[;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; @p;@F;Ao;B;CT;Di;Ei;!@#;"I"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; ; F; ;,;;;I"WIN32OLE_VARIABLE#visible?;F;[;[[@*i;T;;. ;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;H ;II" overload;F;J0;;. ;K0;#I" visible?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Di;Ei;Mi;!@#;"I"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; ; F; ;,;;;I"$WIN32OLE_VARIABLE#variable_kind;F;[;[[@*i0;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;H ;II" overload;F;J0;;B ;K0;#I"variable_kind;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei-;!@#;"I"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; ; F; ;,;;;I"WIN32OLE_VARIABLE#varkind;F;[;[[@*iX;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;H ;II" overload;F;J0;;C ;K0;#I" varkind;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiF;EiU;!@#;"I"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; ; F; ;,;;;I"WIN32OLE_VARIABLE#inspect;F;[;[[@*ig;T;;i;0;[;{;IC;"AReturns the OLE variable name and the value with class name. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @˕;[;I"@return [String];T;0; @˕;@F;Mi;N0;[; @˕;[;I"iReturns the OLE variable name and the value with class name. @overload inspect @return [String];T;0; @˕;@F;Ao;B;CT;Di`;Eie;!@#;"I"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@9;&@#;'IC;[;&@#;(IC;[;&@#;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@9;>;.[;[[@*i2[@*ir;T;:WIN32OLE_VARIABLE;;0;;;[;{;IC;"OWIN32OLE_VARIABLE objects represent OLE variable information.;T;[;[;I"S WIN32OLE_VARIABLE objects represent OLE variable information. ;T;0; @#;@F;Ao;B;CT;Di2;Ei4;Mi;!@;I"WIN32OLE_VARIABLE;F;1@ _ 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;H ;II" overload;F;J0;; ;K0;#I"new(typename, obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE_RECORD object;T; @;[;I"%@return [WIN32OLE_RECORD object];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_RECORD#to_h;F;[;[[@ie;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; @;@F;Ao;B;CT;DiD;Eib;!@;"I"dstatic VALUE folerecord_to_h(VALUE self) { return rb_ivar_get(self, rb_intern("fields")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_RECORD#typename;F;[;[[@i;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;Ao;B;CT;Dik;Ei;!@;"I"jstatic VALUE folerecord_typename(VALUE self) { return rb_ivar_get(self, rb_intern("typename")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"#WIN32OLE_RECORD#method_missing;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"method_missing(name);T;IC;";T;[;[;I";T;0; @:;@F;Mi;N0;[[I" name;T0; @:;[;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; @:;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I".WIN32OLE_RECORD#ole_instance_variable_get;F;[[I" name;T0;[[@i;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;H ;II" overload;F;J0;;F ;K0;#I"$ole_instance_variable_get(name);T;IC;";T;[;[;I";T;0; @S;@F;Mi;N0;[[I" name;T0; @S;[;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; @S;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I".WIN32OLE_RECORD#ole_instance_variable_set;F;[[I" name;T0[I"val;T0;[[@i;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;H ;II" overload;F;J0;;G ;K0;#I")ole_instance_variable_set(name, val);T;IC;";T;[;[;I";T;0; @m;@F;Mi;N0;[[I" name;T0[I"val;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_RECORD#inspect;F;[;[[@iA;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di+;Ei?;!@;"I"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;-{;.[;[[@i[@iS;T;:WIN32OLE_RECORD;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!@;I"WIN32OLE_RECORD;F;1@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;H ;II" overload;F;J0;; ;K0;#I"(new(typelib [, version1, version2]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE_TYPELIB object;T; @і;[;I"&@return [WIN32OLE_TYPELIB object];T;0; @і;@F;Mi;N0;[[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;Ao;B;CT;Dim;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPELIB#guid;F;[;[[@i;T;: guid;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;H ;II" overload;F;J0;;J ;K0;#I" guid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"The guid string.;T; @;[;I"@return [The guid string.];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPELIB#name;F;[;[[@i;T;;>;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;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"The type library name;T; @ ;[;I"$@return [The type library name];T;0; @ ;@F;Mi;N0;[; @ ;[;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; ; F; ;,;;;I"WIN32OLE_TYPELIB#to_s;F;[;[[@iJ;F;;h;;0;[;{;@;!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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;#@+;$To; ; F; ;,;;;I"WIN32OLE_TYPELIB#version;F;[;[[@i;T;;h;0;[;{;IC;"Returns the type library version. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.version #-> "1.3" ;T;[o;H ;II" overload;F;J0;;h;K0;#I" version;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I",The type library version String object.;T; @.;[;I"6@return [The type library version String object.];T;0; @.;@F;Mi;N0;[; @.;[;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; @.;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"#WIN32OLE_TYPELIB#major_version;F;[;[[@i;T;:major_version;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;H ;II" overload;F;J0;;K ;K0;#I"major_version;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"$The type library major version.;T; @I;[;I".@return [The type library major version.];T;0; @I;@F;Mi;N0;[; @I;[;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; @I;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"#WIN32OLE_TYPELIB#minor_version;F;[;[[@i,;T;:minor_version;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;H ;II" overload;F;J0;;L ;K0;#I"minor_version;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"$The type library minor version.;T; @d;[;I".@return [The type library minor version.];T;0; @d;@F;Mi;N0;[; @d;[;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; @d;@F;Ao;B;CT;Di#;Ei*;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPELIB#path;F;[;[[@iB;T;;;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;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" The type library file path.;T; @;[;I"*@return [The type library file path.];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di9;Ei@;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPELIB#ole_types;F;[;[[@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;H ;II" overload;F;J0;;M ;K0;#I"ole_types;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[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;Mi;N0;[; @;[;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; ; F; ;,;;;I"!WIN32OLE_TYPELIB#ole_classes;F;[;[[@iG;F;:ole_classes;;0;[;{;@;!@;"I"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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPELIB#visible?;F;[;[[@ij;T;;. ;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;H ;II" overload;F;J0;;. ;K0;#I" visible?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Di];Eig;Mi;!@;"I"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; ; F; ;,;;;I""WIN32OLE_TYPELIB#library_name;F;[;[[@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;H ;II" overload;F;J0;;O ;K0;#I"library_name;T;IC;";T;[;[;I";T;0; @֗;@F;Mi;N0;[; @֗;[;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;Ao;B;CT;Di};Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPELIB#inspect;F;[;[[@i3;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di*;Ei1;!@;"I"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;-{@;M @#;>;.[;[[@i[@i<;T;:WIN32OLE_TYPELIB;;0;;;[;{;IC;"LWIN32OLE_TYPELIB objects represent OLE tyblib information.;T;[;[;I"P WIN32OLE_TYPELIB objects represent OLE tyblib information. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;I"WIN32OLE_TYPELIB;F;1@ [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] ;T;[o;H ;II" overload;F;J0;;Q ;K0;#I"array(ary, vt);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I" WIN32OLE_VARIANT#initialize;F;[[I" args;T0;[[@$i;T;;;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;H ;II" overload;F;J0;; ;K0;#I"3new(val, vartype) #=> WIN32OLE_VARIANT object.;T;IC;";T;[;[;I";T;0; @:;@F;Mi;N0;[[I"val;T0[I" vartype;T0; @:;[;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; @:;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_VARIANT#value;F;[;[[@$i`;T;;/;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;Ao;B;CT;DiW;Ei];!@;"I"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; ; F; ;,;;;I"WIN32OLE_VARIANT#value=;F;[[I"val;T0;[[@$i;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;H ;II" overload;F;J0;;;K0;#I"value=(val);T;IC;";T;[;[;I";T;0; @d;@F;Mi;N0;[[I"val;T0; @d;[;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; @d;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_VARIANT#vartype;F;[;[[@$i;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;Ao;B;CT;Di~;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_VARIANT#[];F;[[@0;[[@$i;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;H ;II" overload;F;J0;;;K0;#I"[](i,j,...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_VARIANT#[]=;F;[[@0;[[@$i/;T;;+;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;H ;II" overload;F;J0;;+;K0;#I"[]=(i,j,...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei,;!@;"I"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;9;[[@$i;F;: Empty;;;;;;[;{;IC;"$represents VT_EMPTY OLE object. ;T;[;[;I"%represents VT_EMPTY OLE object. ;T;0; @Ƙ;@F;Ao;B;CT;Di;Ei;!@;I"WIN32OLE_VARIANT::Empty;F;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 specfied 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"G 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 specfied 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; @;@F;Ao;B;CT;Din;Ei{;Mi;!@;I"WIN32OLE_VARIANT;F;1@typelib type library. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.new(typelib).ole_classes instead. ;T;[o;H ;II" overload;F;J0;;N ;K0;#I"ole_classes(typelib);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Dip;Eit;!@;"I"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; ; F; ;;;;I"WIN32OLE_TYPE.typelibs;F;[;[[@i;T;;I ;0;[;{;IC;"~Returns array of type libraries. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead. ;T;[o;H ;II" overload;F;J0;;I ;K0;#I" typelibs;T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[; @%;[;I"Returns array of type libraries. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead. @overload typelibs;T;0; @%;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"WIN32OLE_TYPE.progids;F;[;[[@i;T;: progids;0;[;{;IC;"Returns array of ProgID. ;T;[o;H ;II" overload;F;J0;;X ;K0;#I" progids;T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[; @;;[;I"1Returns array of ProgID. @overload progids;T;0; @;;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPE#initialize;F;[[I" typelib;T0[I" oleclass;T0;[[@i;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(typelib, ole_class);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE_TYPE object;T; @Q;[;I"#@return [WIN32OLE_TYPE object];T;0; @Q;@F;Mi;N0;[[I" typelib;T0[I"ole_class;T0; @Q;[;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; @Q;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPE#name;F;[;[[@i%;T;;>;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; ; F; ;,;;;I"WIN32OLE_TYPE#to_s;F;[;[[@i;F;;h;;0;[;{;@{;!@;"I"`static VALUE foletype_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei";!@;"I"`static VALUE foletype_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#@;$To; ; F; ;,;;;I"WIN32OLE_TYPE#ole_type;F;[;[[@ia;T;;;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;Ao;B;CT;DiY;Ei^;!@;"I"~static VALUE foletype_ole_type(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_ole_type(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#guid;F;[;[[@i;T;;J ;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;Ao;B;CT;Di{;Ei;!@;"I"{static VALUE foletype_guid(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_guid(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#progid;F;[;[[@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;Ao;B;CT;Di;Ei;!@;"I"static VALUE foletype_progid(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_progid(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#visible?;F;[;[[@i;T;;. ;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;H ;II" overload;F;J0;;. ;K0;#I" visible? #=> true or false;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"#;TI"> true or false;T; @o;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE foletype_visible(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_visible(pTypeInfo); };T;#I"static VALUE;T;$T@o; ; F; ;,;;;I" WIN32OLE_TYPE#major_version;F;[;[[@i;T;;K ;0;[;{;IC;"Returns major version. tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.major_version # => 8 ;T;[o;H ;II" overload;F;J0;;K ;K0;#I"major_version;T;IC;";T;[;[;I";T;0; @Й;@F;Mi;N0;[; @Й;[;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;Ao;B;CT;Di;Ei;!@;"I"static VALUE foletype_major_version(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_major_version(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" WIN32OLE_TYPE#minor_version;F;[;[[@i;T;;L ;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;Ao;B;CT;Di;Ei;!@;"I"static VALUE foletype_minor_version(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_minor_version(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#typekind;F;[;[[@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;Ao;B;CT;Di;Ei;!@;"I"static VALUE foletype_typekind(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_typekind(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#helpstring;F;[;[[@i:;T;;1 ;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;Ao;B;CT;Di2;Ei7;!@;"I"static VALUE foletype_helpstring(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_helpstring(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#src_type;F;[;[[@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;Ao;B;CT;DiS;EiY;!@;"I"static VALUE foletype_src_type(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_src_type(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#helpfile;F;[;[[@ix;T;;2 ;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;H ;II" overload;F;J0;;2 ;K0;#I" helpfile;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Dio;Eiu;!@;"I"static VALUE foletype_helpfile(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_helpfile(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#helpcontext;F;[;[[@i;T;;3 ;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;H ;II" overload;F;J0;;3 ;K0;#I"helpcontext;T;IC;";T;[;[;I";T;0; @4;@F;Mi;N0;[; @4;[;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; @4;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE foletype_helpcontext(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_helpcontext(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#variables;F;[;[[@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;H ;II" overload;F;J0;;\ ;K0;#I"variables;T;IC;";T;[;[;I";T;0; @J;@F;Mi;N0;[; @J;[;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; @J;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE foletype_variables(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_variables(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"WIN32OLE_TYPE#ole_methods;F;[;[[@i;T;;;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; @`;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPE#ole_typelib;F;[;[[@i;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"ole_typelib;T;IC;";T;[;[;I";T;0; @n;@F;Mi;N0;[; @n;[;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; @n;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE foletype_ole_typelib(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_typelib_from_itypeinfo(pTypeInfo); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"(WIN32OLE_TYPE#implemented_ole_types;F;[;[[@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;H ;II" overload;F;J0;;] ;K0;#I"implemented_ole_types;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di%;Ei+;!@;"I"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; ; F; ;,;;;I"#WIN32OLE_TYPE#source_ole_types;F;[;[[@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;H ;II" overload;F;J0;;^ ;K0;#I"source_ole_types;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di5;Ei<;!@;"I"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; ; F; ;,;;;I"(WIN32OLE_TYPE#default_event_sources;F;[;[[@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;H ;II" overload;F;J0;;_ ;K0;#I"default_event_sources;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiF;EiL;!@;"I"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; ; F; ;,;;;I"$WIN32OLE_TYPE#default_ole_types;F;[;[[@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;H ;II" overload;F;J0;;` ;K0;#I"default_ole_types;T;IC;";T;[;[;I";T;0; @ƚ;@F;Mi;N0;[; @ƚ;[;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;Ao;B;CT;DiV;Ei];!@;"I"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; ; F; ;,;;;I"WIN32OLE_TYPE#inspect;F;[;[[@ip;T;;i;0;[;{;IC;"Returns the type name with class name. ie = WIN32OLE.new('InternetExplorer.Application') ie.ole_type.inspect => # ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ܚ;[;I"@return [String];T;0; @ܚ;@F;Mi;N0;[; @ܚ;[;I"Returns the type name with class name. ie = WIN32OLE.new('InternetExplorer.Application') ie.ole_type.inspect => # @overload inspect @return [String];T;0; @ܚ;@F;Ao;B;CT;Dig;Ein;!@;"I"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;-{@;>;.[;[[@i=[@ix;T;:WIN32OLE_TYPE;;0;;;[;{;IC;"PWIN32OLE_TYPE objects represent OLE type libarary information.;T;[;[;I"T WIN32OLE_TYPE objects represent OLE type libarary information. ;T;0; @;@F;Ao;B;CT;Di=;Ei?;Mi;!@;I"WIN32OLE_TYPE;F;1@ # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(method, n);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"WIN32OLE_PARAM object;T; @ ;[;I"$@return [WIN32OLE_PARAM object];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;,;;;I"WIN32OLE_PARAM#name;F;[;[[@i;T;;>;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;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[; @/;[;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; ; F; ;,;;;I"WIN32OLE_PARAM#to_s;F;[;[[@i;F;;h;;0;[;{;@6;!@ ;"I"astatic VALUE foleparam_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#I"static VALUE;T;@F;Ao;B;CT;Di;Ei;!@ ;"I"astatic VALUE foleparam_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;#@J;$To; ; F; ;,;;;I"WIN32OLE_PARAM#ole_type;F;[;[[@i;T;;;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;H ;II" overload;F;J0;;;K0;#I" ole_type;T;IC;";T;[;[;I";T;0; @M;@F;Mi;N0;[; @M;[;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; @M;@F;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;,;;;I"#WIN32OLE_PARAM#ole_type_detail;F;[;[[@i;T;;A ;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;H ;II" overload;F;J0;;A ;K0;#I"ole_type_detail;T;IC;";T;[;[;I";T;0; @c;@F;Mi;N0;[; @c;[;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; @c;@F;Ao;B;CT;Di;Ei;!@ ;"I"+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; ; F; ;,;;;I"WIN32OLE_PARAM#input?;F;[;[[@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;H ;II" overload;F;J0;;b ;K0;#I" input?;T;IC;";T;[;[;I";T;0; @y;@F;Mi;N0;[; @yo;L ;II" return;F;J@;0;K[@; @y;[;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; @y;@F;Ao;B;CT;Di;Ei;Mi;!@ ;"I"$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; ; F; ;,;;;I"WIN32OLE_PARAM#output?;F;[;[[@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;H ;II" overload;F;J0;;c ;K0;#I" output?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Di;Ei";Mi;!@ ;"I"&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; ; F; ;,;;;I"WIN32OLE_PARAM#optional?;F;[;[[@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;H ;II" overload;F;J0;;d ;K0;#I"optional?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Di.;Ei5;Mi;!@ ;"I"(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; ; F; ;,;;;I"WIN32OLE_PARAM#retval?;F;[;[[@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;H ;II" overload;F;J0;;e ;K0;#I" retval?;T;IC;";T;[;[;I";T;0; @ě;@F;Mi;N0;[; @ěo;L ;II" return;F;J@;0;K[@; @ě;[;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;Ao;B;CT;DiA;EiI;Mi;!@ ;"I")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; ; F; ;,;;;I"WIN32OLE_PARAM#default;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" default;T;IC;";T;[;[;I";T;0; @ݛ;@F;Mi;N0;[; @ݛ;[;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;Ao;B;CT;Dil;Ei;!@ ;"I"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@Bo; ; F; ;,;;;I"WIN32OLE_PARAM#inspect;F;[;[[@i;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@ ;"I"+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;-{@B;>;.[;[[@iG[@i;T;:WIN32OLE_PARAM;;0;;;[;{;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;Ao;B;CT;DiG;EiJ;Mi;!@;I"WIN32OLE_PARAM;F;1@ 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; @H;@F;N0;!@F;"I"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; ; T; ;;;;I"Etc.getlogin;F;@J;@K;T;;i ;0;@M;{;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; @U;@F;Ao;B;CT;Di>;EiL;Mi;!@F;"@S;#@T;$To; ; F; ;,;;;I"Etc#getpwuid;F;[[@0;[[@xci;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; @];@F;N0;!@F;"I"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; ; T; ;;;;I"Etc.getpwuid;F;@_;@a;T;;j ;0;@c;{;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; @k;@F;Ao;B;CT;Di;Ei;Mi;!@F;"@i;#@j;$To; ; F; ;,;;;I"Etc#getpwnam;F;[[I"nam;T0;[[@xci;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; @s;@F;N0;!@F;"I"Kstatic VALUE etc_getpwnam(VALUE obj, VALUE nam) { #ifdef HAVE_GETPWENT struct passwd *pwd; const char *p = StringValueCStr(nam); rb_check_safe_obj(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; ; T; ;;;;I"Etc.getpwnam;F;@u;@x;T;;k ;0;@z;{;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;Ao;B;CT;Di;Ei;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#setpwent;F;[;[[@xciO;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;N0;!@F;"I"jstatic VALUE etc_setpwent(VALUE obj) { #ifdef HAVE_GETPWENT setpwent(); #endif return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Etc.setpwent;F;@;@;T;;l ;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;Ao;B;CT;DiL;EiN;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#endpwent;F;[;[[@xci[;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;N0;!@F;"I"jstatic VALUE etc_endpwent(VALUE obj) { #ifdef HAVE_GETPWENT endpwent(); #endif return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Etc.endpwent;F;@;@;T;;m ;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;Ao;B;CT;DiX;EiZ;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#getpwent;F;[;[[@xcio;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;N0;!@F;"I"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; ; T; ;;;;I"Etc.getpwent;F;@;@;T;;n ;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;Ao;B;CT;Did;Ein;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#passwd;F;[;[[@xci;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;N0;!@F;"I"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; ; T; ;;;;I"Etc.passwd;F;@˜;@̜;T;;o ;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;Ao;B;CT;Di;Ei;Mi;!@F;"@Ԝ;#@՜;$To; ; F; ;,;;;I"Etc#getgrgid;F;[[@0;[[@xci;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;N0;!@F;"I"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; ; T; ;;;;I"Etc.getgrgid;F;@;@;T;;p ;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;Ao;B;CT;Di;Ei;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#getgrnam;F;[[I"nam;T0;[[@xci;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;N0;!@F;"I"Jstatic VALUE etc_getgrnam(VALUE obj, VALUE nam) { #ifdef HAVE_GETGRENT struct group *grp; const char *p = StringValueCStr(nam); rb_check_safe_obj(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; ; T; ;;;;I"Etc.getgrnam;F;@;@;T;;q ;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;Ao;B;CT;Di;Ei;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#group;F;[;[[@xci ;T;;=;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;N0;!@F;"I"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; ; T; ;;;;I"Etc.group;F;@ ;@;T;;=;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;Ao;B;CT;Di;Ei ;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#setgrent;F;[;[[@xci>;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;N0;!@F;"I"jstatic VALUE etc_setgrent(VALUE obj) { #ifdef HAVE_GETGRENT setgrent(); #endif return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Etc.setgrent;F;@";@#;T;;r ;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;Ao;B;CT;Di;;Ei=;Mi;!@F;"@+;#@,;$To; ; F; ;,;;;I"Etc#endgrent;F;[;[[@xciJ;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; @5;@F;N0;!@F;"I"jstatic VALUE etc_endgrent(VALUE obj) { #ifdef HAVE_GETGRENT endgrent(); #endif return Qnil; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Etc.endgrent;F;@7;@8;T;;s ;0;@:;{;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; @B;@F;Ao;B;CT;DiG;EiI;Mi;!@F;"@@;#@A;$To; ; F; ;,;;;I"Etc#getgrent;F;[;[[@xci];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; @J;@F;N0;!@F;"I"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; ; T; ;;;;I"Etc.getgrent;F;@L;@M;T;;t ;0;@O;{;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; @W;@F;Ao;B;CT;DiS;Ei\;Mi;!@F;"@U;#@V;$To; ; F; ;,;;;I"Etc#sysconfdir;F;[;[[@xciz;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; @_;@F;N0;!@F;"I"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; ; T; ;;;;I"Etc.sysconfdir;F;@a;@b;T;;u ;0;@d;{;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; @l;@F;Ao;B;CT;Dir;Eix;Mi;!@F;"@j;#@k;$To; ; F; ;,;;;I"Etc#systmpdir;F;[;[[@xci;T;:systmpdir;0;[;{;IC;":Returns system temporary directory; typically "/tmp". ;T;[;[;I":Returns system temporary directory; typically "/tmp".;T;0; @t;@F;N0;!@F;"I"static VALUE etc_systmpdir(void) { 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 FL_UNSET(tmpdir, FL_TAINT); return tmpdir; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Etc.systmpdir;F;@v;@w;T;;v ;0;@y;{;IC;":Returns system temporary directory; typically "/tmp".;T;[;[;I";Returns system temporary directory; typically "/tmp". ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#uname;F;[;[[@xci;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;N0;!@F;"I"p 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_IA64 # define PROCESSOR_ARCHITECTURE_IA64 6 # 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_IA64: mach = "IA64"; 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; ; T; ;;;;I"Etc.uname;F;@;@;T;;w ;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;Ao;B;CT;Di;Ei;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#sysconf;F;[[I"arg;T0;[[@xci3;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;N0;!@F;"I"&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; ; T; ;;;;I"Etc.sysconf;F;@;@;T;;x ;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;Ao;B;CT;Di';Ei1;Mi;!@F;"@;#@;$To; ; F; ;,;;;I"Etc#confstr;F;[[I"arg;T0;[[@xciX;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;N0;!@F;"I"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; ; T; ;;;;I"Etc.confstr;F;@;@;T;;y ;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;Ao;B;CT;DiI;EiV;Mi;!@F;"@;#@Ý;$To; ; F; ;,;;;I"Etc#nprocessors;F;[;[[@xci;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;N0;!@F;"I",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; ; T; ;;;;I"Etc.nprocessors;F;@Ν;@ϝ;T;;z ;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;Ao;B;CT;Di;Ei;Mi;!@F;"@ם;#@؝;$To;9;[[@xci;F;;t;;;;;;[;{;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;Ao;B;CT;Dih;Ei;!@F;I"Etc::Passwd;F;= 0) dbm = sdbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT, mode); if (!dbm) dbm = sdbm_open(RSTRING_PTR(file), O_RDWR, 0); if (!dbm) dbm = sdbm_open(RSTRING_PTR(file), O_RDONLY, 0); if (!dbm) { if (mode == -1) return Qnil; rb_sys_fail_str(file); } if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm); dbmp->di_dbm = dbm; dbmp->di_size = -1; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#close;F;[;[[@$i~;T;;;0;[;{;IC;"SCloses the database file. Raises SDBMError if the database is already closed. ;T;[o;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @i;[;I"@return [nil];T;0; @i;@F;Mi;N0;[; @i;[;I"uCloses the database file. Raises SDBMError if the database is already closed. @overload close @return [nil];T;0; @i;@F;Ao;B;CT;Di{;Ei|;!@;"I"static VALUE fsdbm_close(VALUE obj) { struct dbmdata *dbmp; GetDBM(obj, dbmp); sdbm_close(dbmp->di_dbm); dbmp->di_dbm = 0; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#closed?;F;[;[[@$i;T;;;0;[;{;IC;".Returns +true+ if the database is closed.;T;[o;H ;II" overload;F;J0;;;K0;#I" closed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"VReturns +true+ if the database is closed. @overload closed? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE fsdbm_closed(VALUE obj) { struct dbmdata *dbmp; TypedData_Get_Struct(obj, struct dbmdata, &sdbm_type, dbmp); if (dbmp->di_dbm == 0) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" SDBM#[];F;[[I" keystr;T0;[[@$i;T;;;0;[;{;IC;"vReturns the +value+ in the database associated with the given +key+ string. If no value is found, returns +nil+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" [](key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"key;T0; @;[;I"Returns the +value+ in the database associated with the given +key+ string. If no value is found, returns +nil+. @overload [](key) @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"dstatic VALUE fsdbm_aref(VALUE obj, VALUE keystr) { return fsdbm_fetch(obj, keystr, Qnil); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#fetch;F;[[@0;[[@$i.;T;;;0;[;{;IC;"]Returns the +value+ in the database associated with the given +key+ string. If a block is provided, the block will be called when there is no +value+ associated with the given +key+. The +key+ will be passed in as an argument to the block. If no block is provided and no value is associated with the given +key+, then an IndexError will be raised. ;T;[o;H ;II" overload;F;J0;;;K0;#I"fetch(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;;K0;#I"fetch(key);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @;[;I"@yield [key];T;0; @;@F;Mi;N0;[[I"key;T0; @;[;I"Returns the +value+ in the database associated with the given +key+ string. If a block is provided, the block will be called when there is no +value+ associated with the given +key+. The +key+ will be passed in as an argument to the block. If no block is provided and no value is associated with the given +key+, then an IndexError will be raised. @overload fetch(key) @return [nil] @overload fetch(key) @yield [key];T;0; @;@F;Ao;B;CT;Di ;Ei-;!@;"I"Cstatic VALUE fsdbm_fetch_m(int argc, VALUE *argv, VALUE obj) { VALUE keystr, valstr, ifnone; rb_scan_args(argc, argv, "11", &keystr, &ifnone); valstr = fsdbm_fetch(obj, keystr, ifnone); if (argc == 1 && !rb_block_given_p() && NIL_P(valstr)) rb_raise(rb_eIndexError, "key not found"); return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" SDBM#[]=;F;[[I" keystr;T0[I" valstr;T0;[[@$ik;T;;+;0;[;{;IC;"Stores a new +value+ in the database with the given +key+ as an index. If the +key+ already exists, this will update the +value+ associated with the +key+. Returns the given +value+. ;T;[o;H ;II" overload;F;J0;;+;K0;#I" []=(key);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;;K0;#I"store(key, value);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"key;T0[I" value;T0; @;[;I"Stores a new +value+ in the database with the given +key+ as an index. If the +key+ already exists, this will update the +value+ associated with the +key+. Returns the given +value+. @overload []=(key) @overload store(key, value);T;0; @;@F;Ao;B;CT;Di_;Eih;!@;"I"static VALUE fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; if (valstr == Qnil) { fsdbm_delete(obj, keystr); return Qnil; } fdbm_modify(obj); ExportStringValue(keystr); ExportStringValue(valstr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_LENINT(valstr); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; if (sdbm_store(dbm, key, val, DBM_REPLACE)) { #ifdef HAVE_DBM_CLAERERR sdbm_clearerr(dbm); #endif if (errno == EPERM) rb_sys_fail(0); rb_raise(rb_eDBMError, "sdbm_store failed"); } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#store;F;[[I" keystr;T0[I" valstr;T0;[[@$ik;T;;;0;[;{;IC;"Stores a new +value+ in the database with the given +key+ as an index. If the +key+ already exists, this will update the +value+ associated with the +key+. Returns the given +value+. ;T;[o;H ;II" overload;F;J0;;+;K0;#I" []=(key);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;;K0;#I"store(key, value);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"key;T0[I" value;T0; @;[;@;0; @;@F;Ao;B;CT;Di_;Eih;!@;"I"static VALUE fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; if (valstr == Qnil) { fsdbm_delete(obj, keystr); return Qnil; } fdbm_modify(obj); ExportStringValue(keystr); ExportStringValue(valstr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_LENINT(valstr); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; if (sdbm_store(dbm, key, val, DBM_REPLACE)) { #ifdef HAVE_DBM_CLAERERR sdbm_clearerr(dbm); #endif if (errno == EPERM) rb_sys_fail(0); rb_raise(rb_eDBMError, "sdbm_store failed"); } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#index;F;[[I" value;T0;[[@$i[;T;;1;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc: ;T;0; @:;@F;Ao;B;CT;DiX;EiY;!@;"I"static VALUE fsdbm_index(VALUE hash, VALUE value) { rb_warn("SDBM#index is deprecated; use SDBM#key"); return fsdbm_key(hash, value); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" SDBM#key;F;[[I" valstr;T0;[[@$iC;T;;;0;[;{;IC;"Returns the +key+ associated with the given +value+. If more than one +key+ corresponds to the given +value+, then the first key to be found will be returned. If no keys are found, +nil+ will be returned. ;T;[o;H ;II" overload;F;J0;;;K0;#I"key(value);T;IC;";T;[;[;I";T;0; @J;@F;Mi;N0;[[I" value;T0; @J;[;I"Returns the +key+ associated with the given +value+. If more than one +key+ corresponds to the given +value+, then the first key to be found will be returned. If no keys are found, +nil+ will be returned. @overload key(value);T;0; @J;@F;Ao;B;CT;Di;;Ei@;!@;"I"static VALUE fsdbm_key(VALUE obj, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; ExportStringValue(valstr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_LENINT(valstr); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); if (val.dsize == RSTRING_LEN(valstr) && memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) return rb_external_str_new(key.dptr, key.dsize); } return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#select;F;[;[[@$iu;T;;;0;[;{;IC;"cReturns a new Array of key-value pairs for which the block returns +true+. Example: require 'sdbm' SDBM.open 'my_database' do |db| db['apple'] = 'fruit' db['pear'] = 'fruit' db['spinach'] = 'vegetable' veggies = db.select do |key, value| value == 'vegetable' end #=> [["apple", "fruit"], ["pear", "fruit"]] end ;T;[o;H ;II" overload;F;J0;;;K0;#I" select;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @do;L ;II" return;F;JI";T;0;K[I" Array;T; @d;[;I"(@yield [key, value] @return [Array];T;0; @d;@F;Mi;N0;[; @d;[;I"Returns a new Array of key-value pairs for which the block returns +true+. Example: require 'sdbm' SDBM.open 'my_database' do |db| db['apple'] = 'fruit' db['pear'] = 'fruit' db['spinach'] = 'vegetable' veggies = db.select do |key, value| value == 'vegetable' end #=> [["apple", "fruit"], ["pear", "fruit"]] end @overload select @yield [key, value] @return [Array];T;0; @d;@F;Ao;B;CT;Dib;Eiu;!@;"I"static VALUE fsdbm_select(VALUE obj) { VALUE new = rb_ary_new(); datum key, val; DBM *dbm; struct dbmdata *dbmp; GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { VALUE assoc, v; val = sdbm_fetch(dbm, key); assoc = rb_assoc_new(rb_external_str_new(key.dptr, key.dsize), rb_external_str_new(val.dptr, val.dsize)); v = rb_yield(assoc); if (RTEST(v)) { rb_ary_push(new, assoc); } GetDBM2(obj, dbmp, dbm); } return new; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#values_at;F;[[@0;[[@$i;T;;;0;[;{;IC;"@Returns an Array of values corresponding to the given keys. ;T;[o;H ;II" overload;F;J0;;;K0;#I"values_at(key, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"key;T0[I"...;T0; @;[;I"rReturns an Array of values corresponding to the given keys. @overload values_at(key, ...) @return [Array];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE fsdbm_values_at(int argc, VALUE *argv, VALUE obj) { VALUE new = rb_ary_new2(argc); int i; for (i=0; idi_size > 0) return INT2FIX(dbmp->di_size); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { i++; } dbmp->di_size = i; return INT2FIX(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#size;F;[;[[@$i;T;;;0;[;{;IC;"0Returns the number of keys in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @͠;[;I"@return [Integer];T;0; @͠;@F;Mi;N0;[; @͠o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @͠;[;I"@return [Integer];T;0; @͠;@F;Mi;N0;[; @͠;[;@ɠ;0; @͠;@F;Ao;B;CT;Di;Ei;!@;"I"Jstatic VALUE fsdbm_length(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; int i = 0; GetDBM2(obj, dbmp, dbm); if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { i++; } dbmp->di_size = i; return INT2FIX(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#empty?;F;[;[[@$i;T;;;0;[;{;IC;"-Returns +true+ if the database is empty.;T;[o;H ;II" overload;F;J0;;;K0;#I" empty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"TReturns +true+ if the database is empty. @overload empty? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"Xstatic VALUE fsdbm_empty_p(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; GetDBM(obj, dbmp); if (dbmp->di_size < 0) { dbm = dbmp->di_dbm; for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { return Qfalse; } } else { if (dbmp->di_size) return Qfalse; } return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#each;F;[;[[@$i2;T;;;0;[;{;IC;"eIterates over each key-value pair in the database. If no block is given, returns an Enumerator. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;[;I"@yield [key, value];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;[;I"@yield [key, value];T;0; @;@F;Mi;N0;[; @;[;I"Iterates over each key-value pair in the database. If no block is given, returns an Enumerator. @overload each @overload each @yield [key, value] @overload each_pair @overload each_pair @yield [key, value];T;0; @;@F;Ao;B;CT;Di';Ei1;!@;"I"static VALUE fsdbm_each_pair(VALUE obj) { datum key, val; DBM *dbm; struct dbmdata *dbmp; VALUE keystr, valstr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); keystr = rb_external_str_new(key.dptr, key.dsize); valstr = rb_external_str_new(val.dptr, val.dsize); rb_yield(rb_assoc_new(keystr, valstr)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#each_value;F;[;[[@$i;T;;;0;[;{;IC;"^Iterates over each +value+ in the database. If no block is given, returns an Enumerator. ;T;[o;H ;II" overload;F;J0;;;K0;#I"each_value;T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;;K0;#I"each_value;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" value;T; @I;[;I"@yield [value];T;0; @I;@F;Mi;N0;[; @I;[;I"Iterates over each +value+ in the database. If no block is given, returns an Enumerator. @overload each_value @overload each_value @yield [value];T;0; @I;@F;Ao;B;CT;Di;Ei;!@;"I"sstatic VALUE fsdbm_each_value(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); rb_yield(rb_external_str_new(val.dptr, val.dsize)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#each_key;F;[;[[@$i;T;;;0;[;{;IC;"\Iterates over each +key+ in the database. If no block is given, returns an Enumerator. ;T;[o;H ;II" overload;F;J0;;;K0;#I" each_key;T;IC;";T;[;[;I";T;0; @l;@F;Mi;N0;[; @lo;H ;II" overload;F;J0;;;K0;#I" each_key;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;T; @l;[;I"@yield [key];T;0; @l;@F;Mi;N0;[; @l;[;I"Iterates over each +key+ in the database. If no block is given, returns an Enumerator. @overload each_key @overload each_key @yield [key];T;0; @l;@F;Ao;B;CT;Di ;Ei;!@;"I"Ostatic VALUE fsdbm_each_key(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { rb_yield(rb_external_str_new(key.dptr, key.dsize)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#each_pair;F;[;[[@$i2;T;;;0;[;{;IC;"eIterates over each key-value pair in the database. If no block is given, returns an Enumerator. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" each;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;[;I"@yield [key, value];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"each_pair;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;[;I"@yield [key, value];T;0; @;@F;Mi;N0;[; @;[;@E;0; @;@F;Ao;B;CT;Di';Ei1;!@;"I"static VALUE fsdbm_each_pair(VALUE obj) { datum key, val; DBM *dbm; struct dbmdata *dbmp; VALUE keystr, valstr; RETURN_ENUMERATOR(obj, 0, 0); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); keystr = rb_external_str_new(key.dptr, key.dsize); valstr = rb_external_str_new(val.dptr, val.dsize); rb_yield(rb_assoc_new(keystr, valstr)); GetDBM2(obj, dbmp, dbm); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#keys;F;[;[[@$iN;T;;;0;[;{;IC;"=Returns a new Array containing the keys in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" keys;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ȡ;[;I"@return [Array];T;0; @ȡ;@F;Mi;N0;[; @ȡ;[;I"`Returns a new Array containing the keys in the database. @overload keys @return [Array];T;0; @ȡ;@F;Ao;B;CT;DiH;EiL;!@;"I">static VALUE fsdbm_keys(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; VALUE ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { rb_ary_push(ary, rb_external_str_new(key.dptr, key.dsize)); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#values;F;[;[[@$ie;T;;;0;[;{;IC;"?Returns a new Array containing the values in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" values;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;I"dReturns a new Array containing the values in the database. @overload values @return [Array];T;0; @;@F;Ao;B;CT;Di_;Eic;!@;"I"bstatic VALUE fsdbm_values(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); rb_ary_push(ary, rb_external_str_new(val.dptr, val.dsize)); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#shift;F;[;[[@$i;T;;;0;[;{;IC;"vRemoves a key-value pair from the database and returns them as an Array. If the database is empty, returns +nil+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" shift;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;TI"nil;T; @;[;I"@return [Array, nil];T;0; @;@F;Mi;N0;[; @;[;I"Removes a key-value pair from the database and returns them as an Array. If the database is empty, returns +nil+. @overload shift @return [Array, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE fsdbm_shift(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); key = sdbm_firstkey(dbm); if (!key.dptr) return Qnil; val = sdbm_fetch(dbm, key); keystr = rb_external_str_new(key.dptr, key.dsize); valstr = rb_external_str_new(val.dptr, val.dsize); sdbm_delete(dbm, key); if (dbmp->di_size >= 0) { dbmp->di_size--; } return rb_assoc_new(keystr, valstr); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#delete;F;[[I" keystr;T0;[[@$i;T;;p;0;[;{;IC;"-Deletes the key-value pair corresponding to the given +key+. If the +key+ exists, the deleted value will be returned, otherwise +nil+. If a block is provided, the deleted +key+ and +value+ will be passed to the block as arguments. If the +key+ does not exist in the database, the value will be +nil+. ;T;[o;H ;II" overload;F;J0;;p;K0;#I"delete(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;p;K0;#I"delete(key);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @;[;I"@yield [key, value];T;0; @;@F;Mi;N0;[[I"key;T0; @;[;I"Deletes the key-value pair corresponding to the given +key+. If the +key+ exists, the deleted value will be returned, otherwise +nil+. If a block is provided, the deleted +key+ and +value+ will be passed to the block as arguments. If the +key+ does not exist in the database, the value will be +nil+. @overload delete(key) @return [nil] @overload delete(key) @yield [key, value];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE fsdbm_delete(VALUE obj, VALUE keystr) { datum key, value; struct dbmdata *dbmp; DBM *dbm; VALUE valstr; fdbm_modify(obj); ExportStringValue(keystr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; value = sdbm_fetch(dbm, key); if (value.dptr == 0) { if (rb_block_given_p()) return rb_yield(keystr); return Qnil; } /* need to save value before sdbm_delete() */ valstr = rb_external_str_new(value.dptr, value.dsize); if (sdbm_delete(dbm, key)) { dbmp->di_size = -1; rb_raise(rb_eDBMError, "dbm_delete failed"); } else if (dbmp->di_size >= 0) { dbmp->di_size--; } return valstr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#delete_if;F;[;[[@$i;T;;;0;[;{;IC;"jIterates over the key-value pairs in the database, deleting those for which the block returns +true+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @Io;L ;II" return;F;JI";T;0;K[I" self;T; @I;[;I"'@yield [key, value] @return [self];T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @Io;L ;II" return;F;JI";T;0;K[I" self;T; @I;[;I"'@yield [key, value] @return [self];T;0; @I;@F;Mi;N0;[; @I;[;I"Iterates over the key-value pairs in the database, deleting those for which the block returns +true+. @overload delete_if @yield [key, value] @return [self] @overload reject! @yield [key, value] @return [self];T;0; @I;@F;Ao;B;CT;Di;Ei;!@;"I".static VALUE fsdbm_delete_if(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; VALUE ret, ary = rb_ary_new(); long i; int status = 0, n; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); n = dbmp->di_size; dbmp->di_size = -1; for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); keystr = rb_external_str_new(key.dptr, key.dsize); valstr = rb_external_str_new(val.dptr, val.dsize); ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status); if (status != 0) break; if (RTEST(ret)) rb_ary_push(ary, keystr); GetDBM2(obj, dbmp, dbm); } for (i = 0; i < RARRAY_LEN(ary); i++) { keystr = RARRAY_AREF(ary, i); ExportStringValue(keystr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); if (sdbm_delete(dbm, key)) { rb_raise(rb_eDBMError, "sdbm_delete failed"); } } if (status) rb_jump_tag(status); if (n > 0) dbmp->di_size = n - RARRAY_LENINT(ary); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#reject!;F;[;[[@$i;T;;;0;[;{;IC;"jIterates over the key-value pairs in the database, deleting those for which the block returns +true+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"delete_if;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @}o;L ;II" return;F;JI";T;0;K[I" self;T; @};[;I"'@yield [key, value] @return [self];T;0; @};@F;Mi;N0;[; @}o;H ;II" overload;F;J0;;;K0;#I" reject!;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @}o;L ;II" return;F;JI";T;0;K[I" self;T; @};[;I"'@yield [key, value] @return [self];T;0; @};@F;Mi;N0;[; @};[;@y;0; @};@F;Ao;B;CT;Di;Ei;!@;"I".static VALUE fsdbm_delete_if(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; VALUE ret, ary = rb_ary_new(); long i; int status = 0, n; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); n = dbmp->di_size; dbmp->di_size = -1; for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); keystr = rb_external_str_new(key.dptr, key.dsize); valstr = rb_external_str_new(val.dptr, val.dsize); ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status); if (status != 0) break; if (RTEST(ret)) rb_ary_push(ary, keystr); GetDBM2(obj, dbmp, dbm); } for (i = 0; i < RARRAY_LEN(ary); i++) { keystr = RARRAY_AREF(ary, i); ExportStringValue(keystr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); if (sdbm_delete(dbm, key)) { rb_raise(rb_eDBMError, "sdbm_delete failed"); } } if (status) rb_jump_tag(status); if (n > 0) dbmp->di_size = n - RARRAY_LENINT(ary); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#reject;F;[;[[@$i;T;;;0;[;{;IC;"Creates a new Hash using the key-value pairs from the database, then calls Hash#reject with the given block, which returns a Hash with only the key-value pairs for which the block returns +false+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reject;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"key;TI" value;T; @o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"'@yield [key, value] @return [Hash];T;0; @;@F;Mi;N0;[; @;[;I"Creates a new Hash using the key-value pairs from the database, then calls Hash#reject with the given block, which returns a Hash with only the key-value pairs for which the block returns +false+. @overload reject @yield [key, value] @return [Hash];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"_static VALUE fsdbm_reject(VALUE obj) { return rb_hash_delete_if(fsdbm_to_hash(obj)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#clear;F;[;[[@$i(;T;;3;0;[;{;IC;"(Deletes all data from the database. ;T;[o;H ;II" overload;F;J0;;3;K0;#I" clear;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @Ѣ;[;I"@return [self];T;0; @Ѣ;@F;Mi;N0;[; @Ѣ;[;I"KDeletes all data from the database. @overload clear @return [self];T;0; @Ѣ;@F;Ao;B;CT;Di";Ei&;!@;"I"]static VALUE fsdbm_clear(VALUE obj) { datum key; struct dbmdata *dbmp; DBM *dbm; fdbm_modify(obj); GetDBM2(obj, dbmp, dbm); dbmp->di_size = -1; while (key = sdbm_firstkey(dbm), key.dptr) { if (sdbm_delete(dbm, key)) { rb_raise(rb_eDBMError, "sdbm_delete failed"); } } dbmp->di_size = 0; return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#invert;F;[;[[@$iL;T;;;0;[;{;IC;"Returns a Hash in which the key-value pairs have been inverted. Example: require 'sdbm' SDBM.open 'my_database' do |db| db.update('apple' => 'fruit', 'spinach' => 'vegetable') db.invert #=> {"fruit" => "apple", "vegetable" => "spinach"} end ;T;[o;H ;II" overload;F;J0;;;K0;#I" invert;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[; @;[;I"'Returns a Hash in which the key-value pairs have been inverted. Example: require 'sdbm' SDBM.open 'my_database' do |db| db.update('apple' => 'fruit', 'spinach' => 'vegetable') db.invert #=> {"fruit" => "apple", "vegetable" => "spinach"} end @overload invert @return [Hash];T;0; @;@F;Ao;B;CT;Di<;EiJ;!@;"I"static VALUE fsdbm_invert(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE keystr, valstr; VALUE hash = rb_hash_new(); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); keystr = rb_external_str_new(key.dptr, key.dsize); valstr = rb_external_str_new(val.dptr, val.dsize); rb_hash_aset(hash, valstr, keystr); } return hash; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#update;F;[[I" other;T0;[[@$i;T;;;0;[;{;IC;"~Insert or update key-value pairs. This method will work with any object which implements an each_pair method, such as a Hash. ;T;[o;H ;II" overload;F;J0;;;K0;#I"update(pairs);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[[I" pairs;T0; @;[;I"Insert or update key-value pairs. This method will work with any object which implements an each_pair method, such as a Hash. @overload update(pairs) @return [self];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE fsdbm_update(VALUE obj, VALUE other) { rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#replace;F;[[I" other;T0;[[@$i;T;;';0;[;{;IC;"Empties the database, then inserts the given key-value pairs. This method will work with any object which implements an each_pair method, such as a Hash. ;T;[o;H ;II" overload;F;J0;;';K0;#I"replace(pairs);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @&;[;I"@return [self];T;0; @&;@F;Mi;N0;[[I" pairs;T0; @&;[;I"Empties the database, then inserts the given key-value pairs. This method will work with any object which implements an each_pair method, such as a Hash. @overload replace(pairs) @return [self];T;0; @&;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE fsdbm_replace(VALUE obj, VALUE other) { fsdbm_clear(obj); rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#has_key?;F;[[I" keystr;T0;[[@$i;T;;;0;[;{;IC;"=Returns +true+ if the database contains the given +key+.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @E;[;I"@return [Boolean];T;0; @E;@F;Mi;N0;[[I"key;T0; @Eo;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @E;[;I"@return [Boolean];T;0; @E;@F;Mi;N0;[[I"key;T0; @Eo;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @E;[;I"@return [Boolean];T;0; @E;@F;Mi;N0;[[I"key;T0; @Eo;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @E;[;I"@return [Boolean];T;0; @E;@F;Mi;N0;[[I"key;T0; @E;[;I"Returns +true+ if the database contains the given +key+. @overload include?(key) @return [Boolean] @overload key?(key) @return [Boolean] @overload member?(key) @return [Boolean] @overload has_key?(key) @return [Boolean];T;0; @E;@F;Ao;B;CT;Diw;Ei;Mi;!@;"I"Pstatic VALUE fsdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; ExportStringValue(keystr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); GetDBM2(obj, dbmp, dbm); val = sdbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#include?;F;[[I" keystr;T0;[[@$i;T;;U;0;[;{;IC;"=Returns +true+ if the database contains the given +key+.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"key;T0; @;[;@;0; @;@F;Ao;B;CT;Diw;Ei;Mi;!@;"I"Pstatic VALUE fsdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; ExportStringValue(keystr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); GetDBM2(obj, dbmp, dbm); val = sdbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#key?;F;[[I" keystr;T0;[[@$i;T;;;0;[;{;IC;"=Returns +true+ if the database contains the given +key+.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ܣ;[;I"@return [Boolean];T;0; @ܣ;@F;Mi;N0;[[I"key;T0; @ܣo;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ܣ;[;I"@return [Boolean];T;0; @ܣ;@F;Mi;N0;[[I"key;T0; @ܣo;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ܣ;[;I"@return [Boolean];T;0; @ܣ;@F;Mi;N0;[[I"key;T0; @ܣo;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ܣ;[;I"@return [Boolean];T;0; @ܣ;@F;Mi;N0;[[I"key;T0; @ܣ;[;@;0; @ܣ;@F;Ao;B;CT;Diw;Ei;Mi;!@;"I"Pstatic VALUE fsdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; ExportStringValue(keystr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); GetDBM2(obj, dbmp, dbm); val = sdbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#member?;F;[[I" keystr;T0;[[@$i;T;;;0;[;{;IC;"=Returns +true+ if the database contains the given +key+.;T;[ o;H ;II" overload;F;J0;;U;K0;#I"include?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @';[;I"@return [Boolean];T;0; @';@F;Mi;N0;[[I"key;T0; @'o;H ;II" overload;F;J0;;;K0;#I"key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @';[;I"@return [Boolean];T;0; @';@F;Mi;N0;[[I"key;T0; @'o;H ;II" overload;F;J0;;;K0;#I"member?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @';[;I"@return [Boolean];T;0; @';@F;Mi;N0;[[I"key;T0; @'o;H ;II" overload;F;J0;;;K0;#I"has_key?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @';[;I"@return [Boolean];T;0; @';@F;Mi;N0;[[I"key;T0; @';[;@;0; @';@F;Ao;B;CT;Diw;Ei;Mi;!@;"I"Pstatic VALUE fsdbm_has_key(VALUE obj, VALUE keystr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; ExportStringValue(keystr); key.dptr = RSTRING_PTR(keystr); key.dsize = RSTRING_LENINT(keystr); GetDBM2(obj, dbmp, dbm); val = sdbm_fetch(dbm, key); if (val.dptr) return Qtrue; return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#has_value?;F;[[I" valstr;T0;[[@$i;T;;;0;[;{;IC;"?Returns +true+ if the database contains the given +value+.;T;[o;H ;II" overload;F;J0;;;K0;#I"value?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @r;[;I"@return [Boolean];T;0; @r;@F;Mi;N0;[[I"key;T0; @ro;H ;II" overload;F;J0;;;K0;#I"has_value?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @r;[;I"@return [Boolean];T;0; @r;@F;Mi;N0;[[I"key;T0; @r;[;I"Returns +true+ if the database contains the given +value+. @overload value?(key) @return [Boolean] @overload has_value?(key) @return [Boolean];T;0; @r;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE fsdbm_has_value(VALUE obj, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; ExportStringValue(valstr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_LENINT(valstr); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); if (val.dsize == RSTRING_LENINT(valstr) && memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#value?;F;[[I" valstr;T0;[[@$i;T;;;0;[;{;IC;"?Returns +true+ if the database contains the given +value+.;T;[o;H ;II" overload;F;J0;;;K0;#I"value?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"key;T0; @o;H ;II" overload;F;J0;;;K0;#I"has_value?(key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"key;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE fsdbm_has_value(VALUE obj, VALUE valstr) { datum key, val; struct dbmdata *dbmp; DBM *dbm; ExportStringValue(valstr); val.dptr = RSTRING_PTR(valstr); val.dsize = RSTRING_LENINT(valstr); GetDBM2(obj, dbmp, dbm); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); if (val.dsize == RSTRING_LENINT(valstr) && memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) return Qtrue; } return Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#to_a;F;[;[[@$i;T;;;0;[;{;IC;"Returns a new Array containing each key-value pair in the database. Example: require 'sdbm' SDBM.open 'my_database' do |db| db.update('apple' => 'fruit', 'spinach' => 'vegetable') db.to_a #=> [["apple", "fruit"], ["spinach", "vegetable"]] end ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_a;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ͤ;[;I"@return [Array];T;0; @ͤ;@F;Mi;N0;[; @ͤ;[;I"(Returns a new Array containing each key-value pair in the database. Example: require 'sdbm' SDBM.open 'my_database' do |db| db.update('apple' => 'fruit', 'spinach' => 'vegetable') db.to_a #=> [["apple", "fruit"], ["spinach", "vegetable"]] end @overload to_a @return [Array];T;0; @ͤ;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE fsdbm_to_a(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE ary; GetDBM2(obj, dbmp, dbm); ary = rb_ary_new(); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); rb_ary_push(ary, rb_assoc_new(rb_external_str_new(key.dptr, key.dsize), rb_external_str_new(val.dptr, val.dsize))); } return ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SDBM#to_hash;F;[;[[@$i;T;;;0;[;{;IC;"GReturns a new Hash containing each key-value pair in the database. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_hash;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[; @;[;I"lReturns a new Hash containing each key-value pair in the database. @overload to_hash @return [Hash];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE fsdbm_to_hash(VALUE obj) { datum key, val; struct dbmdata *dbmp; DBM *dbm; VALUE hash; GetDBM2(obj, dbmp, dbm); hash = rb_hash_new(); for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) { val = sdbm_fetch(dbm, key); rb_hash_aset(hash, rb_external_str_new(key.dptr, key.dsize), rb_external_str_new(val.dptr, val.dsize)); } return hash; };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[@C;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@$i[@$i;T;: SDBM;;0;;;[;{;IC;"bSDBM provides a simple file-based key-value store, which can only store String keys and values. Note that Ruby comes with the source code for SDBM, while the DBM and GDBM standard libraries rely on external libraries and headers. === Examples Insert values: require 'sdbm' SDBM.open 'my_database' do |db| db['apple'] = 'fruit' db['pear'] = 'fruit' db['carrot'] = 'vegetable' db['tomato'] = 'vegetable' end Bulk update: require 'sdbm' SDBM.open 'my_database' do |db| db.update('peach' => 'fruit', 'tomato' => 'fruit') end Retrieve values: require 'sdbm' SDBM.open 'my_database' do |db| db.each do |key, value| puts "Key: #{key}, Value: #{value}" end end Outputs: Key: apple, Value: fruit Key: pear, Value: fruit Key: carrot, Value: vegetable Key: peach, Value: fruit Key: tomato, Value: fruit;T;[;[;I"d SDBM provides a simple file-based key-value store, which can only store String keys and values. Note that Ruby comes with the source code for SDBM, while the DBM and GDBM standard libraries rely on external libraries and headers. === Examples Insert values: require 'sdbm' SDBM.open 'my_database' do |db| db['apple'] = 'fruit' db['pear'] = 'fruit' db['carrot'] = 'vegetable' db['tomato'] = 'vegetable' end Bulk update: require 'sdbm' SDBM.open 'my_database' do |db| db.update('peach' => 'fruit', 'tomato' => 'fruit') end Retrieve values: require 'sdbm' SDBM.open 'my_database' do |db| db.each do |key, value| puts "Key: #{key}, Value: #{value}" end end Outputs: Key: apple, Value: fruit Key: pear, Value: fruit Key: carrot, Value: vegetable Key: peach, Value: fruit Key: tomato, Value: fruit ;T;0; @;@F;Ao;B;CT;Di;EiD;Mi;!@;I" SDBM;F;1@ [1, 2, nil], ... } ;T;[o;H ;II" overload;F;J0;; ;K0;#I"peek_result;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@P;"I"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"); } st_foreach(RHASH_TBL(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; ; T; ;;;;I"Coverage.peek_result;F;@;@¦;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;H ;II" overload;F;J0;; ;K0;#I"peek_result;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @٦;[;I"@return [Hash];T;0; @٦;@F;Mi;N0;[; @٦;[;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;Ao;B;CT;Di;Ei;Mi;!@P;"@צ;#@ئ;$To; ; F; ;,;;;I"Coverage#running?;F;[;[[@Xi$;T;: running?;0;[;{;IC;"~Returns true if coverage stats are currently being collected (after Coverage.start call, but before Coverage.result call) ;T;[o;H ;II" overload;F;J0;; ;K0;#I" running?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;N0;!@P;"I"static VALUE rb_coverage_running(VALUE klass) { VALUE coverages = rb_get_coverages(); return RTEST(coverages) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Coverage.running?;F;@;@;T;; ;0;@;{;IC;"~Returns true if coverage stats are currently being collected (after Coverage.start call, but before Coverage.result call);T;[o;H ;II" overload;F;J0;; ;K0;#I" running?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei";Mi;!@P;"@;#@;$T;&@P;'IC;[;&@P;(IC;[;&@P;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@XiO;F;: Coverage;;0;;;[;{;IC;" ;T;[;[;@;0; @P;Mi;!@;I" Coverage;Fo; ;IC;[o; ;IC;[ o; ; F; ;,;;;I""Racc::Parser#_racc_do_parse_c;F;[[I"arg;T0[I" sysdebug;T0;[[I"ext/racc/cparse/cparse.c;Ti;T;:_racc_do_parse_c;0;[;{;IC;" ;T;[;[;@;0; @0;!@.;"I"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; ; F; ;,;;;I"!Racc::Parser#_racc_yyparse_c;F;[ [I" lexer;T0[I" lexmid;T0[I"arg;T0[I" sysdebug;T0;[[@9i;T;:_racc_yyparse_c;0;[;{;IC;" ;T;[;[;@;0; @A;!@.;"I"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;9;[[@9iA;F;: Racc_Runtime_Core_Version_C;;;;;;[;{;IC;" ;T;[;[;@;0; @U;!@.;I".Racc::Parser::Racc_Runtime_Core_Version_C;F;\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; @;@F;Ao;B;CT;Di`;Eib;!@;"I"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); OBJ_INFECT(self, str); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#freeze;F;[;[[@[i};T;;f;0;[;{;IC;"/Freezes this Pathname. See Object.freeze. ;T;[o;H ;II" overload;F;J0;;f;K0;#I" freeze;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"UFreezes this Pathname. See Object.freeze. @overload freeze @return [Object];T;0; @;@F;Ao;B;CT;Diz;Ei{;!@;"I"}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; ; F; ;,;;;I"Pathname#taint;F;[;[[@[i;T;;`;0;[;{;IC;"-Taints this Pathname. See Object.taint. ;T;[o;H ;II" overload;F;J0;;`;K0;#I" taint;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @ŧ;[;I"@return [Object];T;0; @ŧ;@F;Mi;N0;[; @ŧ;[;I"RTaints this Pathname. See Object.taint. @overload taint @return [Object];T;0; @ŧ;@F;Ao;B;CT;Di;Ei;!@;"I"{static VALUE path_taint(VALUE self) { rb_call_super(0, 0); rb_obj_taint(get_strpath(self)); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#untaint;F;[;[[@[i;T;;b;0;[;{;IC;"1Untaints this Pathname. See Object.untaint. ;T;[o;H ;II" overload;F;J0;;b;K0;#I" untaint;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[; @;[;I"XUntaints this Pathname. See Object.untaint. @overload untaint @return [Object];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE path_untaint(VALUE self) { rb_call_super(0, 0); rb_obj_untaint(get_strpath(self)); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#==;F;[[I" other;T0;[[@[i;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;[;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#===;F;[[I" other;T0;[[@[i;T;;O;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#eql?;F;[[I" other;T0;[[@[i;T;;R;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;L ;II" return;F;J@;0;K[@; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#<=>;F;[[I" other;T0;[[@[i;T;;V;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;Ao;B;CT;Di;Ei;!@;"I"#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; ; F; ;,;;;I"Pathname#hash;F;[;[[@[i;T;;U;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @<;@F;Ao;B;CT;Di;Ei;!@;"I"^static VALUE path_hash(VALUE self) { return ST2FIX(rb_str_hash(get_strpath(self))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#to_s;F;[;[[@[i;T;;h;0;[;{;IC;"mReturn the path as a String. to_path is implemented so Pathname objects are usable with File.open, etc. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @J;[;I"@return [String];T;0; @J;@F;Mi;N0;[; @Jo;H ;II" overload;F;J0;;;K0;#I" to_path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @J;[;I"@return [String];T;0; @J;@F;Mi;N0;[; @J;[;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; @J;@F;Ao;B;CT;Di;Ei;!@;"I"Ustatic VALUE path_to_s(VALUE self) { return rb_obj_dup(get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#to_path;F;[;[[@[i;T;;;0;[;{;IC;"mReturn the path as a String. to_path is implemented so Pathname objects are usable with File.open, etc. ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @r;[;I"@return [String];T;0; @r;@F;Mi;N0;[; @ro;H ;II" overload;F;J0;;;K0;#I" to_path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @r;[;I"@return [String];T;0; @r;@F;Mi;N0;[; @r;[;@n;0; @r;@F;Ao;B;CT;Di;Ei;!@;"I"Ustatic VALUE path_to_s(VALUE self) { return rb_obj_dup(get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#inspect;F;[;[[@[i;T;;i;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#sub;F;[[@0;[[@[i ;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; @;@F;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;,;;;I"Pathname#sub_ext;F;[[I" repl;T0;[[@[i";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; @;@F;Ao;B;CT;Di;Ei ;!@;"I"Mstatic 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); OBJ_INFECT(str2, str); return rb_class_new_instance(1, &str2, rb_obj_class(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#realpath;F;[[@0;[[@[iG;T;;;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; @ƨ;@F;Ao;B;CT;Di=;EiE;!@;"I"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; ; F; ;,;;;I"Pathname#realdirpath;F;[[@0;[[@[iW;T;;;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;Ao;B;CT;DiP;EiU;!@;"I"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; ; F; ;,;;;I"Pathname#each_line;F;[[@0;[[@[ij;T;;w;0;[;{;IC;"MIterates over each line in the file and yields a String object for each. ;T;[ o;H ;II" overload;F;J0;;w;K0;#I"each_line;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @;[;I"@yield [line];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;w;K0;#I"$each_line(sep=$/ [, open_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I" @yield [line] @return [nil];T;0; @;@F;Mi;N0;[[I"sep;TI"$/[, open_args];T; @o;H ;II" overload;F;J0;;w;K0;#I"#each_line(limit [, open_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I" @yield [line] @return [nil];T;0; @;@F;Mi;N0;[[I"limit[, open_args];T0; @o;H ;II" overload;F;J0;;w;K0;#I"(each_line(sep, limit [, open_args]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I" @yield [line] @return [nil];T;0; @;@F;Mi;N0;[[I"sep;T0[I"limit[, open_args];T0; @o;H ;II" overload;F;J0;;w;K0;#I"each_line(...);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di`;Ein;!@;"I"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(rb_cFile, id_foreach, 1+n, args, 0, 0); } else { return rb_funcallv(rb_cFile, id_foreach, 1+n, args); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#read;F;[[@0;[[@[i;T;;;0;[;{;IC;"YReturns all data from the file, or the first +N+ bytes if specified. See File.read. ;T;[o;H ;II" overload;F;J0;;;K0;#I"read([length [, offset]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[[I"[length [, offset]];T0; @Io;H ;II" overload;F;J0;;;K0;#I")read([length [, offset]], open_args);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @I;[;I"@return [String];T;0; @I;@F;Mi;N0;[[I"[length [, offset]];T0[I"open_args;T0; @I;[;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; @I;@F;Ao;B;CT;Diz;Ei;!@;"I"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(rb_cFile, id_read, 1+n, args); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#binread;F;[[@0;[[@[i;T;;;0;[;{;IC;"[Returns all the bytes from the file, or the first +N+ if specified. See File.binread. ;T;[o;H ;II" overload;F;J0;;;K0;#I"!binread([length [, offset]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @x;[;I"@return [String];T;0; @x;@F;Mi;N0;[[I"[length [, offset]];T0; @x;[;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; @x;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#readlines;F;[[@0;[[@[i;T;;;0;[;{;IC;">Returns all the lines from the file. See File.readlines. ;T;[o;H ;II" overload;F;J0;;;K0;#I"$readlines(sep=$/ [, open_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"sep;TI"$/[, open_args];T; @o;H ;II" overload;F;J0;;;K0;#I"#readlines(limit [, open_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"limit[, open_args];T0; @o;H ;II" overload;F;J0;;;K0;#I"(readlines(sep, limit [, open_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"sep;T0[I"limit[, open_args];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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(rb_cFile, id_readlines, 1+n, args); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#write;F;[[@0;[[@[i;T;;;0;[;{;IC;"4Writes +contents+ to the file. See File.write. ;T;[o;H ;II" overload;F;J0;;;K0;#I"write(string, [offset] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @թ;[;I"@return [Fixnum];T;0; @թ;@F;Mi;N0;[[I" string;T0[I" [offset];T0; @թo;H ;II" overload;F;J0;;;K0;#I"(write(string, [offset], open_args );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @թ;[;I"@return [Fixnum];T;0; @թ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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(rb_cFile, id_write, 1+n, args); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#binwrite;F;[[@0;[[@[i;T;;;0;[;{;IC;"RWrites +contents+ to the file, opening it in binary mode. See File.binwrite. ;T;[o;H ;II" overload;F;J0;;;K0;#I" binwrite(string, [offset] );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[[I" string;T0[I" [offset];T0; @o;H ;II" overload;F;J0;;;K0;#I"+binwrite(string, [offset], open_args );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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(rb_cFile, id_binwrite, 1+n, args); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#sysopen;F;[[@0;[[@[i;T;;;0;[;{;IC;"See IO.sysopen. ;T;[o;H ;II" overload;F;J0;;;K0;#I"sysopen([mode, [perm]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;;[;I"@return [Fixnum];T;0; @;;@F;Mi;N0;[[I"[mode, [perm]];T0; @;;[;I"LSee IO.sysopen. @overload sysopen([mode, [perm]]) @return [Fixnum];T;0; @;;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#atime;F;[;[[@[i;T;;Z;0;[;{;IC;"@Returns the last access time for the file. See File.atime. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" ->(time);T;IC;";T;[;[;I";T;0; @Y;@F;Mi;N0;[; @Y;[;I"UReturns the last access time for the file. See File.atime. @overload ->(time);T;0; @Y;@F;Ao;B;CT;Di;Ei;!@;"I"mstatic VALUE path_atime(VALUE self) { return rb_funcall(rb_cFile, id_atime, 1, get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#birthtime;F;[;[[@[i ;T;;\;0;[;{;IC;"}Returns the birth time for the file. If the platform doesn't have birthtime, raises NotImplementedError. See File.birthtime. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" ->(time);T;IC;";T;[;[;I";T;0; @o;@F;Mi;N0;[; @o;[;I"Returns the birth time for the file. If the platform doesn't have birthtime, raises NotImplementedError. See File.birthtime. @overload ->(time);T;0; @o;@F;Ao;B;CT;Di;Ei ;!@;"I"ustatic VALUE path_birthtime(VALUE self) { return rb_funcall(rb_cFile, id_birthtime, 1, get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#ctime;F;[;[[@[i;T;;C;0;[;{;IC;"eReturns the last change time, using directory information, not the file itself. See File.ctime. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" ->(time);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"zReturns the last change time, using directory information, not the file itself. See File.ctime. @overload ->(time);T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"mstatic VALUE path_ctime(VALUE self) { return rb_funcall(rb_cFile, id_ctime, 1, get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#mtime;F;[;[[@[i,;T;;[;0;[;{;IC;"AReturns the last modified time of the file. See File.mtime. ;T;[o;H ;II" overload;F;J0;;<;K0;#I" ->(time);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"VReturns the last modified time of the file. See File.mtime. @overload ->(time);T;0; @;@F;Ao;B;CT;Di$;Ei);!@;"I"mstatic VALUE path_mtime(VALUE self) { return rb_funcall(rb_cFile, id_mtime, 1, get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#chmod;F;[[I" mode;T0;[[@[i:;T;;x;0;[;{;IC;"/Changes file permissions. See File.chmod. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"->(integer);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"GChanges file permissions. See File.chmod. @overload ->(integer);T;0; @;@F;Ao;B;CT;Di2;Ei7;!@;"I"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; ; F; ;,;;;I"Pathname#lchmod;F;[[I" mode;T0;[[@[iH;T;;z;0;[;{;IC;"RSame as Pathname.chmod, but does not follow symbolic links. See File.lchmod. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"->(integer);T;IC;";T;[;[;I";T;0; @ɪ;@F;Mi;N0;[; @ɪ;[;I"jSame as Pathname.chmod, but does not follow symbolic links. See File.lchmod. @overload ->(integer);T;0; @ɪ;@F;Ao;B;CT;Di@;EiE;!@;"I"|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; ; F; ;,;;;I"Pathname#chown;F;[[I" owner;T0[I" group;T0;[[@[iV;T;;y;0;[;{;IC;"9Change owner and group of the file. See File.chown. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"->(integer);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"QChange owner and group of the file. See File.chown. @overload ->(integer);T;0; @;@F;Ao;B;CT;DiN;EiS;!@;"I"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; ; F; ;,;;;I"Pathname#lchown;F;[[I" owner;T0[I" group;T0;[[@[id;T;;{;0;[;{;IC;"RSame as Pathname.chown, but does not follow symbolic links. See File.lchown. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"->(integer);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"jSame as Pathname.chown, but does not follow symbolic links. See File.lchown. @overload ->(integer);T;0; @;@F;Ao;B;CT;Di\;Eia;!@;"I"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; ; F; ;,;;;I"Pathname#fnmatch;F;[[@0;[[@[is;T;;L;0;[;{;IC;"PReturn +true+ if the receiver matches the given pattern. See File.fnmatch. ;T;[o;H ;II" overload;F;J0;;L;K0;#I"fnmatch(pattern, [flags]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" pattern;T0[I" [flags];T0; @o;H ;II" overload;F;J0;;M;K0;#I"fnmatch?(pattern, [flags]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" pattern;T0[I" [flags];T0; @;[;I"Return +true+ if the receiver matches the given pattern. See File.fnmatch. @overload fnmatch(pattern, [flags]) @return [String] @overload fnmatch?(pattern, [flags]) @return [String];T;0; @;@F;Ao;B;CT;Dij;Eir;!@;"I"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; ; F; ;,;;;I"Pathname#fnmatch?;F;[[@0;[[@[is;T;;M;0;[;{;IC;"PReturn +true+ if the receiver matches the given pattern. See File.fnmatch.;T;[o;H ;II" overload;F;J0;;L;K0;#I"fnmatch(pattern, [flags]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @F;[;I"@return [String];T;0; @F;@F;Mi;N0;[[I" pattern;T0[I" [flags];T0; @Fo;H ;II" overload;F;J0;;M;K0;#I"fnmatch?(pattern, [flags]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @F;[;I"@return [String];T;0; @F;@F;Mi;N0;[[I" pattern;T0[I" [flags];T0; @F;[;@B;0; @F;@F;Ao;B;CT;Dij;Eir;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#ftype;F;[;[[@[i;T;;];0;[;{;IC;"HReturns "type" of file ("file", "directory", etc). See File.ftype. ;T;[o;H ;II" overload;F;J0;;<;K0;#I"->(string);T;IC;";T;[;[;I";T;0; @v;@F;Mi;N0;[; @v;[;I"_Returns "type" of file ("file", "directory", etc). See File.ftype. @overload ->(string);T;0; @v;@F;Ao;B;CT;Di~;Ei;!@;"I"mstatic VALUE path_ftype(VALUE self) { return rb_funcall(rb_cFile, id_ftype, 1, get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#make_link;F;[[I"old;T0;[[@[i;T;:make_link;0;[;{;IC;"7Creates a hard link at _pathname_. See File.link. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"make_link(old);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"old;T0; @;[;I"RCreates a hard link at _pathname_. See File.link. @overload make_link(old);T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"{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; ; F; ;,;;;I"Pathname#open;F;[[@0;[[@[i;T;;;0;[;{;IC;";Opens the file for reading or writing. See File.open. ;T;[;[;I"Truncates the file to +length+ bytes. See File.truncate. ;T;[;[;I"?Truncates the file to +length+ bytes. See File.truncate. ;T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#utime;F;[[I" atime;T0[I" mtime;T0;[[@[i;T;;w;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#basename;F;[[@0;[[@[i;T;;;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; @+;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#dirname;F;[;[[@[i;T;;;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; @:;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#extname;F;[;[[@[i";T;;;0;[;{;IC;"5Returns the file's extension. See File.extname. ;T;[;[;I"6Returns the file's extension. See File.extname. ;T;0; @H;@F;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;,;;;I"Pathname#expand_path;F;[[@0;[[@[i.;T;;;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; @V;@F;Ao;B;CT;Di);Ei,;!@;"I"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; ; F; ;,;;;I"Pathname#split;F;[;[[@[i?;T;;H;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; @e;@F;Ao;B;CT;Di:;Ei=;!@;"I"static VALUE path_split(VALUE self) { VALUE str = get_strpath(self); VALUE ary, dirname, basename; ary = rb_funcall(rb_cFile, id_split, 1, str); ary = rb_check_array_type(ary); 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; ; F; ;,;;;I"Pathname#blockdev?;F;[;[[@[iP;T;;n;0;[;{;IC;"See FileTest.blockdev?.;T;[o;L ;II" return;F;J@;0;K[@; @s;[;I"See FileTest.blockdev?. ;T;0; @s;@F;Ao;B;CT;DiM;EiN;Mi;!@;"I"{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; ; F; ;,;;;I"Pathname#chardev?;F;[;[[@[iY;T;;o;0;[;{;IC;"See FileTest.chardev?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.chardev?. ;T;0; @;@F;Ao;B;CT;DiV;EiW;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#executable?;F;[;[[@[ib;T;;e;0;[;{;IC;"See FileTest.executable?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.executable?. ;T;0; @;@F;Ao;B;CT;Di_;Ei`;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#executable_real?;F;[;[[@[ik;T;;f;0;[;{;IC;"#See FileTest.executable_real?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"$See FileTest.executable_real?. ;T;0; @;@F;Ao;B;CT;Dih;Eii;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#exist?;F;[;[[@[it;T;;s;0;[;{;IC;"See FileTest.exist?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.exist?. ;T;0; @;@F;Ao;B;CT;Diq;Eir;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#grpowned?;F;[;[[@[i};T;;j;0;[;{;IC;"See FileTest.grpowned?.;T;[o;L ;II" return;F;J@;0;K[@; @Ȭ;[;I"See FileTest.grpowned?. ;T;0; @Ȭ;@F;Ao;B;CT;Diz;Ei{;Mi;!@;"I"{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; ; F; ;,;;;I"Pathname#directory?;F;[;[[@[i;T;;^;0;[;{;IC;"See FileTest.directory?.;T;[o;L ;II" return;F;J@;0;K[@; @٬;[;I"See FileTest.directory?. ;T;0; @٬;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"}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; ; F; ;,;;;I"Pathname#file?;F;[;[[@[i;T;;g;0;[;{;IC;"See FileTest.file?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.file?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#pipe?;F;[;[[@[i;T;;k;0;[;{;IC;"See FileTest.pipe?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.pipe?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#socket?;F;[;[[@[i;T;;m;0;[;{;IC;"See FileTest.socket?.;T;[o;L ;II" return;F;J@;0;K[@; @ ;[;I"See FileTest.socket?. ;T;0; @ ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#owned?;F;[;[[@[i;T;;i;0;[;{;IC;"See FileTest.owned?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.owned?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#readable?;F;[;[[@[i;T;;_;0;[;{;IC;"See FileTest.readable?.;T;[o;L ;II" return;F;J@;0;K[@; @.;[;I"See FileTest.readable?. ;T;0; @.;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"{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; ; F; ;,;;;I"Pathname#world_readable?;F;[;[[@[i;T;;a;0;[;{;IC;""See FileTest.world_readable?.;T;[o;L ;II" return;F;J@;0;K[@; @?;[;I"#See FileTest.world_readable?. ;T;0; @?;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#readable_real?;F;[;[[@[i;T;;`;0;[;{;IC;"!See FileTest.readable_real?.;T;[o;L ;II" return;F;J@;0;K[@; @P;[;I""See FileTest.readable_real?. ;T;0; @P;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#setuid?;F;[;[[@[i;T;;p;0;[;{;IC;"See FileTest.setuid?.;T;[o;L ;II" return;F;J@;0;K[@; @a;[;I"See FileTest.setuid?. ;T;0; @a;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#setgid?;F;[;[[@[i;T;;q;0;[;{;IC;"See FileTest.setgid?.;T;[o;L ;II" return;F;J@;0;K[@; @r;[;I"See FileTest.setgid?. ;T;0; @r;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#size;F;[;[[@[i;T;;;0;[;{;IC;"See FileTest.size. ;T;[;[;I"See FileTest.size. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"ostatic VALUE path_size(VALUE self) { return rb_funcall(rb_mFileTest, id_size, 1, get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#size?;F;[;[[@[i;T;;h;0;[;{;IC;"See FileTest.size?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.size?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#sticky?;F;[;[[@[i;T;;r;0;[;{;IC;"See FileTest.sticky?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.sticky?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#symlink?;F;[;[[@[i;T;;l;0;[;{;IC;"See FileTest.symlink?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.symlink?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#writable?;F;[;[[@[i;T;;b;0;[;{;IC;"See FileTest.writable?.;T;[o;L ;II" return;F;J@;0;K[@; @ĭ;[;I"See FileTest.writable?. ;T;0; @ĭ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"{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; ; F; ;,;;;I"Pathname#world_writable?;F;[;[[@[i ;T;;d;0;[;{;IC;""See FileTest.world_writable?.;T;[o;L ;II" return;F;J@;0;K[@; @խ;[;I"#See FileTest.world_writable?. ;T;0; @խ;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#writable_real?;F;[;[[@[i;T;;c;0;[;{;IC;"!See FileTest.writable_real?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I""See FileTest.writable_real?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#zero?;F;[;[[@[i;T;;;0;[;{;IC;"See FileTest.zero?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"See FileTest.zero?. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Pathname#empty?;F;[;[[@[i*;T;;;0;[;{;IC;"BTests the file is empty. See Dir#empty? and FileTest.empty?.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"CTests the file is empty. See Dir#empty? and FileTest.empty?. ;T;0; @;@F;Ao;B;CT;Di%;Ei(;Mi;!@;"I"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; ; F; ;;;;I"Pathname.glob;F;[[@0;[[@[iC;T;;;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;Ao;B;CT;Di;;EiA;!@;"I"static VALUE path_s_glob(int argc, VALUE *argv, VALUE klass) { VALUE args[2]; int n; n = rb_scan_args(argc, argv, "11", &args[0], &args[1]); if (rb_block_given_p()) { return rb_block_call(rb_cDir, id_glob, n, args, s_glob_i, klass); } else { VALUE ary; long i; ary = rb_funcallv(rb_cDir, id_glob, n, args); 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; ; F; ;;;;I"Pathname.getwd;F;[;[[@[i;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; @(;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Pathname.pwd;F;[;[[@[i;T;;;0;[;{;IC;"Returns the current working directory as a Pathname. Pathname.getwd #=> # See Dir.getwd. ;T;[;[;@2;0; @6;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#glob;F;[[@0;[[@[ik;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; @C;@F;Ao;B;CT;Dib;Eii;!@;"I"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(rb_cDir, id_glob, n, args, glob_i, self); } else { VALUE ary; long i; ary = rb_funcallv(rb_cDir, id_glob, n, args); 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; ; F; ;,;;;I"Pathname#entries;F;[;[[@[i;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; @R;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#mkdir;F;[[@0;[[@[i;T;;;0;[;{;IC;"5Create the referenced directory. See Dir.mkdir. ;T;[;[;I"6Create the referenced directory. See Dir.mkdir. ;T;0; @`;@F;Ao;B;CT;Di;Ei;!@;"I"#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; ; F; ;,;;;I"Pathname#rmdir;F;[;[[@[i;T;;;0;[;{;IC;"5Remove the referenced directory. See Dir.rmdir. ;T;[;[;I"6Remove the referenced directory. See Dir.rmdir. ;T;0; @o;@F;Ao;B;CT;Di;Ei;!@;"I"lstatic VALUE path_rmdir(VALUE self) { return rb_funcall(rb_cDir, id_rmdir, 1, get_strpath(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Pathname#opendir;F;[;[[@[i;T;: opendir;0;[;{;IC;"3Opens the referenced directory. See Dir.open. ;T;[;[;I"4Opens the referenced directory. See Dir.open. ;T;0; @};@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#each_entry;F;[;[[@[i;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#unlink;F;[;[[@[i;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Pathname#delete;F;[;[[@[i;T;;p;0;[;{;IC;"dRemoves a file or directory, using File.unlink if +self+ is a file, or Dir.unlink as necessary. ;T;[;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@[i;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I" Pathname;F;1@ 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; @Ǯ;@F;Ao;B;CT;Dip;Eiu;!@Ů;"I"}static VALUE rb_digest_instance_bubblebabble(VALUE self) { return bubblebabble_str_new(rb_funcall(self, id_digest, 0)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Instance#update;F;[[I"str;T0;[[I"ext/digest/digest.c;Ti;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;H ;II" overload;F;J0;;;K0;#I"update(string);T;IC;";T;[;[;I";T;0; @֮;@F;Mi;N0;[[I" string;T0; @֮o;H ;II" overload;F;J0;;Q;K0;#I"<<(string);T;IC;";T;[;[;I";T;0; @֮;@F;Mi;N0;[[I" string;T0; @֮;[;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; @֮;@F;Ao;B;CT;Di;Ei;!@Ů;"I"static VALUE rb_digest_instance_update(VALUE self, VALUE str) { rb_digest_instance_method_unimpl(self, "update"); UNREACHABLE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Instance#<<;F;[[I"str;T0;[[@ݮi;T;;Q;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;H ;II" overload;F;J0;;;K0;#I"update(string);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0; @o;H ;II" overload;F;J0;;Q;K0;#I"<<(string);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@Ů;"I"static VALUE rb_digest_instance_update(VALUE self, VALUE str) { rb_digest_instance_method_unimpl(self, "update"); UNREACHABLE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Instance#finish;F;[;[[@ݮi;T;;;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;H ;II" overload;F;J0;;;K0;#I"instance_eval;T;IC;";T;[o;L ;II" yield;F;JI"[];T;0;K0; @;[;I"@yield [];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@Ů;"I"~static VALUE rb_digest_instance_finish(VALUE self) { rb_digest_instance_method_unimpl(self, "finish"); UNREACHABLE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Instance#reset;F;[;[[@ݮi;T;;;0;[;{;IC;"yResets the digest to the initial state and returns self. This method is overridden by each implementation subclass. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reset;T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[; @7;[;I"Resets the digest to the initial state and returns self. This method is overridden by each implementation subclass. @overload reset;T;0; @7;@F;Ao;B;CT;Di;Ei;!@Ů;"I"|static VALUE rb_digest_instance_reset(VALUE self) { rb_digest_instance_method_unimpl(self, "reset"); UNREACHABLE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"#Digest::Instance#digest_length;F;[;[[@ݮi;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;H ;II" overload;F;J0;; ;K0;#I"digest_length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @M;[;I"@return [Integer];T;0; @M;@F;Mi;N0;[; @M;[;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; @M;@F;Ao;B;CT;Di;Ei;!@Ů;"I"1static 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 INT2NUM(RSTRING_LEN(digest)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I""Digest::Instance#block_length;F;[;[[@ݮi;T;:block_length;0;[;{;IC;"hReturns the block length of the digest. This method is overridden by each implementation subclass. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"block_length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @h;[;I"@return [Integer];T;0; @h;@F;Mi;N0;[; @h;[;I"Returns the block length of the digest. This method is overridden by each implementation subclass. @overload block_length @return [Integer];T;0; @h;@F;Ao;B;CT;Di;Ei;!@Ů;"I"static VALUE rb_digest_instance_block_length(VALUE self) { rb_digest_instance_method_unimpl(self, "block_length"); UNREACHABLE; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Instance#==;F;[[I" other;T0;[[@ݮio;T;;S;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;H ;II" overload;F;J0;;S;K0;#I"==(another_digest_obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I"another_digest_obj;T0; @o;H ;II" overload;F;J0;;S;K0;#I"==(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;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; @;@F;Ao;B;CT;Die;Ein;!@Ů;"I"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; ; F; ;,;;;I"Digest::Instance#inspect;F;[;[[@ݮiR;T;;i;0;[;{;IC;"6Creates a printable version of the digest object. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"]Creates a printable version of the digest object. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;DiL;EiP;!@Ů;"I"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; ; F; ;,;;;I"Digest::Instance#new;F;[;[[@ݮi;T;; ;0;[;{;IC;"eReturns a new, initialized copy of the digest object. Equivalent to digest_obj.clone().reset(). ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new;T;IC;";T;[;[;I";T;0; @̯;@F;Mi;N0;[; @̯;[;I"uReturns a new, initialized copy of the digest object. Equivalent to digest_obj.clone().reset(). @overload new;T;0; @̯;@F;Ao;B;CT;Di;Ei;!@Ů;"I"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; ; F; ;,;;;I"Digest::Instance#digest;F;[[@0;[[@ݮi;T;;;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;H ;II" overload;F;J0;;;K0;#I" digest;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I"digest(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@Ů;"I"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; ; F; ;,;;;I"Digest::Instance#digest!;F;[;[[@ݮi ;T;: digest!;0;[;{;IC;"QReturns the resulting hash value and resets the digest to the initial state. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" digest!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;I"xReturns the resulting hash value and resets the digest to the initial state. @overload digest! @return [String];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@Ů;"I"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; ; F; ;,;;;I"Digest::Instance#hexdigest;F;[[@0;[[@ݮi;T;;;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;H ;II" overload;F;J0;;;K0;#I"hexdigest;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @(;[;I"@return [String];T;0; @(;@F;Mi;N0;[; @(o;H ;II" overload;F;J0;;;K0;#I"hexdigest(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @(;[;I"@return [String];T;0; @(;@F;Mi;N0;[[I" string;T0; @(;[;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; @(;@F;Ao;B;CT;Di;Ei;!@Ů;"I"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; ; F; ;,;;;I" Digest::Instance#hexdigest!;F;[;[[@ݮi7;T;:hexdigest!;0;[;{;IC;"gReturns the resulting hash value in a hex-encoded form and resets the digest to the initial state. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"hexdigest!;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @S;[;I"@return [String];T;0; @S;@F;Mi;N0;[; @S;[;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; @S;@F;Ao;B;CT;Di0;Ei5;!@Ů;"I"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; ; F; ;,;;;I"Digest::Instance#to_s;F;[;[[@ݮiF;T;;h;0;[;{;IC;"$Returns digest_obj.hexdigest(). ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @n;[;I"@return [String];T;0; @n;@F;Mi;N0;[; @n;[;I"HReturns digest_obj.hexdigest(). @overload to_s @return [String];T;0; @n;@F;Ao;B;CT;Di@;EiD;!@Ů;"I"gstatic VALUE rb_digest_instance_to_s(VALUE self) { return rb_funcall(self, id_hexdigest, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Instance#length;F;[;[[@ݮi;T;;;0;[;{;IC;"(Returns digest_obj.digest_length(). ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"rReturns digest_obj.digest_length(). @overload length @return [Integer] @overload size @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@Ů;"I"mstatic VALUE rb_digest_instance_length(VALUE self) { return rb_funcall(self, id_digest_length, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Instance#size;F;[;[[@ݮi;T;;;0;[;{;IC;"(Returns digest_obj.digest_length(). ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@Ů;"I"mstatic VALUE rb_digest_instance_length(VALUE self) { return rb_funcall(self, id_digest_length, 0); };T;#I"static VALUE;T;$T;&@Ů;'IC;[;&@Ů;(IC;[;&@Ů;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ݮi[@̮i[@ݮi;T;: Instance;;0;;;[;{;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; @Ů;@F;Ao;B;CT;Di;Ei;Mi;!@î;I"Digest::Instance;Fo; ;IC;[ o; ; F; ;;;;I"Digest::Class.bubblebabble;F;[[@0;[[@̮ij;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; @;@F;Ao;B;CT;Dic;Eih;!@;"I"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; ; F; ;,;;;I"Digest::Class#initialize;F;[;[[@ݮi;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Gstatic VALUE rb_digest_class_init(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Digest::Class.digest;F;[[@0;[[@ݮi;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;H ;II" overload;F;J0;:Digest::Class.digest;K0;#I".Digest::Class.digest(string, *parameters);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" string;T0[I"*parameters;T0; @ ;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Digest::Class.hexdigest;F;[[@0;[[@ݮi;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;H ;II" overload;F;J0;:Digest::Class.hexdigest;K0;#I"+Digest::Class.hexdigest(string[, ...]);T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[[I"string[, ...];T0; @%;[;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; @%;@F;Ao;B;CT;Di;Ei;!@;"I"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;&@;'IC;[;&@;(IC;[@Ů;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ݮi[@̮i[@ݮi ;T;;|;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!@î;I"Digest::Class;F;1@ 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; @Q;@F;N0;!@î;"I"lstatic VALUE rb_digest_s_bubblebabble(VALUE klass, VALUE str) { return bubblebabble_str_new(str); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Digest.bubblebabble;F;@S;@V;T;; ;0;@X;{;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;Ao;B;CT;DiV;Ei[;Mi;!@î;"@^;#@_;$To; ;IC;[;&@h;'IC;[;&@h;(IC;[;&@h;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/digest/sha1/sha1init.c;Ti[@siE;T;: SHA1;;0;;;[;{;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; @h;@F;Ao;B;CT;Di;Ei5;!o;2 ;30;40;50;;;!@;7@î;F0;I"Digest::SHA1;F;1o;2 ;3@;4I"Digest::Base;T;50;: Base;!o;2 ;30;40;50;;;!@;7@î;F0;7o; ;IC;[ o; ; F; ;,;;;I"!Digest::Base#initialize_copy;F;[[I"obj;T0;[[@ݮid;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Dic;Eic;!@;"I"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_base_metadata(rb_obj_class(copy)); if (algo != get_digest_base_metadata(rb_obj_class(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; ; F; ;,;;;I"Digest::Base#reset;F;[;[[@ݮi~;T;;;0;[;{;IC;"=Reset the digest to its initial state and return +self+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" reset;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"OReset the digest to its initial state and return +self+. @overload reset;T;0; @;@F;Ao;B;CT;Diy;Ei|;!@;"I"static VALUE rb_digest_base_reset(VALUE self) { rb_digest_metadata_t *algo; void *pctx; algo = get_digest_base_metadata(rb_obj_class(self)); TypedData_Get_Struct(self, void, &digest_type, pctx); algo_init(algo, pctx); return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Base#update;F;[[I"str;T0;[[@ݮi;T;;;0;[;{;IC;">Update the digest using given _string_ and return +self+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"update(string);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0; @o;H ;II" overload;F;J0;;Q;K0;#I"<<(string);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"nUpdate the digest using given _string_ and return +self+. @overload update(string) @overload <<(string);T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"sstatic VALUE rb_digest_base_update(VALUE self, VALUE str) { rb_digest_metadata_t *algo; void *pctx; algo = get_digest_base_metadata(rb_obj_class(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; ; F; ;,;;;I"Digest::Base#<<;F;[[I"str;T0;[[@ݮi;T;;Q;0;[;{;IC;">Update the digest using given _string_ and return +self+. ;T;[o;H ;II" overload;F;J0;;;K0;#I"update(string);T;IC;";T;[;[;I";T;0; @ͱ;@F;Mi;N0;[[I" string;T0; @ͱo;H ;II" overload;F;J0;;Q;K0;#I"<<(string);T;IC;";T;[;[;I";T;0; @ͱ;@F;Mi;N0;[[I" string;T0; @ͱ;[;@ɱ;0; @ͱ;@F;Ao;B;CT;Di;Ei;!@;"I"sstatic VALUE rb_digest_base_update(VALUE self, VALUE str) { rb_digest_metadata_t *algo; void *pctx; algo = get_digest_base_metadata(rb_obj_class(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; ; F; ;,;;;I"Digest::Base#finish;F;[;[[@ݮi;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_digest_base_finish(VALUE self) { rb_digest_metadata_t *algo; void *pctx; VALUE str; algo = get_digest_base_metadata(rb_obj_class(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; ; F; ;,;;;I"Digest::Base#digest_length;F;[;[[@ݮi;T;; ;0;[;{;IC;"2Return the length of the hash value in bytes. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"digest_length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"`Return the length of the hash value in bytes. @overload digest_length @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_digest_base_digest_length(VALUE self) { rb_digest_metadata_t *algo; algo = get_digest_base_metadata(rb_obj_class(self)); return INT2NUM(algo->digest_len); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest::Base#block_length;F;[;[[@ݮi;T;; ;0;[;{;IC;"4Return the block length of the digest in bytes. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"block_length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"aReturn the block length of the digest in bytes. @overload block_length @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_digest_base_block_length(VALUE self) { rb_digest_metadata_t *algo; algo = get_digest_base_metadata(rb_obj_class(self)); return INT2NUM(algo->block_len); };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@ݮi[@ݮi;T;; ;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!@;I"Digest::Base;F;1@;F;o; ;IC;[;&@F;'IC;[;&@F;(IC;[;&@F;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/digest/md5/md5init.c;Ti[@QiC;T;:MD5;;0;;;[;{;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;Ao;B;CT;Di;Ei3;!o;2 ;30;40;50;;;!@;7@î;F0;I"Digest::MD5;F;1o;2 ;3@;4I"Digest::Base;T;50;; ;!@;7@;F;o; ;IC;[;&@^;'IC;[;&@^;(IC;[;&@^;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"#ext/digest/rmd160/rmd160init.c;Ti[@iiA;T;: RMD160;;0;;;[;{;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; @^;@F;Ao;B;CT;Di;Ei1;!o;2 ;30;40;50;;;!@;7@î;F0;I"Digest::RMD160;F;1o;2 ;3@;4I"Digest::Base;T;50;; ;!@;7@;F;@o; ; F; ;,;;;I"Digest#hexencode;F;[[I"str;T0;[[@ݮi;T;:hexencode;0;[;{;IC;"9Generates a hex-encoded version of a given _string_. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"hexencode(string);T;IC;";T;[;[;I";T;0; @v;@F;Mi;N0;[[I" string;T0; @v;[;I"VGenerates a hex-encoded version of a given _string_. @overload hexencode(string) ;T;0; @v;@F;N0;!@î;"I"fstatic VALUE rb_digest_s_hexencode(VALUE klass, VALUE str) { return hexencode_str_new(str); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Digest.hexencode;F;@x;@{;T;; ;0;@};{;IC;"9Generates a hex-encoded version of a given _string_.;T;[o;H ;II" overload;F;J0;; ;K0;#I"hexencode(string);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"WGenerates a hex-encoded version of a given _string_. @overload hexencode(string);T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@î;"@;#@;$To; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Ki;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@î;I"Digest::DigestError;F;1@FKo; ; F; ;,;;;I"Digest#initialize;F;[[@0;[[@Ki{;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(string [, data]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Digest;T; @;[;I"@return [Digest];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dij;Eiy;!@î;"I"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; ; F; ;,;;;I"Digest#initialize_copy;F;[[I" other;T0;[[@Ki;T;;];0;[;{;IC;" ;T;[;[;@;0; @в;!@î;"I"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; ; F; ;,;;;I"Digest#reset;F;[;[[@Ki;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;H ;II" overload;F;J0;;;K0;#I" reset;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @޲;[;I"@return [self];T;0; @޲;@F;Mi;N0;[; @޲;[;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;Ao;B;CT;Di;Ei;!@î;"I"static VALUE ossl_digest_reset(VALUE self) { EVP_MD_CTX *ctx; GetDigest(self, ctx); if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL) != 1) { ossl_raise(eDigestError, "Digest initialization failed."); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Digest#update;F;[[I" data;T0;[[@Ki;T;;;0;[;{;IC;"qNot 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::SHA256.new digest.update('First input') digest << 'Second input' # equivalent to digest.update('Second input') result = digest.digest ;T;[o;H ;II" overload;F;J0;;;K0;#I"update(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @;[;I"@return [aString];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;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::SHA256.new digest.update('First input') digest << 'Second input' # equivalent to digest.update('Second input') result = digest.digest @overload update(string) @return [aString];T;0; o; ; F; ;,;;;I"Digest#<<;F;[;[[@Ki;F;;Q;;0;[;{;@;!@î;"I"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;Ao;B;CT;Di;Ei;!@î;"I"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@o; ; F; ;,;;;I"Digest#finish;F;[[@0;[[@Ki;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" finish;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" aString;T; @ ;[;I"@return [aString];T;0; @ ;@F;Mi;N0;[; @ ;[;I"+ @overload finish @return [aString];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@î;"I"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; ; F; ;,;;;I"Digest#digest_length;F;[;[[@Ki;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::SHA1.new puts digest.digest_length # => 20 ;T;[o;H ;II" overload;F;J0;; ;K0;#I"digest_length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @<;[;I"@return [Integer];T;0; @<;@F;Mi;N0;[; @<;[;I"Returns the output size of the digest, i.e. the length in bytes of the final message digest result. === Example digest = OpenSSL::Digest::SHA1.new puts digest.digest_length # => 20 @overload digest_length @return [Integer];T;0; @<;@F;Ao;B;CT;Di ;Ei;!@î;"I"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; ; F; ;,;;;I"Digest#block_length;F;[;[[@Ki,;T;; ;0;[;{;IC;"5Returns 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::SHA1.new puts digest.block_length # => 64 ;T;[o;H ;II" overload;F;J0;; ;K0;#I"block_length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @W;[;I"@return [Integer];T;0; @W;@F;Mi;N0;[; @W;[;I"bReturns 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::SHA1.new puts digest.block_length # => 64 @overload block_length @return [Integer];T;0; @W;@F;Ao;B;CT;Di;Ei*;!@î;"I"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; ; F; ;,;;;I"Digest#name;F;[;[[@Ki;T;;>;0;[;{;IC;"~Returns the sn of this Digest algorithm. === Example digest = OpenSSL::Digest::SHA512.new puts digest.name # => SHA512 ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @r;[;I"@return [String];T;0; @r;@F;Mi;N0;[; @r;[;I"Returns the sn of this Digest algorithm. === Example digest = OpenSSL::Digest::SHA512.new puts digest.name # => SHA512 @overload name @return [String];T;0; @r;@F;Ao;B;CT;Di;Ei;!@î;"I"static VALUE ossl_digest_name(VALUE self) { EVP_MD_CTX *ctx; GetDigest(self, ctx); return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx))); };T;#I"static VALUE;T;$T;&@î;'IC;[;&@î;(IC;[;&@î;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@;;.[;[ [@ݮi![@̮i[@si@[@Qi>[@ii<[@ݮi;T;;;;0;;;[;{;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; @î;@F;Ao;B;CT;Di!;Eib;Mi;!@;I" Digest;Fo; ;IC;[#o; ;IC;[o; ; F; ;;;;I"Syslog::Constants.included;F;[[I" target;T0;[[I"ext/syslog/syslog.c;Ti;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"}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;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;: Option;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I"Syslog::Option;Fo; ;IC;[;&@ɳ;'IC;[;&@ɳ;(IC;[;&@ɳ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;: Facility;;0;;;[;{;IC;" ;T;[;[;@;0; @ɳ;!@;I"Syslog::Facility;Fo; ;IC;[;&@ڳ;'IC;[;&@ڳ;(IC;[;&@ڳ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;: Level;;0;;;[;{;IC;" ;T;[;[;@;0; @ڳ;!@;I"Syslog::Level;F;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;;K;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I"Syslog::Constants;F@@ɳ@ڳo; ;IC;[o; ; F; ;,;;;I"Syslog::Macros#LOG_MASK;F;[;[;F;: LOG_MASK;;0;[;{;IC;"Syslog macros ;T;[;[;I"Syslog macros;T;0; @;@F;Ao;B;CT;DiD;EiD;!@;$To; ; F; ;,;;;I"Syslog::Macros#LOG_UPTO;F;[[I"pri;T0;[[@i;T;: LOG_UPTO;0;[;{;IC;"[Generates a mask value for priority levels at or below the level specified. See #mask= ;T;[o;H ;II" overload;F;J0;; ;K0;#I"LOG_UPTO(priority_level);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;;;;I"Syslog::Macros.included;F;[[I" target;T0;[[@i;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"}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;-{;.[;[[@i;F;: Macros;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"Syslog::Macros;Fo; ; F; ;,;;;I"Syslog#open;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"#open(ident, options, facility);T;IC;";T;[;[;I";T;0; @<;@F;Mi;N0;[[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;N0;!@;"I"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); rb_check_safe_obj(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; ; T; ;;;;I"Syslog.open;F;@>;@@;T;;;0;@B;{;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;H ;II" overload;F;J0;;;K0;#I"#open(ident, options, facility);T;IC;";T;[;[;I";T;0; @X;@F;Mi;N0;[[I" ident;T0[I" options;T0[I" facility;T0; @X;[;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; @X;@F;Ao;B;CT;DiM;Ei;Mi;!@;"@V;#@W;$To; ; F; ;,;;;I"Syslog#reopen;F;[[@0;[[@i;T;;;0;[;{;IC;"`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). ;T;[o;H ;II" overload;F;J0;;;K0;#I"%reopen(ident, options, facility);T;IC;";T;[;[;I";T;0; @n;@F;Mi;N0;[[I" ident;T0[I" options;T0[I" facility;T0; @n;[;I":yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). @overload reopen(ident, options, facility) ;T;0; @n;@F;N0;!@;"I"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; ; T; ;;;;I"Syslog.reopen;F;@p;@r;T;;;0;@t;{;IC;"`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open().;T;[o;H ;II" overload;F;J0;;;K0;#I"%reopen(ident, options, facility);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Syslog#open!;F;[[@0;[[@i;T;: open!;0;[;{;IC;"`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). ;T;[o;H ;II" overload;F;J0;;;K0;#I"%reopen(ident, options, facility);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"Syslog.open!;F;@;@;T;; ;0;@;{;IC;"`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open().;T;[o;H ;II" overload;F;J0;;;K0;#I"%reopen(ident, options, facility);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" ident;T0[I" options;T0[I" facility;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Syslog#opened?;F;[;[[@i;T;: opened?;0;[;{;IC;"(Returns true if the syslog is open. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" opened?;T;IC;";T;[;[;I";T;0; @Ѵ;@F;Mi;N0;[; @Ѵo;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Ѵ;[;I"NReturns true if the syslog is open. @overload opened? @return [Boolean] ;T;0; @Ѵ;@F;N0;!@;"I"[static VALUE mSyslog_isopen(VALUE self) { return syslog_opened ? Qtrue : Qfalse; };T;#I",static VALUE mSyslog_isopen(VALUE self);T;$To; ; T; ;;;;I"Syslog.opened?;F;@Ӵ;@Դ;T;; ;0;@ִ;{;IC;"(Returns true if the syslog is open.;T;[o;H ;II" overload;F;J0;; ;K0;#I" opened?;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;L ;II" return;F;J@;0;K[@; @;[;I"Returns an inspect() string summarizing the object state. ;T;[;[;I"?Returns an inspect() string summarizing the object state. ;T;0; @ĵ;@F;Ao;B;CT;DiC;EiD;!@;"I"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; ; F; ;,;;;I"Syslog#instance;F;[;[[@iV;T;;,;0;[;{;IC;".Returns self, for backward compatibility. ;T;[;[;I".Returns self, for backward compatibility.;T;0; @ҵ;@F;N0;!@;"I"Cstatic VALUE mSyslog_instance(VALUE self) { return self; };T;#I".static VALUE mSyslog_instance(VALUE self);T;$To; ; T; ;;;;I"Syslog.instance;F;@Ե;@յ;T;;,;0;@׵;{;IC;".Returns self, for backward compatibility.;T;[;[;I"/Returns self, for backward compatibility. ;T;0; @ߵ;@F;Ao;B;CT;DiT;EiU;Mi;!@;"@ݵ;#@޵;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;: Syslog;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I" Syslog;Fo; ;IC;[Io; ;IC;[o; ; F; ;,;;;I"Zlib::ZStream#avail_out;F;[;[[I"ext/zlib/zlib.c;TiE;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;Ao;B;CT;DiA;EiC;!@;"I"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; ; F; ;,;;;I"Zlib::ZStream#avail_out=;F;[[I" size;T0;[[@iS;T;:avail_out=;0;[;{;IC;"Allocates +size+ bytes of free space in the output buffer. If there are more than +size+ bytes already in the buffer, the buffer is truncated. Because free space is allocated automatically, you usually don't need to use this method. ;T;[;[;I"Allocates +size+ bytes of free space in the output buffer. If there are more than +size+ bytes already in the buffer, the buffer is truncated. Because free space is allocated automatically, you usually don't need to use this method. ;T;0; @ ;@F;Ao;B;CT;DiM;EiQ;!@;"I"static VALUE rb_zstream_set_avail_out(VALUE obj, VALUE size) { struct zstream *z = get_zstream(obj); zstream_expand_buffer_into(z, FIX2INT(size)); return size; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#avail_in;F;[;[[@i_;T;: avail_in;0;[;{;IC;"DReturns bytes of data in the input buffer. Normally, returns 0. ;T;[;[;I"EReturns bytes of data in the input buffer. Normally, returns 0. ;T;0; @;@F;Ao;B;CT;Di\;Ei];!@;"I"static VALUE rb_zstream_avail_in(VALUE obj) { struct zstream *z; TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z); return INT2FIX(NIL_P(z->input) ? 0 : (int)(RSTRING_LEN(z->input))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#total_in;F;[;[[@ij;T;: total_in;0;[;{;IC;"DReturns the total bytes of the input data to the stream. FIXME ;T;[;[;I"EReturns the total bytes of the input data to the stream. FIXME ;T;0; @';@F;Ao;B;CT;Dig;Eih;!@;"I"pstatic VALUE rb_zstream_total_in(VALUE obj) { return rb_uint2inum(get_zstream(obj)->stream.total_in); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#total_out;F;[;[[@is;T;:total_out;0;[;{;IC;"GReturns the total bytes of the output data from the stream. FIXME ;T;[;[;I"HReturns the total bytes of the output data from the stream. FIXME ;T;0; @5;@F;Ao;B;CT;Dip;Eiq;!@;"I"rstatic VALUE rb_zstream_total_out(VALUE obj) { return rb_uint2inum(get_zstream(obj)->stream.total_out); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#data_type;F;[;[[@i~;T;:data_type;0;[;{;IC;"Guesses the type of the data which have been inputed into the stream. The returned value is either BINARY, ASCII, or UNKNOWN. ;T;[;[;I"Guesses the type of the data which have been inputed into the stream. The returned value is either BINARY, ASCII, or UNKNOWN. ;T;0; @C;@F;Ao;B;CT;Diy;Ei|;!@;"I"mstatic VALUE rb_zstream_data_type(VALUE obj) { return INT2FIX(get_zstream(obj)->stream.data_type); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#adler;F;[;[[@i;T;: adler;0;[;{;IC;"#Returns the adler-32 checksum. ;T;[;[;I"$Returns the adler-32 checksum. ;T;0; @Q;@F;Ao;B;CT;Di;Ei;!@;"I"jstatic VALUE rb_zstream_adler(VALUE obj) { return rb_uint2inum(get_zstream(obj)->stream.adler); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#finished?;F;[;[[@i;T;:finished?;0;[;{;IC;",Returns true if the stream is finished.;T;[o;L ;II" return;F;J@;0;K[@; @_;[;I"-Returns true if the stream is finished. ;T;0; @_;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"ystatic VALUE rb_zstream_finished_p(VALUE obj) { return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#stream_end?;F;[;[[@i;T;:stream_end?;0;[;{;IC;",Returns true if the stream is finished.;T;[o;L ;II" return;F;J@;0;K[@; @p;[;@l;0; @p;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"ystatic VALUE rb_zstream_finished_p(VALUE obj) { return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#closed?;F;[;[[@i;T;;;0;[;{;IC;"*Returns true if the stream is closed.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"+Returns true if the stream is closed. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE rb_zstream_closed_p(VALUE obj) { struct zstream *z; TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z); return ZSTREAM_IS_READY(z) ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#ended?;F;[;[[@i;T;: ended?;0;[;{;IC;"*Returns true if the stream is closed.;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"static VALUE rb_zstream_closed_p(VALUE obj) { struct zstream *z; TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z); return ZSTREAM_IS_READY(z) ? Qfalse : Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#close;F;[;[[@i;T;;;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;Ao;B;CT;Di;Ei;!@;"I"cstatic VALUE rb_zstream_end(VALUE obj) { zstream_end(get_zstream(obj)); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#end;F;[;[[@i;T;;E;0;[;{;IC;"TCloses the stream. All operations on the closed stream will raise an exception. ;T;[;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"cstatic VALUE rb_zstream_end(VALUE obj) { zstream_end(get_zstream(obj)); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#reset;F;[;[[@i;T;;;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;Ao;B;CT;Di;Ei;!@;"I"gstatic VALUE rb_zstream_reset(VALUE obj) { zstream_reset(get_zstream(obj)); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::ZStream#finish;F;[;[[@i;T;;;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;H ;II" overload;F;J0;;;K0;#I" finish;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ʶ;[;I"@return [String];T;0; @ʶ;@F;Mi;N0;[; @ʶo;H ;II" overload;F;J0;;;K0;#I" finish;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" chunk;T; @ʶo;L ;II" return;F;JI";T;0;K[I"nil;T; @ʶ;[;I"!@yield [chunk] @return [nil];T;0; @ʶ;@F;Mi;N0;[; @ʶ;[;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;Ao;B;CT;Di ;Ei;!@;"I"static VALUE rb_zstream_finish(VALUE obj) { struct zstream *z = get_zstream(obj); zstream_run(z, (Bytef*)"", 0, Z_FINISH); return zstream_detach_buffer(z); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Zlib::ZStream#flush_next_in;F;[;[[@i";T;:flush_next_in;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;; ;K0;#I"flush_next_in;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I" @overload flush_next_in;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_zstream_flush_next_in(VALUE obj) { struct zstream *z; VALUE dst; TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z); dst = zstream_detach_input(z); OBJ_INFECT(dst, obj); return dst; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!Zlib::ZStream#flush_next_out;F;[;[[@i7;T;:flush_next_out;0;[;{;IC;"Flushes output buffer and returns all data in that buffer. If a block is given each chunk is yielded to the block until the current output buffer has been flushed. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"flush_next_out;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;; ;K0;#I"flush_next_out;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" chunk;T; @ o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ;[;I"!@yield [chunk] @return [nil];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di.;Ei7;!@;"I"static VALUE rb_zstream_flush_next_out(VALUE obj) { struct zstream *z; TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z); return zstream_detach_buffer(z); };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;: ZStream;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!o;2 ;30;40;50;: Zlib;!@;7@;F0;I"Zlib::ZStream;F;1@;EiR;!@M;"I"9static 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_end, (VALUE)&z); OBJ_INFECT(dst, src); return dst; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::Deflate#initialize;F;[[@0;[[@i;T;;;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; @^;@F;Ao;B;CT;Di;Ei;!@M;"I"+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; ; F; ;,;;;I""Zlib::Deflate#initialize_copy;F;[[I" orig;T0;[[@i;T;;];0;[;{;IC;"#Duplicates the deflate stream. ;T;[;[;I"% Duplicates the deflate stream. ;T;0; @m;@F;Ao;B;CT;Di;Ei;!@M;"I"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; ; F; ;,;;;I"Zlib::Deflate#deflate;F;[[@0;[[@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; @};@F;Ao;B;CT;Di|;Ei;!@M;"I""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); OBJ_INFECT(obj, src); do_deflate(z, src, ARG_FLUSH(flush)); return zstream_detach_buffer(z); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::Deflate#<<;F;[[I"src;T0;[[@i;T;;Q;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; @;@F;Ao;B;CT;Di;Ei;!@M;"I"static VALUE rb_deflate_addstr(VALUE obj, VALUE src) { OBJ_INFECT(obj, src); do_deflate(get_zstream(obj), src, Z_NO_FLUSH); return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::Deflate#flush;F;[[@0;[[@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;Ao;B;CT;Di;Ei;!@M;"I"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; ; F; ;,;;;I"Zlib::Deflate#params;F;[[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;Ao;B;CT;Di;Ei;!@M;"I"-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; ; F; ;,;;;I"!Zlib::Deflate#set_dictionary;F;[[I"dic;T0;[[@i ;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;Ao;B;CT;Di;Ei ;!@M;"I"wstatic VALUE rb_deflate_set_dictionary(VALUE obj, VALUE dic) { struct zstream *z = get_zstream(obj); VALUE src = dic; int err; OBJ_INFECT(obj, dic); 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;&@M;'IC;[;&@M;(IC;[;&@M;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;: Deflate;;0;;;[;{;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; @M;@F;Ao;B;CT;Di;Ei;Mi;!o;2 ;30;40;50;; ;!@;7@;F0;I"Zlib::Deflate;F;1@o; ;IC;[ o; ; F; ;;;;I"Zlib::Inflate.inflate;F;[[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;Ao;B;CT;Di|;Ei;!@;"I"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_end, (VALUE)&z); OBJ_INFECT(dst, src); return dst; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::Inflate#initialize;F;[[@0;[[@i^;T;;;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;Ao;B;CT;Di1;Ei[;!@;"I"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; ; F; ;,;;;I"!Zlib::Inflate#add_dictionary;F;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::Inflate#inflate;F;[[I"src;T0;[[@i;T;; ;0;[;{;IC;"$call-seq: inflate(deflate_string) -> String inflate(deflate_string) { |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. 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) -> String inflate(deflate_string) { |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. 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;Ao;B;CT;Di;Ei;!@;"I" static VALUE rb_inflate_inflate(VALUE obj, VALUE src) { struct zstream *z = get_zstream(obj); VALUE dst; OBJ_INFECT(obj, src); if (ZSTREAM_IS_FINISHED(z)) { if (NIL_P(src)) { dst = zstream_detach_buffer(z); } else { StringValue(src); zstream_append_buffer2(z, src); dst = rb_str_new(0, 0); OBJ_INFECT(dst, obj); } } 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; ; F; ;,;;;I"Zlib::Inflate#<<;F;[[I"src;T0;[[@i;T;;Q;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;H ;II" overload;F;J0;;Q;K0;#I"<< string;T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"ustatic VALUE rb_inflate_addstr(VALUE obj, VALUE src) { struct zstream *z = get_zstream(obj); OBJ_INFECT(obj, src); 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; ; F; ;,;;;I"Zlib::Inflate#sync;F;[[I"src;T0;[[@i4;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;H ;II" overload;F;J0;;;K0;#I"sync(string);T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[[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;Ao;B;CT;Di,;Ei2;!@;"I"static VALUE rb_inflate_sync(VALUE obj, VALUE src) { struct zstream *z = get_zstream(obj); OBJ_INFECT(obj, src); StringValue(src); return zstream_sync(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::Inflate#sync_point?;F;[;[[@iE;T;:sync_point?;0;[;{;IC;"OQuoted verbatim from original documentation: What is this? :);T;[o;L ;II" return;F;J@;0;K[@; @U;[;I"PQuoted verbatim from original documentation: What is this? :) ;T;0; @U;@F;Ao;B;CT;Di>;EiC;Mi;!@;"I"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; ; F; ;,;;;I"!Zlib::Inflate#set_dictionary;F;[[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; @f;@F;Ao;B;CT;DiU;EiY;!@;"I"wstatic VALUE rb_inflate_set_dictionary(VALUE obj, VALUE dic) { struct zstream *z = get_zstream(obj); VALUE src = dic; int err; OBJ_INFECT(obj, dic); 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![@i;T;: Inflate;;0;;;[;{;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;Ao;B;CT;Di!;Ei%;Mi;!o;2 ;30;40;50;; ;!@;7@;F0;I"Zlib::Inflate;F;1@o; ;IC;[o; ;IC;[o; ; F; ;,;;;I" Zlib::GzipFile::Error#input;F;[;[[@i3;F;: input;;0;[;{;IC;"input gzipped string ;T;[;[;I"input gzipped string;T;0; @;@F;Ao;B;CT;Di2;Ei2;!@;$To; ; F; ;,;;;I""Zlib::GzipFile::Error#inspect;F;[;[[@i ;T;;i;0;[;{;IC;".Constructs a String of the GzipFile Error ;T;[;[;I"0 Constructs a String of the GzipFile Error ;T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{; IC;*{;@;0;+T;+T;+T;-{;.[;[[@i[@i0;T;;;;0;;;[;{;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; @;@F;Ao;B;CT;Di;Ei;!@;I"Zlib::GzipFile::Error;F;1o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i{;T;;;;0;;;[;{;IC;"PThe 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 ;T;[;[;I"S 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 ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Zlib::Error;F;1@7o; ;IC;[;&@θ;'IC;[;&@θ;(IC;[;&@θ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i6;T;: NoFooter;;0;;;[;{;IC;"/Raised when gzip file footer is not found. ;T;[;[;I"1 Raised when gzip file footer is not found. ;T;0; @θ;@F;Ao;B;CT;Di;Ei;!@;I"Zlib::GzipFile::NoFooter;F;1@o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@i7;T;: CRCError;;0;;;[;{;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;Ao;B;CT;Di ;Ei;!@;I"Zlib::GzipFile::CRCError;F;1@o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i8;T;:LengthError;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I" Zlib::GzipFile::LengthError;F;1@o; ; F; ;;;;I"Zlib::GzipFile.wrap;F;[[@0;[[@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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Zlib::GzipFile#to_io;F;[;[[@i6 ;T;;;0;[;{;IC;"Same as IO. ;T;[;[;I" Same as IO. ;T;0; @;@F;Ao;B;CT;Di1 ;Ei3 ;!@;"I"Pstatic VALUE rb_gzfile_to_io(VALUE obj) { return get_gzfile(obj)->io; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#crc;F;[;[[@iA ;T;:crc;0;[;{;IC;"0Returns CRC value of the uncompressed data. ;T;[;[;I"2 Returns CRC value of the uncompressed data. ;T;0; @';@F;Ao;B;CT;Di< ;Ei> ;!@;"I"]static VALUE rb_gzfile_crc(VALUE obj) { return rb_uint2inum(get_gzfile(obj)->crc); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#mtime;F;[;[[@iL ;T;;[;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; @5;@F;Ao;B;CT;DiG ;EiI ;!@;"I"kstatic VALUE rb_gzfile_mtime(VALUE obj) { return rb_time_new(get_gzfile(obj)->mtime, (time_t)0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#level;F;[;[[@iW ;T;: level;0;[;{;IC;"Returns compression level. ;T;[;[;I"! Returns compression level. ;T;0; @C;@F;Ao;B;CT;DiR ;EiT ;!@;"I"\static VALUE rb_gzfile_level(VALUE obj) { return INT2FIX(get_gzfile(obj)->level); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#os_code;F;[;[[@ib ;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; @Q;@F;Ao;B;CT;Di] ;Ei_ ;!@;"I"`static VALUE rb_gzfile_os_code(VALUE obj) { return INT2FIX(get_gzfile(obj)->os_code); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#orig_name;F;[;[[@in ;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; @_;@F;Ao;B;CT;Dih ;Eik ;!@;"I"static VALUE rb_gzfile_orig_name(VALUE obj) { VALUE str = get_gzfile(obj)->orig_name; if (!NIL_P(str)) { str = rb_str_dup(str); } OBJ_TAINT(str); /* for safe */ return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#comment;F;[;[[@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; @m;@F;Ao;B;CT;Diy ;Ei| ;!@;"I"static VALUE rb_gzfile_comment(VALUE obj) { VALUE str = get_gzfile(obj)->comment; if (!NIL_P(str)) { str = rb_str_dup(str); } OBJ_TAINT(str); /* for safe */ return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#close;F;[;[[@i ;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; @{;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Zlib::GzipFile#finish;F;[;[[@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; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Zlib::GzipFile#closed?;F;[;[[@i" ;T;;;0;[;{;IC;"Same as IO#closed?;T;[o;L ;II" return;F;J@;0;K[@; @;[;I" Same as IO#closed? ;T;0; @;@F;Ao;B;CT;Di ;Ei ;Mi;!@;"I"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; ; F; ;,;;;I"Zlib::GzipFile#sync;F;[;[[@i< ;T;;;0;[;{;IC;"Same as IO#sync ;T;[;[;I" Same as IO#sync ;T;0; @;@F;Ao;B;CT;Di6 ;Ei9 ;!@;"I"zstatic VALUE rb_gzfile_sync(VALUE obj) { return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipFile#sync=;F;[[I" mode;T0;[[@iK ;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;Ao;B;CT;DiB ;EiH ;!@;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@i/;T;: GzipFile;;0;;;[;{;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; @;@F;Ao;B;CT;Di ;Ei ;Mi;!o;2 ;30;40;50;; ;!@;7@;F0;I"Zlib::GzipFile;F;1@z.flags & GZFILE_FLAG_HEADER_FINISHED) { rb_raise(cGzError, "header is already written"); } val = rb_Integer(mtime); gz->mtime = NUM2UINT(val); return mtime; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Zlib::GzipWriter#orig_name=;F;[[I"str;T0;[[@i ;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;Ao;B;CT;Di ;Ei ;!@ٹ;"I"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; ; F; ;,;;;I"Zlib::GzipWriter#comment=;F;[[I"str;T0;[[@i ;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;Ao;B;CT;Di ;Ei ;!@ٹ;"I"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; ; F; ;,;;;I"Zlib::GzipWriter#pos;F;[;[[@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;Ao;B;CT;DiY ;Ei[ ;!@ٹ;"I"pstatic VALUE rb_gzfile_total_in(VALUE obj) { return rb_uint2inum(get_gzfile(obj)->z.stream.total_in); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipWriter#tell;F;[;[[@i^ ;T;;;0;[;{;IC;"-Total number of input bytes read so far. ;T;[;[;@;0; @;@F;Ao;B;CT;DiY ;Ei[ ;!@ٹ;"I"pstatic VALUE rb_gzfile_total_in(VALUE obj) { return rb_uint2inum(get_gzfile(obj)->z.stream.total_in); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Zlib::GzipWriter.open;F;[[@0;[[@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;H ;II" overload;F;J0;:Zlib::GzipWriter.open;K0;#I"=Zlib::GzipWriter.open(filename, level=nil, strategy=nil);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"gz;T; @&;[;I"@yield [gz];T;0; @&;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@ٹ;"I"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; ; F; ;,;;;I" Zlib::GzipWriter#initialize;F;[[@0;[[@i ;T;;;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;H ;II" overload;F;J0;:Zlib::GzipWriter.new;K0;#I"HZlib::GzipWriter.new(io, level = nil, strategy = nil, options = {});T;IC;";T;[;[;I";T;0; @J;@F;Mi;N0;[ [I"io;T0[I" level;TI"nil;T[I" strategy;TI"nil;T[I" options;TI"{};T; @J;[;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; @J;@F;Ao;B;CT;Di ;Ei ;!@ٹ;"I"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)) { gz->path = rb_funcall(gz->io, id_path, 0); rb_define_singleton_method(obj, "path", rb_gzfile_path, 0); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipWriter#flush;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"flush(flush=nil);T;IC;";T;[;[;I";T;0; @l;@F;Mi;N0;[[I" flush;TI"nil;T; @l;[;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; @l;@F;Ao;B;CT;Di ;Ei ;!@ٹ;"I"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; ; F; ;,;;;I"Zlib::GzipWriter#write;F;[[@0;[[@i;T;;;0;[;{;IC;"Same as IO. ;T;[;[;I"Same as IO. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@ٹ;"I"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; ; F; ;,;;;I"Zlib::GzipWriter#putc;F;[[I"ch;T0;[[@i0;T;;;0;[;{;IC;"Same as IO. ;T;[;[;I"Same as IO. ;T;0; @;@F;Ao;B;CT;Di-;Ei.;!@ٹ;"I"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; ; F; ;,;;;I"Zlib::GzipWriter#<<;F;[;[;F;;Q;;0;[;{;IC;"Same as IO. ;T;[;[;I"Same as IO. ;T;0; @;@F;Ao;B;CT;Di<;Ei=;!@ٹ;$To; ; F; ;,;;;I"Zlib::GzipWriter#printf;F;[;[;F;;;;0;[;{;IC;"Same as IO. ;T;[;[;I"Same as IO. ;T;0; @;@F;Ao;B;CT;DiA;EiB;!@ٹ;$To; ; F; ;,;;;I"Zlib::GzipWriter#print;F;[;[;F;;;;0;[;{;IC;"Same as IO. ;T;[;[;I"Same as IO. ;T;0; @;@F;Ao;B;CT;DiF;EiG;!@ٹ;$To; ; F; ;,;;;I"Zlib::GzipWriter#puts;F;[;[;F;;;;0;[;{;IC;"Same as IO. ;T;[;[;I"Same as IO. ;T;0; @ƺ;@F;Ao;B;CT;DiK;EiL;!@ٹ;$T;&@ٹ;'IC;[;&@ٹ;(IC;[;&@ٹ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i [@i:;T;:GzipWriter;;0;;;[;{;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;Ao;B;CT;Di ;Ei ;Mi;!o;2 ;30;40;50;; ;!@;7@;F0;I"Zlib::GzipWriter;F;1@o; ;IC;[!o; ; F; ;,;;;I"Zlib::GzipReader#lineno;F;[;[[@i ;T;;;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;Ao;B;CT;Di ;Ei ;!@;"I"^static VALUE rb_gzfile_lineno(VALUE obj) { return INT2NUM(get_gzfile(obj)->lineno); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipReader#lineno=;F;[[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;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#eof;F;[;[[@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;Ao;B;CT;Di* ;Ei, ;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#eof?;F;[;[[@i/ ;T;;;0;[;{;IC;"FReturns +true+ or +false+ whether the stream has reached the end.;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;@F;Ao;B;CT;Di* ;Ei, ;Mi;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#pos;F;[;[[@ii ;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;Ao;B;CT;Did ;Eif ;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#tell;F;[;[[@ii ;T;;;0;[;{;IC;"0Total number of output bytes output so far. ;T;[;[;@,;0; @0;@F;Ao;B;CT;Did ;Eif ;!@;"I"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; ; F; ;;;;I"Zlib::GzipReader.open;F;[[@0;[[@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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I" Zlib::GzipReader#initialize;F;[[@0;[[@i;T;;;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; @L;@F;Ao;B;CT;Di;Ei;!@;"I"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)) { gz->path = rb_funcall(gz->io, id_path, 0); rb_define_singleton_method(obj, "path", rb_gzfile_path, 0); } return obj; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipReader#rewind;F;[;[[@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; @[;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#unused;F;[;[[@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; @i;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#read;F;[[@0;[[@i;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @w;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"!Zlib::GzipReader#readpartial;F;[[@0;[[@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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#getc;F;[;[[@i!;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"wstatic VALUE rb_gzreader_getc(VALUE obj) { struct gzfile *gz = get_gzfile(obj); return gzfile_getc(gz); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipReader#getbyte;F;[;[[@i>;T;;5;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @;@F;Ao;B;CT;Di9;Ei;;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#readchar;F;[;[[@i.;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @;@F;Ao;B;CT;Di);Ei+;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#readbyte;F;[;[[@iP;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @;@F;Ao;B;CT;DiK;EiM;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#each_byte;F;[;[[@ir;T;;x;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @ͻ;@F;Ao;B;CT;Dim;Eio;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#each_char;F;[;[[@i`;T;;y;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @ۻ;@F;Ao;B;CT;Di[;Ei];!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#bytes;F;[;[[@i;T;;J;0;[;{;IC;";This is a deprecated alias for each_byte. ;T;[;[;I"> This is a deprecated alias for each_byte. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE rb_gzreader_bytes(VALUE obj) { rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead"); if (!rb_block_given_p()) return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0); return rb_gzreader_each_byte(obj); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipReader#ungetc;F;[[I"s;T0;[[@i;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#ungetbyte;F;[[I"ch;T0;[[@i;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#gets;F;[[@0;[[@ip;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @;@F;Ao;B;CT;Dik;Eim;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#readline;F;[[@0;[[@i;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @&;@F;Ao;B;CT;Di{;Ei};!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#each;F;[[@0;[[@i;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @5;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#each_line;F;[[@0;[[@i;T;;w;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;@@;0; @D;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Zlib::GzipReader#lines;F;[[@0;[[@i;T;;I;0;[;{;IC;";This is a deprecated alias for each_line. ;T;[;[;I"> This is a deprecated alias for each_line. ;T;0; @R;@F;Ao;B;CT;Di;Ei;!@;"I"'static VALUE rb_gzreader_lines(int argc, VALUE *argv, VALUE obj) { rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead"); if (!rb_block_given_p()) return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv); return rb_gzreader_each(argc, argv, obj); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Zlib::GzipReader#readlines;F;[[@0;[[@i;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @a;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"'Zlib::GzipReader#external_encoding;F;[;[[@i;T;;;0;[;{;IC;":See Zlib::GzipReader documentation for a description. ;T;[;[;I"< See Zlib::GzipReader documentation for a description. ;T;0; @p;@F;Ao;B;CT;Di;Ei;!@;"I"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;[@C;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iT[@i;;T;:GzipReader;;0;;;[;{;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;Ao;B;CT;DiT;Ei;Mi;!o;2 ;30;40;50;; ;!@;7@;F0;I"Zlib::GzipReader;F;1@@o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i|;T;:StreamEnd;;0;;;[;{;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; @;@F;Ao;B;CT;Di;Ei;!@;I"Zlib::StreamEnd;F;1@o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i};T;: NeedDict;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"Zlib::NeedDict;F;1@o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i~;T;;;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"Zlib::DataError;F;1@o; ;IC;[;&@ͼ;'IC;[;&@ͼ;(IC;[;&@ͼ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;:StreamError;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"Zlib::StreamError;F;1@o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;: MemError;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"Zlib::MemError;F;1@o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;: BufError;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"Zlib::BufError;F;1@o; ;IC;[;&@ ;'IC;[;&@ ;(IC;[;&@ ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;:VersionError;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"Zlib::VersionError;F;1@o; ; F; ;,;;;I"Zlib#zlib_version;F;[;[[@ih;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;N0;!@;"I"static VALUE rb_zlib_version(VALUE klass) { VALUE str; str = rb_str_new2(zlibVersion()); OBJ_TAINT(str); /* for safe */ return str; };T;#I"static VALUE;T;$To; ; T; ;;;;I"Zlib.zlib_version;F;@;@ ;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;Ao;B;CT;Dic;Eie;Mi;!@;"@(;#@);$To; ; F; ;,;;;I"Zlib#adler32;F;[[@0;[[@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+. 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+. Example usage: require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145;T;0; @2;@F;N0;!@;"I"vstatic VALUE rb_zlib_adler32(int argc, VALUE *argv, VALUE klass) { return do_checksum(argc, argv, adler32); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Zlib.adler32;F;@4;@6;T;; ;0;@8;{;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+. 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+. Example usage: require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145 ;T;0; @@;@F;Ao;B;CT;Di;Ei;Mi;!@;"@>;#@?;$To; ; F; ;,;;;I"Zlib#adler32_combine;F;[[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; @H;@F;N0;!@;"I"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; ; T; ;;;;I"Zlib.adler32_combine;F;@J;@Q;T;; ;0;@S;{;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; @[;@F;Ao;B;CT;Di;Ei;Mi;!@;"@Y;#@Z;$To; ; F; ;,;;;I"Zlib#crc32;F;[[@0;[[@i;T;: crc32;0;[;{;IC;"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+. 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+. FIXME: expression.;T;0; @c;@F;N0;!@;"I"rstatic VALUE rb_zlib_crc32(int argc, VALUE *argv, VALUE klass) { return do_checksum(argc, argv, crc32); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Zlib.crc32;F;@e;@g;T;; ;0;@i;{;IC;"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+. 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+. FIXME: expression. ;T;0; @q;@F;Ao;B;CT;Di;Ei;Mi;!@;"@o;#@p;$To; ; F; ;,;;;I"Zlib#crc32_combine;F;[[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; @y;@F;N0;!@;"I"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; ; T; ;;;;I"Zlib.crc32_combine;F;@{;@;T;; ;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To; ; F; ;,;;;I"Zlib#crc_table;F;[;[[@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;N0;!@;"I"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; ; T; ;;;;I"Zlib.crc_table;F;@;@;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;Ao;B;CT;Di;Ei;Mi;!@;"@;#@;$To;9;[[@i;F;;^;;;;;;[;{;IC;""The Ruby/zlib version string. ;T;[;[;I""The Ruby/zlib version string.;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Zlib::VERSION;F;;EiR;!@;"I"9static 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_end, (VALUE)&z); OBJ_INFECT(dst, src); return dst; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Zlib.inflate;F;[[I"src;T0;[[@i;T;; ;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;[;[;@;0; @;@F;Ao;B;CT;Di|;Ei;!@;"I"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_end, (VALUE)&z); OBJ_INFECT(dst, src); return dst; };T;#I"static VALUE;T;$To;9;[[@i;F;:NO_COMPRESSION;;;;;;[;{;IC;"tNo compression, passes through data untouched. Use this for appending pre-compressed data to a deflate stream. ;T;[;[;I"uNo compression, passes through data untouched. Use this for appending pre-compressed data to a deflate stream. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Zlib::NO_COMPRESSION;F;;@F;Ao;B;CT;Di;Ei;!@;I"Zlib::FILTERED;F;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; ; F; ;;;;I"Zlib.gunzip;F;[[I"src;T0;[[@iE;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;H ;II" overload;F;J0;; ;K0;#I"gunzip(src);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di3;EiC;!@;"I"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;9;[[@i;F;: OS_CODE;;;;;;[;{;IC;" The OS code of current host ;T;[;[;I" The OS code of current host;T;0; @;@F;Ao;B;CT;Di~;Ei~;!@;I"Zlib::OS_CODE;F; 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 (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"C 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 (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;Ao;B;CT;Di;Ei#;Mi;!@;I" Zlib;Fo; ;IC;[ o; ;IC;[o; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I" ext/psych/psych_yaml_tree.c;Ti[I"ext/psych/psych_to_ruby.c;Ti&;F;: Visitor;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I"Psych::Visitors::Visitor;F;1@Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS);T;IC;";T;[;[;I";T;0; @|;@F;Mi;N0;[[I"io;T0[I" options;TI"Psych::Emitter::OPTIONS;T; @|;[;@rF;0; @|;@F;Ao;B;CT;DiK;EiN;!@z;"I"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; ; F; ;,;;;I" Psych::Emitter#start_stream;F;[[I" encoding;T0;[[@_Fio;T;:start_stream;0;[;{;IC;"MStart a stream emission with +encoding+ See Psych::Handler#start_stream ;T;[o;H ;II" overload;F;J0;;, ;K0;#I"start_stream(encoding);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" encoding;T0; @;[;I"pStart a stream emission with +encoding+ See Psych::Handler#start_stream @overload start_stream(encoding);T;0; @;@F;Ao;B;CT;Dii;Ein;!@z;"I"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; ; F; ;,;;;I"Psych::Emitter#end_stream;F;[;[[@_Fi~;T;:end_stream;0;[;{;IC;"9End a stream emission See Psych::Handler#end_stream ;T;[o;H ;II" overload;F;J0;;- ;K0;#I"end_stream;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"PEnd a stream emission See Psych::Handler#end_stream @overload end_stream;T;0; @;@F;Ao;B;CT;Di};Ei};!@z;"I"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; ; F; ;,;;;I""Psych::Emitter#start_document;F;[[I" version;T0[I" tags;T0[I"imp;T0;[[@_Fi;T;:start_document;0;[;{;IC;"wStart a document emission with YAML +version+, +tags+, and an +implicit+ start. See Psych::Handler#start_document ;T;[o;H ;II" overload;F;J0;;. ;K0;#I",start_document(version, tags, implicit);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@z;"I"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; ; F; ;,;;;I" Psych::Emitter#end_document;F;[[I"imp;T0;[[@_Fi;T;:end_document;0;[;{;IC;"XEnd a document emission with an +implicit+ ending. See Psych::Handler#end_document ;T;[o;H ;II" overload;F;J0;;/ ;K0;#I"end_document(implicit);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" implicit;T0; @;[;I"{End a document emission with an +implicit+ ending. See Psych::Handler#end_document @overload end_document(implicit);T;0; @;@F;Ao;B;CT;Di;Ei;!@z;"I"$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; ; F; ;,;;;I"Psych::Emitter#scalar;F;[ [I" value;T0[I" anchor;T0[I"tag;T0[I" plain;T0[I" quoted;T0[I" style;T0;[[@_Fi;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;H ;II" overload;F;J0;;0 ;K0;#I"5scalar(value, anchor, tag, plain, quoted, style);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[ [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;Ao;B;CT;Di;Ei;!@z;"I"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; ; F; ;,;;;I""Psych::Emitter#start_sequence;F;[ [I" anchor;T0[I"tag;T0[I" implicit;T0[I" style;T0;[[@_Fi(;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;H ;II" overload;F;J0;;1 ;K0;#I"1start_sequence(anchor, tag, implicit, style);T;IC;";T;[;[;I";T;0; @1;@F;Mi;N0;[ [I" anchor;T0[I"tag;T0[I" implicit;T0[I" style;T0; @1;[;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; @1;@F;Ao;B;CT;Di!;Ei';!@z;"I",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; ; F; ;,;;;I" Psych::Emitter#end_sequence;F;[;[[@_FiS;T;:end_sequence;0;[;{;IC;"canonical == 0) ? Qfalse : Qtrue; };T;#I"'static VALUE canonical(VALUE self);T;$To; ; F; ;,;;;I"Psych::Emitter#canonical=;F;[[I" style;T0;[[@_Fi;T;:canonical=;0;[;{;IC;"/Set the output style to canonical, or not. ;T;[o;H ;II" overload;F;J0;;7 ;K0;#I"canonical=(true);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" true;T0; @;[;I"LSet the output style to canonical, or not. @overload canonical=(true);T;0; @;@F;Ao;B;CT;Di;Ei;!@z;"I"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; ; F; ;,;;;I"Psych::Emitter#indentation;F;[;[[@_Fi;T;:indentation;0;[;{;IC;"Get the indentation level. ;T;[o;H ;II" overload;F;J0;;8 ;K0;#I"indentation;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"7Get the indentation level. @overload indentation;T;0; @;@F;Ao;B;CT;Di;Ei;!@z;"I"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; ; F; ;,;;;I" Psych::Emitter#indentation=;F;[[I" level;T0;[[@_Fi;T;:indentation=;0;[;{;IC;"^Set the indentation level to +level+. The level must be less than 10 and greater than 1. ;T;[o;H ;II" overload;F;J0;;9 ;K0;#I"indentation=(level);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@z;"I"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; ; F; ;,;;;I"Psych::Emitter#line_width;F;[;[[@_Fi;T;:line_width;0;[;{;IC;""Get the preferred line width. ;T;[o;H ;II" overload;F;J0;;: ;K0;#I"line_width;T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[; @#;[;I"9Get the preferred line width. @overload line_width;T;0; @#;@F;Ao;B;CT;Di;Ei;!@z;"I"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; ; F; ;,;;;I"Psych::Emitter#line_width=;F;[[I" width;T0;[[@_Fi;T;:line_width=;0;[;{;IC;",Set the preferred line with to +width+. ;T;[o;H ;II" overload;F;J0;;; ;K0;#I"line_width=(width);T;IC;";T;[;[;I";T;0; @9;@F;Mi;N0;[[I" width;T0; @9;[;I"KSet the preferred line with to +width+. @overload line_width=(width);T;0; @9;@F;Ao;B;CT;Di;Ei;!@z;"I"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;&@z;'IC;[;&@z;(IC;[;&@z;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@_Fi;F;: Emitter;;0;;;[;{;IC;" ;T;[;[;@;0; @z;Mi;!@;I"Psych::Emitter;F;1@io; ;IC;[o; ; F; ;,;;;I""Psych::ClassLoader#path2class;F;[[I" path;T0;[[@i;T;:path2class;0;[;{;IC;"%Convert +path+ string to a class ;T;[o;H ;II" overload;F;J0;;= ;K0;#I"path2class(path);T;IC;";T;[;[;I";T;0; @d;@F;Mi;N0;[[I" path;T0; @d;[;I"BConvert +path+ string to a class @overload path2class(path);T;0; @d;@F;Ao;B;CT;Di;Ei;!@b;"I"[static VALUE path2class(VALUE self, VALUE path) { return rb_path_to_class(path); };T;#I"4static VALUE path2class(VALUE self, VALUE path);T;$T;&@b;'IC;[;&@b;(IC;[;&@b;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i#;F;:ClassLoader;;0;;;[;{;IC;" ;T;[;[;@;0; @b;Mi;!@;I"Psych::ClassLoader;F;1@"); } TypedData_Get_Struct(self, yaml_parser_t, &psych_parser_type, parser); yaml_parser_delete(parser); yaml_parser_initialize(parser); if (OBJ_TAINTED(yaml)) tainted = 1; 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); if (RTEST(rb_obj_is_kind_of(yaml, rb_cIO))) tainted = 1; } 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 = INT2NUM((long)event.start_mark.line); start_column = INT2NUM((long)event.start_mark.column); end_line = INT2NUM((long)event.end_mark.line); end_column = INT2NUM((long)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((long)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((long)event.data.document_start.version_directive->major), INT2NUM((long)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); if (tainted) OBJ_TAINT(handle); PSYCH_TRANSCODE(handle, encoding, internal_enc); } if(start->prefix) { prefix = rb_str_new2((const char *)start->prefix); if (tainted) OBJ_TAINT(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); if (tainted) OBJ_TAINT(alias); 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 ); if (tainted) OBJ_TAINT(val); PSYCH_TRANSCODE(val, encoding, internal_enc); if(event.data.scalar.anchor) { anchor = rb_str_new2((const char *)event.data.scalar.anchor); if (tainted) OBJ_TAINT(anchor); PSYCH_TRANSCODE(anchor, encoding, internal_enc); } if(event.data.scalar.tag) { tag = rb_str_new2((const char *)event.data.scalar.tag); if (tainted) OBJ_TAINT(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((long)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); if (tainted) OBJ_TAINT(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); if (tainted) OBJ_TAINT(tag); PSYCH_TRANSCODE(tag, encoding, internal_enc); } implicit = event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue; style = INT2NUM((long)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); if (tainted) OBJ_TAINT(anchor); PSYCH_TRANSCODE(anchor, encoding, internal_enc); } if(event.data.mapping_start.tag) { tag = rb_str_new2((const char *)event.data.mapping_start.tag); if (tainted) OBJ_TAINT(tag); PSYCH_TRANSCODE(tag, encoding, internal_enc); } implicit = event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue; style = INT2NUM((long)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; ; F; ;,;;;I"Psych::Parser#mark;F;[;[[@i;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;Ao;B;CT;Di;Ei;!@;"I"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] = INT2NUM(parser->mark.index); args[1] = INT2NUM(parser->mark.line); args[2] = INT2NUM(parser->mark.column); return rb_class_new_instance(3, args, mark_klass); };T;#I""static VALUE mark(VALUE self);T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i,;F;; ;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"Psych::Parser;F;1@<;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[ [@i[@_Fi [@i"[@i[@i);F;: Psych;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I" Psych;Fo; ;IC;[6o; ;IC;[;&@";'IC;[;&@";(IC;[;&@";)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/strscan/strscan.c;Ti;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @";!@ ;I"StringScanner::Error;F;1@7o; ; F; ;,;;;I"StringScanner#initialize;F;[[@0;[[@-i;T;;;0;[;{;IC;"uCreates a new StringScanner object to scan over the given +string+. +dup+ argument is obsolete and not used now. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(string, dup = false);T;IC;";T;[;[;I";T;0; @4;@F;Mi;N0;[[I" string;T0[I"dup;TI" false;T; @4;[;I"Creates a new StringScanner object to scan over the given +string+. +dup+ argument is obsolete and not used now. @overload new(string, dup = false);T;0; @4;@F;Ao;B;CT;Di;Ei;!@ ;"I"static VALUE strscan_initialize(int argc, VALUE *argv, VALUE self) { struct strscanner *p; VALUE str, need_dup; p = check_strscan(self); rb_scan_args(argc, argv, "11", &str, &need_dup); StringValue(str); p->str = str; return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I""StringScanner#initialize_copy;F;[[I" vorig;T0;[[@-i;T;;];0;[;{;IC;"'Duplicates a StringScanner object. ;T;[o;H ;II" overload;F;J0;;Y;K0;#I"dup;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @Po;H ;II" overload;F;J0;;X;K0;#I" clone;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @P;[;I"GDuplicates a StringScanner object. @overload dup @overload clone;T;0; @P;@F;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;;;;I"!StringScanner.must_C_version;F;[;[[@-i;T;:must_C_version;0;[;{;IC;"7This method is defined for backward compatibility. ;T;[o;H ;II" overload;F;J0;;E ;K0;#I"must_C_version;T;IC;";T;[;[;I";T;0; @p;@F;Mi;N0;[; @p;[;I"RThis method is defined for backward compatibility. @overload must_C_version;T;0; @p;@F;Ao;B;CT;Di ;Ei;!@ ;"I"Bstatic VALUE strscan_s_mustc(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#reset;F;[;[[@-i;T;;;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;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;,;;;I"StringScanner#terminate;F;[;[[@-i+;T;;0;0;[;{;IC;"KSet the scan pointer to the end of the string and clear matching data. ;T;[o;H ;II" overload;F;J0;;0;K0;#I"terminate;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;3;K0;#I" clear;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"qSet the scan pointer to the end of the string and clear matching data. @overload terminate @overload clear;T;0; @;@F;Ao;B;CT;Di$;Ei(;!@ ;"I"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; ; F; ;,;;;I"StringScanner#clear;F;[;[[@-i:;T;;3;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;Ao;B;CT;Di6;Ei8;!@ ;"I"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; ; F; ;,;;;I"StringScanner#string;F;[;[[@-iD;T;;;0;[;{;IC;"&Returns the string being scanned. ;T;[;[;I"'Returns the string being scanned. ;T;0; @;@F;Ao;B;CT;DiA;EiB;!@ ;"I"|static VALUE strscan_get_string(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return p->str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#string=;F;[[I"str;T0;[[@-iS;T;: string=;0;[;{;IC;"UChanges the string being scanned to +str+ and resets the scanner. Returns +str+. ;T;[o;H ;II" overload;F;J0;;F ;K0;#I"string=(str);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"str;T0; @;[;I"nChanges the string being scanned to +str+ and resets the scanner. Returns +str+. @overload string=(str);T;0; @;@F;Ao;B;CT;DiM;EiQ;!@ ;"I"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; ; F; ;,;;;I"StringScanner#concat;F;[[I"str;T0;[[@-im;T;;P;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;H ;II" overload;F;J0;;P;K0;#I"concat(str);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"str;T0; @o;H ;II" overload;F;J0;;Q;K0;#I" <<(str);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"str;T0; @;[;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; @;@F;Ao;B;CT;Di_;Eij;!@ ;"I"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; ; F; ;,;;;I"StringScanner#<<;F;[[I"str;T0;[[@-im;T;;Q;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;H ;II" overload;F;J0;;P;K0;#I"concat(str);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"str;T0; @ o;H ;II" overload;F;J0;;Q;K0;#I" <<(str);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I"str;T0; @ ;[;@;0; @ ;@F;Ao;B;CT;Di_;Eij;!@ ;"I"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; ; F; ;,;;;I"StringScanner#pos;F;[;[[@-i;T;;;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;Ao;B;CT;Dix;Ei;!@ ;"I"~static VALUE strscan_get_pos(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return INT2FIX(p->curr); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#pos=;F;[[I"v;T0;[[@-i;T;;;0;[;{;IC;"Set the byte position of the scan pointer. s = StringScanner.new('test string') s.pos = 7 # -> 7 s.rest # -> "ring" ;T;[o;H ;II" overload;F;J0;;;K0;#I" pos=(n);T;IC;";T;[;[;I";T;0; @=;@F;Mi;N0;[[I"n;T0; @=;[;I"Set 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;Ao;B;CT;Di;Ei;!@ ;"I"Ustatic 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 INT2NUM(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#charpos;F;[;[[@-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; @W;@F;Ao;B;CT;Di;Ei;!@ ;"I"static VALUE strscan_get_charpos(VALUE self) { struct strscanner *p; VALUE substr; GET_SCANNER(self, p); substr = rb_funcall(p->str, id_byteslice, 2, INT2FIX(0), INT2NUM(p->curr)); return rb_str_length(substr); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#pointer;F;[;[[@-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;[;[;@9;0; @e;@F;Ao;B;CT;Dix;Ei;!@ ;"I"~static VALUE strscan_get_pos(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return INT2FIX(p->curr); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#pointer=;F;[[I"v;T0;[[@-i;T;: pointer=;0;[;{;IC;"Set the byte position of the scan pointer. s = StringScanner.new('test string') s.pos = 7 # -> 7 s.rest # -> "ring" ;T;[o;H ;II" overload;F;J0;;;K0;#I" pos=(n);T;IC;";T;[;[;I";T;0; @r;@F;Mi;N0;[[I"n;T0; @r;[;@S;0; @r;@F;Ao;B;CT;Di;Ei;!@ ;"I"Ustatic 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 INT2NUM(i); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#scan;F;[[I"re;T0;[[@-i;T;;X;0;[;{;IC;"yTries 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(/\w+/) # -> "string" p s.scan(/./) # -> nil ;T;[o;H ;II" overload;F;J0;;X;K0;#I"scan(pattern);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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(/\w+/) # -> "string" p s.scan(/./) # -> nil @overload scan(pattern) @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@ ;"I"gstatic VALUE strscan_scan(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 1, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#skip;F;[[I"re;T0;[[@-i7;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(/\w+/) # -> 6 p s.skip(/./) # -> nil ;T;[o;H ;II" overload;F;J0;;J ;K0;#I"skip(pattern);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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(/\w+/) # -> 6 p s.skip(/./) # -> nil @overload skip(pattern);T;0; @;@F;Ao;B;CT;Di&;Ei5;!@ ;"I"gstatic VALUE strscan_skip(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 0, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#match?;F;[[I"re;T0;[[@-i ;T;;;0;[;{;IC;"Tests 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?(/\s+/) # -> nil;T;[o;H ;II" overload;F;J0;;;K0;#I"match?(pattern);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" pattern;T0; @o;L ;II" return;F;J@;0;K[@; @;[;I"6Tests 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?(/\s+/) # -> nil @overload match?(pattern);T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@ ;"I"jstatic VALUE strscan_match_p(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 0, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#check;F;[[I"re;T0;[[@-iL;T;;;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;H ;II" overload;F;J0;;;K0;#I"check(pattern);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" pattern;T0; @;[;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; @;@F;Ao;B;CT;Di=;EiJ;!@ ;"I"hstatic VALUE strscan_check(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 1, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#scan_full;F;[[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;H ;II" overload;F;J0;;K ;K0;#I";scan_full(pattern, advance_pointer_p, return_string_p);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" pattern;T0[I"advance_pointer_p;T0[I"return_string_p;T0; @;[;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; @;@F;Ao;B;CT;DiR;EiZ;!@ ;"I"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; ; F; ;,;;;I"StringScanner#scan_until;F;[[I"re;T0;[[@-in;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;H ;II" overload;F;J0;;L ;K0;#I"scan_until(pattern);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dib;Eil;!@ ;"I"mstatic VALUE strscan_scan_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 1, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#skip_until;F;[[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;H ;II" overload;F;J0;;M ;K0;#I"skip_until(pattern);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I" pattern;T0; @7;[;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; @7;@F;Ao;B;CT;Di;Ei;!@ ;"I"mstatic VALUE strscan_skip_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 0, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#exist?;F;[[I"re;T0;[[@-i;T;;s;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;H ;II" overload;F;J0;;s;K0;#I"exist?(pattern);T;IC;";T;[;[;I";T;0; @Q;@F;Mi;N0;[[I" pattern;T0; @Qo;L ;II" return;F;J@;0;K[@; @Q;[;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; @Q;@F;Ao;B;CT;Dit;Ei;Mi;!@ ;"I"jstatic VALUE strscan_exist_p(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 0, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#check_until;F;[[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;H ;II" overload;F;J0;;N ;K0;#I"check_until(pattern);T;IC;";T;[;[;I";T;0; @n;@F;Mi;N0;[[I" pattern;T0; @n;[;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; @n;@F;Ao;B;CT;Di;Ei;!@ ;"I"nstatic VALUE strscan_check_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 1, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#search_full;F;[[I"re;T0[I"s;T0[I"f;T0;[[@-i;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;H ;II" overload;F;J0;;O ;K0;#I"=search_full(pattern, advance_pointer_p, return_string_p);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;,;;;I"StringScanner#getch;F;[;[[@-i;T;;;0;[;{;IC;"cScans one character and returns it. This method is multibyte character sensitive. s = StringScanner.new("ab") s.getch # => "a" s.getch # => "b" s.getch # => nil $KCODE = 'EUC' s = StringScanner.new("\244\242") s.getch # => "\244\242" # Japanese hira-kana "A" in EUC-JP s.getch # => nil ;T;[;[;I"dScans one character and returns it. This method is multibyte character sensitive. s = StringScanner.new("ab") s.getch # => "a" s.getch # => "b" s.getch # => nil $KCODE = 'EUC' s = StringScanner.new("\244\242") s.getch # => "\244\242" # Japanese hira-kana "A" in EUC-JP s.getch # => nil ;T;0; @;@F;Ao;B;CT;Di;Ei;!@ ;"I"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, p->prev + p->regs.beg[0], p->prev + p->regs.end[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#get_byte;F;[;[[@-i;T;: get_byte;0;[;{;IC;"qScans 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 $KCODE = 'EUC' s = StringScanner.new("\244\242") s.get_byte # => "\244" s.get_byte # => "\242" s.get_byte # => nil ;T;[;[;I"rScans 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 $KCODE = 'EUC' s = StringScanner.new("\244\242") s.get_byte # => "\244" s.get_byte # => "\242" s.get_byte # => nil ;T;0; @;@F;Ao;B;CT;Di;Ei;!@ ;"I"lstatic 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, p->prev + p->regs.beg[0], p->prev + p->regs.end[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#getbyte;F;[;[[@-i;T;;5;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; @;@F;Ao;B;CT;Di ;Ei ;!@ ;"I"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; ; F; ;,;;;I"StringScanner#peek;F;[[I" vlen;T0;[[@-i!;T;;;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;H ;II" overload;F;J0;;;K0;#I"peek(len);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"len;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@ ;"I"#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 infect(str_new(p, "", 0), p); len = minl(len, S_RESTLEN(p)); return extract_beg_len(p, p->curr, len); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#peep;F;[[I" vlen;T0;[[@-i5;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;Ao;B;CT;Di1;Ei3;!@ ;"I"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; ; F; ;,;;;I"StringScanner#unscan;F;[;[[@-iG;T;: unscan;0;[;{;IC;"pSet 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"qSet 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; @;@F;Ao;B;CT;Di<;EiE;!@ ;"I" 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; ; F; ;,;;;I"%StringScanner#beginning_of_line?;F;[;[[@-i`;T;:beginning_of_line?;0;[;{;IC;"Returns +true+ iff 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;L ;II" return;F;J@;0;K[@; @ ;[;I"Returns +true+ iff 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;Ao;B;CT;DiT;Ei^;Mi;!@ ;"I"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; ; F; ;,;;;I"StringScanner#eos?;F;[;[[@-iu;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;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Dik;Eis;Mi;!@ ;"I"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; ; F; ;,;;;I"StringScanner#empty?;F;[;[[@-i;T;;;0;[;{;IC;"EEquivalent to #eos?. This method is obsolete, use #eos? instead.;T;[o;L ;II" return;F;J@;0;K[@; @.;[;I"FEquivalent to #eos?. This method is obsolete, use #eos? instead. ;T;0; @.;@F;Ao;B;CT;Di~;Ei;Mi;!@ ;"I"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; ; F; ;,;;;I"StringScanner#rest?;F;[;[[@-i;T;: rest?;0;[;{;IC;"Returns true iff 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;L ;II" return;F;J@;0;K[@; @?;[;I"Returns true iff 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;Ao;B;CT;Di;Ei;Mi;!@ ;"I"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; ; F; ;,;;;I"StringScanner#matched?;F;[;[[@-i;T;: matched?;0;[;{;IC;"Returns +true+ iff 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;L ;II" return;F;J@;0;K[@; @P;[;I"Returns +true+ iff 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; @P;@F;Ao;B;CT;Di;Ei;Mi;!@ ;"I"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; ; F; ;,;;;I"StringScanner#matched;F;[;[[@-i;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; @a;@F;Ao;B;CT;Di;Ei;!@ ;"I"static VALUE strscan_matched(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return extract_range(p, p->prev + p->regs.beg[0], p->prev + p->regs.end[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#matched_size;F;[;[[@-i;T;:matched_size;0;[;{;IC;"Returns the size of the most recent match (see #matched), or +nil+ if there was no recent match. s = StringScanner.new('test string') s.check /\w+/ # -> "test" s.matched_size # -> 4 s.check /\d+/ # -> nil s.matched_size # -> nil ;T;[;[;I"Returns the size of the most recent match (see #matched), or +nil+ if there was no recent match. s = StringScanner.new('test string') s.check /\w+/ # -> "test" s.matched_size # -> 4 s.check /\d+/ # -> nil s.matched_size # -> nil ;T;0; @o;@F;Ao;B;CT;Di;Ei;!@ ;"I"static VALUE strscan_matched_size(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return INT2NUM(p->regs.end[0] - p->regs.beg[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#[];F;[[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;H ;II" overload;F;J0;;;K0;#I" [](n);T;IC;";T;[;[;I";T;0; @};@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@ ;"I"\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 (!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, p->prev + p->regs.beg[i], p->prev + p->regs.end[i]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#pre_match;F;[;[[@-i~;T;;;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;Ao;B;CT;Diu;Ei|;!@ ;"I"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, p->prev + p->regs.beg[0]); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#post_match;F;[;[[@-i;T;;;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;Ao;B;CT;Di;Ei;!@ ;"I"static VALUE strscan_post_match(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return extract_range(p, p->prev + p->regs.end[0], S_LEN(p)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#size;F;[;[[@-i);T;;;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;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei';!@ ;"I"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; ; F; ;,;;;I"StringScanner#captures;F;[;[[@-i?;T;;;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;H ;II" overload;F;J0;;;K0;#I" captures;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di3;Ei=;!@ ;"I"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, p->prev + p->regs.beg[i], p->prev + p->regs.end[i]); rb_ary_push(new_ary, str); } return new_ary; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#values_at;F;[[@0;[[@-ic;T;;;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;H ;II" overload;F;J0;;;K0;#I" values_at( i1, i2, ... iN );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"i1;T0[I"i2;T0[I" ...iN;T0; @;[;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; @;@F;Ao;B;CT;DiU;Ei`;!@ ;"I"\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; @;@F;Ao;B;CT;Di;Ei;!@ ;"I"static VALUE strscan_rest(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (EOS_P(p)) { return infect(str_new(p, "", 0), p); } return extract_range(p, p->curr, S_LEN(p)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringScanner#rest_size;F;[;[[@-i;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;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;,;;;I"StringScanner#restsize;F;[;[[@-i;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;Ao;B;CT;Di;Ei;!@ ;"I"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; ; F; ;,;;;I"StringScanner#inspect;F;[;[[@-i;T;;i;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;Ao;B;CT;Di;Ei;!@ ;"I"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 infect(a, p); } if (EOS_P(p)) { a = rb_sprintf("#<%"PRIsVALUE" fin>", rb_obj_class(self)); return infect(a, p); } 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 infect(a, p); } 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 infect(a, p); };T;#I"static VALUE;T;$T;&@ ;'IC;[;&@ ;(IC;[;&@ ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@-i[@-i;T;:StringScanner;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!@;I"StringScanner;F;1@flags &= ~STRIO_READWRITE; RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE; ++ptr->count; return copy; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#reopen;F;[[@0;[[@i#;T;;;0;[;{;IC;"gReinitializes *strio* with the given other_StrIO or _string_ and _mode_ (see StringIO#new). ;T;[o;H ;II" overload;F;J0;;;K0;#I"reopen(other_StrIO);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"other_StrIO;T0; @o;H ;II" overload;F;J0;;;K0;#I"reopen(string, mode);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;T0[I" mode;T0; @;[;I"Reinitializes *strio* with the given other_StrIO or _string_ and _mode_ (see StringIO#new). @overload reopen(other_StrIO) @overload reopen(string, mode);T;0; @;@F;Ao;B;CT;Di;Ei ;!@K;"I"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; ; F; ;,;;;I"StringIO#string;F;[;[[@iO;T;;;0;[;{;IC;"9Returns underlying String object, the subject of IO. ;T;[o;H ;II" overload;F;J0;;;K0;#I" string;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"_Returns underlying String object, the subject of IO. @overload string @return [String];T;0; @;@F;Ao;B;CT;DiJ;EiN;!@K;"I"Ustatic VALUE strio_get_string(VALUE self) { return StringIO(self)->string; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#string=;F;[[I" string;T0;[[@i[;T;;F ;0;[;{;IC;"9Changes underlying String object, the subject of IO. ;T;[o;H ;II" overload;F;J0;;F ;K0;#I"string=(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"hChanges underlying String object, the subject of IO. @overload string=(string) @return [String];T;0; @;@F;Ao;B;CT;DiU;EiY;!@K;"I"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; ; F; ;,;;;I"StringIO#lineno;F;[;[[@i;T;;;0;[;{;IC;":Returns the current line number in *strio*. The stringio 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;H ;II" overload;F;J0;;;K0;#I" lineno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"aReturns the current line number in *strio*. The stringio 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; @;@F;Ao;B;CT;Di;Ei;!@K;"I"_static VALUE strio_get_lineno(VALUE self) { return LONG2NUM(StringIO(self)->lineno); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#lineno=;F;[[I" lineno;T0;[[@i;T;;;0;[;{;IC;"pManually sets the current line number to the given value. $. is updated only on the next read. ;T;[o;H ;II" overload;F;J0;;;K0;#I"lineno=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@K;"I"}static VALUE strio_set_lineno(VALUE self, VALUE lineno) { StringIO(self)->lineno = NUM2LONG(lineno); return lineno; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#binmode;F;[;[[@i;T;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" binmode;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @>;[;I"@return [true];T;0; @>;@F;Mi;N0;[; @>;[;I"( @overload binmode @return [true];T;0; @>;@F;Ao;B;CT;Din;Eip;!@K;"I"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; ; F; ;,;;;I"StringIO#close;F;[;[[@ip;T;;;0;[;{;IC;"}Closes strio. The *strio* is unavailable for any further data operations; an +IOError+ is raised if such an attempt is made. ;T;[o;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @Y;[;I"@return [nil];T;0; @Y;@F;Mi;N0;[; @Y;[;I"Closes strio. The *strio* is unavailable for any further data operations; an +IOError+ is raised if such an attempt is made. @overload close @return [nil];T;0; @Y;@F;Ao;B;CT;Dii;Ein;!@K;"I"static VALUE strio_close(VALUE self) { StringIO(self); RBASIC(self)->flags &= ~STRIO_READWRITE; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#close_read;F;[;[[@i;T;;;0;[;{;IC;"`Closes the read end of a StringIO. Will raise an +IOError+ if the *strio* is not readable. ;T;[o;H ;II" overload;F;J0;;;K0;#I"close_read;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @t;[;I"@return [nil];T;0; @t;@F;Mi;N0;[; @t;[;I"Closes the read end of a StringIO. Will raise an +IOError+ if the *strio* is not readable. @overload close_read @return [nil];T;0; @t;@F;Ao;B;CT;Dix;Ei};!@K;"I"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; ; F; ;,;;;I"StringIO#close_write;F;[;[[@i;T;;;0;[;{;IC;"cCloses the write end of a StringIO. Will raise an +IOError+ if the *strio* is not writeable. ;T;[o;H ;II" overload;F;J0;;;K0;#I"close_write;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;I"Closes the write end of a StringIO. Will raise an +IOError+ if the *strio* is not writeable. @overload close_write @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#closed?;F;[;[[@i;T;;;0;[;{;IC;"GReturns +true+ if *strio* is completely closed, +false+ otherwise.;T;[o;H ;II" overload;F;J0;;;K0;#I" closed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"oReturns +true+ if *strio* is completely closed, +false+ otherwise. @overload closed? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@K;"I"zstatic VALUE strio_closed(VALUE self) { StringIO(self); if (!CLOSED(self)) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#closed_read?;F;[;[[@i;T;:closed_read?;0;[;{;IC;"BReturns +true+ if *strio* is not readable, +false+ otherwise.;T;[o;H ;II" overload;F;J0;;] ;K0;#I"closed_read?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"oReturns +true+ if *strio* is not readable, +false+ otherwise. @overload closed_read? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@K;"I"{static VALUE strio_closed_read(VALUE self) { StringIO(self); if (READABLE(self)) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#closed_write?;F;[;[[@i;T;:closed_write?;0;[;{;IC;"BReturns +true+ if *strio* is not writable, +false+ otherwise.;T;[o;H ;II" overload;F;J0;;^ ;K0;#I"closed_write?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"pReturns +true+ if *strio* is not writable, +false+ otherwise. @overload closed_write? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@K;"I"|static VALUE strio_closed_write(VALUE self) { StringIO(self); if (WRITABLE(self)) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#eof;F;[;[[@i;T;;;0;[;{;IC;"wReturns true if *strio* is at end of file. The stringio must be opened for reading or an +IOError+ will be raised. ;T;[o;H ;II" overload;F;J0;;;K0;#I"eof;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" eof?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"Returns true if *strio* is at end of file. The stringio must be opened for reading or an +IOError+ will be raised. @overload eof @return [Boolean] @overload eof? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"static VALUE strio_eof(VALUE self) { struct StringIO *ptr = readable(self); if (ptr->pos < RSTRING_LEN(ptr->string)) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#eof?;F;[;[[@i;T;;;0;[;{;IC;"wReturns true if *strio* is at end of file. The stringio must be opened for reading or an +IOError+ will be raised.;T;[o;H ;II" overload;F;J0;;;K0;#I"eof;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @#;[;I"@return [Boolean];T;0; @#;@F;Mi;N0;[; @#o;H ;II" overload;F;J0;;;K0;#I" eof?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @#;[;I"@return [Boolean];T;0; @#;@F;Mi;N0;[; @#;[;@;0; @#;@F;Ao;B;CT;Di;Ei;Mi;!@K;"I"static VALUE strio_eof(VALUE self) { struct StringIO *ptr = readable(self); if (ptr->pos < RSTRING_LEN(ptr->string)) return Qfalse; return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#fcntl;F;[;[;F;; ;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;; ;K0;#I" fcntl;T;IC;";T;[;[;I";T;0; @J;@F;Mi;N0;[; @J;[;I" @overload fcntl;T;0; @J;@F;Ao;B;CT;Dix;Eiy;!@K;$To; ; F; ;,;;;I"StringIO#flush;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" flush;T;IC;";T;[;[;I";T;0; @];@F;Mi;N0;[; @];[;I" @overload flush;T;0; @];@F;Ao;B;CT;Diz;Ei{;!@K;$To; ; F; ;,;;;I"StringIO#fsync;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" fsync;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @p;[;I"@return [0];T;0; @p;@F;Mi;N0;[; @p;[;I"# @overload fsync @return [0];T;0; @p;@F;Ao;B;CT;Di|;Ei~;!@K;$To; ; F; ;,;;;I"StringIO#pos;F;[;[[@i4;T;;;0;[;{;IC;"6Returns the current offset (in bytes) of *strio*. ;T;[o;H ;II" overload;F;J0;;;K0;#I"pos;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" tell;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"}Returns the current offset (in bytes) of *strio*. @overload pos @return [Integer] @overload tell @return [Integer];T;0; @;@F;Ao;B;CT;Di-;Ei3;!@K;"I"Ystatic VALUE strio_get_pos(VALUE self) { return LONG2NUM(StringIO(self)->pos); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#pos=;F;[[I"pos;T0;[[@i@;T;;;0;[;{;IC;"7Seeks to the given position (in bytes) in *strio*. ;T;[o;H ;II" overload;F;J0;;;K0;#I"pos=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" integer;T0; @;[;I"eSeeks to the given position (in bytes) in *strio*. @overload pos=(integer) @return [Integer];T;0; @;@F;Ao;B;CT;Di:;Ei>;!@K;"I"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; ; F; ;,;;;I"StringIO#rewind;F;[;[[@iS;T;;;0;[;{;IC;"MPositions *strio* to the beginning of input, resetting +lineno+ to zero. ;T;[o;H ;II" overload;F;J0;;;K0;#I" rewind;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[; @;[;I"nPositions *strio* to the beginning of input, resetting +lineno+ to zero. @overload rewind @return [0];T;0; @;@F;Ao;B;CT;DiL;EiQ;!@K;"I"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; ; F; ;,;;;I"StringIO#seek;F;[[@0;[[@ic;T;;;0;[;{;IC;"eSeeks to a given offset _amount_ in the stream according to the value of _whence_ (see IO#seek). ;T;[o;H ;II" overload;F;J0;;;K0;#I""seek(amount, whence=SEEK_SET);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" amount;T0[I" whence;TI" SEEK_SET;T; @;[;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; @;@F;Ao;B;CT;Di\;Eia;!@K;"I"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; ; F; ;,;;;I"StringIO#sync;F;[;[[@i;T;;;0;[;{;IC;"Returns +true+ always. ;T;[o;H ;II" overload;F;J0;;;K0;#I" sync;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" true;T; @ ;[;I"@return [true];T;0; @ ;@F;Mi;N0;[; @ ;[;I"=Returns +true+ always. @overload sync @return [true];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@K;"I"Vstatic VALUE strio_get_sync(VALUE self) { StringIO(self); return Qtrue; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#sync=;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"sync=(boolean);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @&;[;I"@return [Boolean];T;0; @&;@F;Mi;N0;[[I" boolean;T0; @&;[;I"2 @overload sync=(boolean) @return [Boolean];T;0; @&;@F;Ao;B;CT;Di;Ei;!@K;$To; ; F; ;,;;;I"StringIO#tell;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @@;!@K;$To; ; F; ;,;;;I"StringIO#each;F;[[@0;[[@i;T;;;0;[;{;IC;"strio.each_line(sep=$/) {|line| block } -> strio strio.each_line(limit) {|line| block } -> strio strio.each_line(sep,limit) {|line| block } -> strio strio.each_line(...) -> anEnumerator See IO#each. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"each(sep=$/);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @I;[;I"@yield [line];T;0; @I;@F;Mi;N0;[[I"sep;TI"$/;T; @Io;H ;II" overload;F;J0;;;K0;#I"each(limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @I;[;I"@yield [line];T;0; @I;@F;Mi;N0;[[I" limit;T0; @Io;H ;II" overload;F;J0;;;K0;#I"each(sep, limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @I;[;I"@yield [line];T;0; @I;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @Io;H ;II" overload;F;J0;;;K0;#I"each(...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @I;[;I"@return [Enumerator];T;0; @I;@F;Mi;N0;[[I"...;T0; @I;[;I" strio.each_line(sep=$/) {|line| block } -> strio strio.each_line(limit) {|line| block } -> strio strio.each_line(sep,limit) {|line| block } -> strio strio.each_line(...) -> anEnumerator See IO#each. @overload each(sep=$/) @yield [line] @overload each(limit) @yield [line] @overload each(sep, limit) @yield [line] @overload each(...) @return [Enumerator];T;0; @I;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#each_line;F;[[@0;[[@i;T;;w;0;[;{;IC;"strio.each_line(sep=$/) {|line| block } -> strio strio.each_line(limit) {|line| block } -> strio strio.each_line(sep,limit) {|line| block } -> strio strio.each_line(...) -> anEnumerator See IO#each. ;T;[ o;H ;II" overload;F;J0;;;K0;#I"each(sep=$/);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @;[;I"@yield [line];T;0; @;@F;Mi;N0;[[I"sep;TI"$/;T; @o;H ;II" overload;F;J0;;;K0;#I"each(limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @;[;I"@yield [line];T;0; @;@F;Mi;N0;[[I" limit;T0; @o;H ;II" overload;F;J0;;;K0;#I"each(sep, limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @;[;I"@yield [line];T;0; @;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @o;H ;II" overload;F;J0;;;K0;#I"each(...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[[I"...;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#lines;F;[[@0;[[@i;T;;I;0;[;{;IC;";This is a deprecated alias for each_line. ;T;[;[;I"each_line. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"static VALUE strio_lines(int argc, VALUE *argv, VALUE self) { rb_warn("StringIO#lines is deprecated; use #each_line instead"); if (!rb_block_given_p()) return rb_enumeratorize(self, ID2SYM(rb_intern("each_line")), argc, argv); return strio_each(argc, argv, self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#each_byte;F;[;[[@i;T;;x;0;[;{;IC;"See IO#each_byte. ;T;[o;H ;II" overload;F;J0;;x;K0;#I"each_byte;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" byte;T; @;[;I"@yield [byte];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;x;K0;#I"each_byte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @;[;I"@return [Enumerator];T;0; @;@F;Mi;N0;[; @;[;I"gSee IO#each_byte. @overload each_byte @yield [byte] @overload each_byte @return [Enumerator];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I" static VALUE strio_each_byte(VALUE self) { struct StringIO *ptr = readable(self); RETURN_ENUMERATOR(self, 0, 0); while (ptr->pos < RSTRING_LEN(ptr->string)) { char c = RSTRING_PTR(ptr->string)[ptr->pos++]; rb_yield(CHR2FIX(c)); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#bytes;F;[;[[@i;T;;J;0;[;{;IC;"/This is a deprecated alias for #each_byte. ;T;[;[;I"0This is a deprecated alias for #each_byte. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"static VALUE strio_bytes(VALUE self) { rb_warn("StringIO#bytes is deprecated; use #each_byte instead"); if (!rb_block_given_p()) return rb_enumeratorize(self, ID2SYM(rb_intern("each_byte")), 0, 0); return strio_each_byte(self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#each_char;F;[;[[@i;T;;y;0;[;{;IC;"See IO#each_char. ;T;[o;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" char;T; @);[;I"@yield [char];T;0; @);@F;Mi;N0;[; @)o;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @);[;I"@return [Enumerator];T;0; @);@F;Mi;N0;[; @);[;I"gSee IO#each_char. @overload each_char @yield [char] @overload each_char @return [Enumerator];T;0; @);@F;Ao;B;CT;Diy;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#chars;F;[;[[@i;T;;K;0;[;{;IC;";This is a deprecated alias for each_char. ;T;[;[;I"each_char. ;T;0; @Q;@F;Ao;B;CT;Di;Ei;!@K;"I"static VALUE strio_chars(VALUE self) { rb_warn("StringIO#chars is deprecated; use #each_char instead"); if (!rb_block_given_p()) return rb_enumeratorize(self, ID2SYM(rb_intern("each_char")), 0, 0); return strio_each_char(self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#each_codepoint;F;[;[[@i;T;;z;0;[;{;IC;"See IO#each_codepoint. ;T;[o;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"c;T; @_;[;I"@yield [c];T;0; @_;@F;Mi;N0;[; @_o;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Enumerator;T; @_;[;I"@return [Enumerator];T;0; @_;@F;Mi;N0;[; @_;[;I"sSee IO#each_codepoint. @overload each_codepoint @yield [c] @overload each_codepoint @return [Enumerator];T;0; @_;@F;Ao;B;CT;Di;Ei;!@K;"I"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); for (;;) { if (ptr->pos >= RSTRING_LEN(ptr->string)) { return self; } c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_END(ptr->string), &n, enc); rb_yield(UINT2NUM(c)); ptr->pos += n; } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#codepoints;F;[;[[@i;T;;L;0;[;{;IC;"@This is a deprecated alias for each_codepoint. ;T;[;[;I"AThis is a deprecated alias for each_codepoint. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I" static VALUE strio_codepoints(VALUE self) { rb_warn("StringIO#codepoints is deprecated; use #each_codepoint instead"); if (!rb_block_given_p()) return rb_enumeratorize(self, ID2SYM(rb_intern("each_codepoint")), 0, 0); return strio_each_codepoint(self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#getc;F;[;[[@i;T;;;0;[;{;IC;"See IO#getc. ;T;[o;H ;II" overload;F;J0;;;K0;#I" getc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[; @;[;I":See IO#getc. @overload getc @return [String, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#ungetc;F;[[I"c;T0;[[@i;T;;;0;[;{;IC;"Pushes back one character (passed as a parameter) onto *strio* 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;H ;II" overload;F;J0;;;K0;#I"ungetc(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"Pushes back one character (passed as a parameter) onto *strio* 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;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#ungetbyte;F;[[I"c;T0;[[@i";T;;;0;[;{;IC;"See IO#ungetbyte ;T;[o;H ;II" overload;F;J0;;;K0;#I"ungetbyte(fixnum);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I" fixnum;T0; @;[;I"CSee IO#ungetbyte @overload ungetbyte(fixnum) @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei ;!@K;"I"static VALUE strio_ungetbyte(VALUE self, VALUE c) { struct StringIO *ptr = readable(self); check_modifiable(ptr); switch (TYPE(c)) { case T_NIL: return Qnil; case T_FIXNUM: case T_BIGNUM: ; /* rb_int_modulo() not visible from exts */ VALUE v = rb_funcall(c, rb_intern("modulo"), 1, INT2FIX(256)); unsigned char cc = NUM2INT(v) & 0xFF; c = rb_str_new((const char *)&cc, 1); break; default: SafeStringValue(c); } const char *cp = RSTRING_PTR(c); long cl = RSTRING_LEN(c); if (cl == 0) return Qnil; strio_unget_bytes(ptr, cp, cl); RB_GC_GUARD(c); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#getbyte;F;[;[[@i;T;;5;0;[;{;IC;"See IO#getbyte. ;T;[o;H ;II" overload;F;J0;;5;K0;#I" getbyte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;TI"nil;T; @;[;I"@return [Fixnum, nil];T;0; @;@F;Mi;N0;[; @;[;I"@See IO#getbyte. @overload getbyte @return [Fixnum, nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#gets;F;[[@0;[[@i~;T;;;0;[;{;IC;"See IO#gets. ;T;[o;H ;II" overload;F;J0;;;K0;#I"gets(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I"sep;TI"$/;T; @ o;H ;II" overload;F;J0;;;K0;#I"gets(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I" limit;T0; @ o;H ;II" overload;F;J0;;;K0;#I"gets(sep, limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ ;[;I"@return [String, nil];T;0; @ ;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @ ;[;I"See IO#gets. @overload gets(sep=$/) @return [String, nil] @overload gets(limit) @return [String, nil] @overload gets(sep, limit) @return [String, nil];T;0; @ ;@F;Ao;B;CT;Div;Ei~;!@K;"I"\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; ; F; ;,;;;I"StringIO#readlines;F;[[@0;[[@i;T;;;0;[;{;IC;"See IO#readlines. ;T;[o;H ;II" overload;F;J0;;;K0;#I"readlines(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @M;[;I"@return [Array];T;0; @M;@F;Mi;N0;[[I"sep;TI"$/;T; @Mo;H ;II" overload;F;J0;;;K0;#I"readlines(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @M;[;I"@return [Array];T;0; @M;@F;Mi;N0;[[I" limit;T0; @Mo;H ;II" overload;F;J0;;;K0;#I"readlines(sep,limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @M;[;I"@return [Array];T;0; @M;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @M;[;I"See IO#readlines. @overload readlines(sep=$/) @return [Array] @overload readlines(limit) @return [Array] @overload readlines(sep,limit) @return [Array];T;0; @M;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#read;F;[[@0;[[@ic;T;;;0;[;{;IC;"See IO#read. ;T;[o;H ;II" overload;F;J0;;;K0;#I"read([length [, outbuf]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[[I"[length [, outbuf]];T0; @;[;I"OSee IO#read. @overload read([length [, outbuf]]) @return [String, nil];T;0; @;@F;Ao;B;CT;Di];Eia;!@K;"I"static VALUE strio_read(int argc, VALUE *argv, VALUE self) { struct StringIO *ptr = readable(self); VALUE str = Qnil; long len; int binary = 0; rb_check_arity(argc, 0, 2); 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 = binary ? rb_ascii8bit_encoding() : 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; } 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; ; F; ;,;;;I"StringIO#write;F;[[@0;[[@i;T;;;0;[;{;IC;"Appends the given string to the underlying buffer string of *strio*. 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;H ;II" overload;F;J0;;;K0;#I"write(string, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" string;T0[I"...;T0; @o;H ;II" overload;F;J0;;;K0;#I"syswrite(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"]Appends the given string to the underlying buffer string of *strio*. 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;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#putc;F;[[I"ch;T0;[[@iC;T;;;0;[;{;IC;"See IO#putc. ;T;[o;H ;II" overload;F;J0;;;K0;#I"putc(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @;[;I"@return [Object];T;0; @;@F;Mi;N0;[[I"obj;T0; @;[;I":See IO#putc. @overload putc(obj) @return [Object];T;0; @;@F;Ao;B;CT;Di=;EiA;!@K;"I"=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; ; F; ;,;;;I"StringIO#isatty;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" isatty;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" tty?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;I"F @overload isatty @return [nil] @overload tty? @return [nil];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;$To; ; F; ;,;;;I"StringIO#tty?;F;[;[;F;;;;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;Mi;!@K;$To; ; F; ;,;;;I"StringIO#pid;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I"pid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @*;[;I"@return [nil];T;0; @*;@F;Mi;N0;[; @*;[;I"# @overload pid @return [nil];T;0; @*;@F;Ao;B;CT;Di;Ei;!@K;$To; ; F; ;,;;;I"StringIO#fileno;F;[;[;F;;;;0;[;{;IC;" ;T;[o;H ;II" overload;F;J0;;;K0;#I" fileno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @B;[;I"@return [nil];T;0; @B;@F;Mi;N0;[; @B;[;I"& @overload fileno @return [nil];T;0; @B;@F;Ao;B;CT;Di;Ei;!@K;$To; ; F; ;,;;;I"StringIO#size;F;[;[[@i;T;;;0;[;{;IC;"+Returns the size of the buffer string. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Z;[;I"@return [Integer];T;0; @Z;@F;Mi;N0;[; @Zo;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @Z;[;I"@return [Integer];T;0; @Z;@F;Mi;N0;[; @Z;[;I"uReturns the size of the buffer string. @overload length @return [Integer] @overload size @return [Integer];T;0; @Z;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#length;F;[;[[@i;T;;;0;[;{;IC;"+Returns the size of the buffer string. ;T;[o;H ;II" overload;F;J0;;;K0;#I" length;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;;K0;#I" size;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;@~;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#truncate;F;[[I"len;T0;[[@i;T;;;0;[;{;IC;"dTruncates the buffer string to at most _integer_ bytes. The *strio* must be opened for writing. ;T;[o;H ;II" overload;F;J0;;;K0;#I"truncate(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[I" integer;T0; @;[;I"Truncates the buffer string to at most _integer_ bytes. The *strio* must be opened for writing. @overload truncate(integer) @return [0];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#external_encoding;F;[;[[@i;T;;;0;[;{;IC;"Returns the Encoding object that represents the encoding of the file. If strio is write mode and no encoding is specified, returns nil. ;T;[o;H ;II" overload;F;J0;;;K0;#I"external_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @;[;I"@return [Encoding];T;0; @;@F;Mi;N0;[; @;[;I"Returns the Encoding object that represents the encoding of the file. If strio is write mode and no encoding is specified, returns nil. @overload external_encoding @return [Encoding];T;0; @;@F;Ao;B;CT;Di;Ei;!@K;"I"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; ; F; ;,;;;I"StringIO#internal_encoding;F;[;[[@i&;T;;;0;[;{;IC;"dReturns the Encoding of the internal string if conversion is specified. Otherwise returns nil. ;T;[o;H ;II" overload;F;J0;;;K0;#I"internal_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @;[;I"@return [Encoding];T;0; @;@F;Mi;N0;[; @;[;I"Returns the Encoding of the internal string if conversion is specified. Otherwise returns nil. @overload internal_encoding @return [Encoding];T;0; @;@F;Ao;B;CT;Di;Ei#;!@K;"I"Jstatic VALUE strio_internal_encoding(VALUE self) { return Qnil; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"StringIO#set_encoding;F;[[@0;[[@i6;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;H ;II" overload;F;J0;;;K0;#I",set_encoding(ext_enc, [int_enc[, opt]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" ext_enc;T0[I"[int_enc[, opt]];T0; @;[;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; @;@F;Ao;B;CT;Di,;Ei2;!@K;"I"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;$T;&@K;'IC;[;&@K;(IC;[@C@j@˫;&@K;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i^;F;: StringIO;;0;;;[;{;IC;" ;T;[;[;@;0; @K;Mi;!@;I" StringIO;F;1@S6o; ;IC;[o; ;IC;[ o; ; F; ;,;;;I"CGI::Escape#escapeHTML;F;[[I"str;T0;[[I"ext/cgi/escape/escape.c;Ti?;T;:escapeHTML;0;[;{;IC;"!Returns HTML-escaped string. ;T;[o;H ;II" overload;F;J0;;` ;K0;#I"escapeHTML(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @,;[;I"@return [String];T;0; @,;@F;Mi;N0;[[I" string;T0; @,;[;I"TReturns HTML-escaped string. @overload escapeHTML(string) @return [String];T;0; @,;@F;Ao;B;CT;Di8;Ei=;!@*;"I"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; ; F; ;,;;;I"CGI::Escape#unescapeHTML;F;[[I"str;T0;[[@3iS;T;:unescapeHTML;0;[;{;IC;"#Returns HTML-unescaped string. ;T;[o;H ;II" overload;F;J0;;a ;K0;#I"unescapeHTML(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @L;[;I"@return [String];T;0; @L;@F;Mi;N0;[[I" string;T0; @L;[;I"XReturns HTML-unescaped string. @overload unescapeHTML(string) @return [String];T;0; @L;@F;Ao;B;CT;DiL;EiQ;!@*;"I"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; ; F; ;,;;;I"CGI::Escape#escape;F;[[I"str;T0;[[@3ig;T;;;0;[;{;IC;" Returns URL-escaped string. ;T;[o;H ;II" overload;F;J0;;;K0;#I"escape(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @k;[;I"@return [String];T;0; @k;@F;Mi;N0;[[I" string;T0; @k;[;I"OReturns URL-escaped string. @overload escape(string) @return [String];T;0; @k;@F;Ao;B;CT;Di`;Eie;!@*;"I"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; ; F; ;,;;;I"CGI::Escape#unescape;F;[[@0;[[@3i;T;: unescape;0;[;{;IC;""Returns URL-unescaped string. ;T;[o;H ;II" overload;F;J0;;b ;K0;#I"0unescape(string, encoding=@@accept_charset);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" string;T0[I" encoding;TI"@@accept_charset;T; @;[;I"nReturns URL-unescaped string. @overload unescape(string, encoding=@@accept_charset) @return [String];T;0; @;@F;Ao;B;CT;Di|;Ei;!@*;"I"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;-{;.[;[[@3i;F;: Escape;;0;;;[;{;IC;" ;T;[;[;@;0; @*;Mi;!@(;I"CGI::Escape;Fo; ;IC;[;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@3i;F;: Util;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@(;I"CGI::Util;F;&@(;'IC;[;&@(;(IC;[;&@(;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@3i;F;:CGI;;0;;;[;{;IC;" ;T;[;[;@;0; @(;!@;I"CGI;F;1@ # UDPSocket.new(Socket::AF_INET6) #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new([address_family]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"\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; ; F; ;,;;;I"UDPSocket#connect;F;[[I" host;T0[I" port;T0;[[@iZ;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;H ;II" overload;F;J0;;;K0;#I"connect(host, port);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiJ;EiX;!@;"I"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; ; F; ;,;;;I"UDPSocket#bind;F;[[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;H ;II" overload;F;J0;;;K0;#I"bind(host, port) #=> 0;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Diz;Ei~;!@;"I"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; ; F; ;,;;;I"UDPSocket#send;F;[[@0;[[@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;H ;II" overload;F;J0;;};K0;#I""send(mesg, flags, host, port);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[ [I" mesg;T0[I" flags;T0[I" host;T0[I" port;T0; @7o;H ;II" overload;F;J0;;};K0;#I"#send(mesg, flags, sockaddr_to);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I" mesg;T0[I" flags;T0[I"sockaddr_to;T0; @7o;H ;II" overload;F;J0;;};K0;#I"send(mesg, flags);T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[[I" mesg;T0[I" flags;T0; @7;[;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; @7;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I""UDPSocket#__recvfrom_nonblock;F;[ [I"len;T0[I"flg;T0[I"str;T0[I"ex;T0;[[@i;T;:__recvfrom_nonblock;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @p;@F;Ao;B;CT;Di;Ei;!@;"I"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;;0;;;[;{;IC;"*UDPSocket represents a UDP/IP socket. ;T;[;[;I"- UDPSocket represents a UDP/IP socket. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"UDPSocket;F;1o;2 ;30;40;50;: IPSocket;!@;7o; ;IC;[ o; ; F; ;,;;;I"IPSocket#inspect;F;[;[[I"ext/socket/ipsocket.c;Ti;T;;i;0;[;{;IC;"5Return a string describing this IPSocket object. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"\Return a string describing this IPSocket object. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IPSocket#addr;F;[[@0;[[@i;T;: addr;0;[;{;IC;"4Returns 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 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;H ;II" overload;F;J0;;i ;K0;#I"addr([reverse_lookup]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"[reverse_lookup];T0; @;[;I"jReturns 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 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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"IPSocket#peeraddr;F;[[@0;[[@i%;T;: peeraddr;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 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;H ;II" overload;F;J0;;j ;K0;#I"peeraddr([reverse_lookup]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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 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;Ao;B;CT;Di ;Ei#;!@;"I"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; ; F; ;,;;;I"IPSocket#recvfrom;F;[[@0;[[@iK;T;: recvfrom;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 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;H ;II" overload;F;J0;;k ;K0;#I"recvfrom(maxlen);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" maxlen;T0; @o;H ;II" overload;F;J0;;k ;K0;#I"recvfrom(maxlen, flags);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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 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;Ao;B;CT;Di6;EiJ;!@;"I"|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; ; F; ;;;;I"IPSocket.getaddress;F;[[I" host;T0;[[@i];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;H ;II" overload;F;J0;;l ;K0;#I"getaddress(host);T;IC;";T;[;[;I";T;0; @";@F;Mi;N0;[[I" host;T0; @";[;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; @";@F;Ao;B;CT;DiQ;EiZ;!@;"I"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;-{;.[;[[@in[@is;T;;h ;;0;;;[;{;IC;" IPSocket is the super class of TCPSocket and UDPSocket. ;T;0; @;@F;Ao;B;CT;Din;Eip;!@;I" IPSocket;F;1o;2 ;30;40;50;:BasicSocket;!@;7o; ;IC;[o; ; F; ;;;;I"&BasicSocket.do_not_reverse_lookup;F;[;[[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;H ;II" overload;F;J0;;n ;K0;#I"do_not_reverse_lookup;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Q;[;I"@return [Boolean];T;0; @Q;@F;Mi;N0;[; @Q;[;I"Gets the global do_not_reverse_lookup flag. BasicSocket.do_not_reverse_lookup #=> false @overload do_not_reverse_lookup @return [Boolean];T;0; @Q;@F;Ao;B;CT;Di;Ei;!@O;"I"hstatic VALUE bsock_do_not_rev_lookup(void) { return rsock_do_not_reverse_lookup?Qtrue:Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"'BasicSocket.do_not_reverse_lookup=;F;[[I"val;T0;[[@Vi;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;H ;II" overload;F;J0;;o ;K0;#I"!do_not_reverse_lookup=(bool);T;IC;";T;[;[;I";T;0; @m;@F;Mi;N0;[[I" bool;T0; @m;[;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; @m;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;;;;I"BasicSocket.for_fd;F;[[I"fd;T0;[[@Vi;T;;;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;H ;II" overload;F;J0;;;K0;#I"for_fd(fd);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"fd;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@O;"I"static VALUE bsock_s_for_fd(VALUE klass, VALUE fd) { rb_io_t *fptr; VALUE sock = rsock_init_sock(rb_obj_alloc(klass), NUM2INT(fd)); GetOpenFile(sock, fptr); return sock; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"BasicSocket#close_read;F;[;[[@Vid;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;H ;II" overload;F;J0;;;K0;#I"close_read;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiZ;Eib;!@O;"I"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; ; F; ;,;;;I"BasicSocket#close_write;F;[;[[@Vi};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;H ;II" overload;F;J0;;;K0;#I"close_write;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Dis;Ei{;!@O;"I"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; ; F; ;,;;;I"BasicSocket#shutdown;F;[[@0;[[@ViC;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;H ;II" overload;F;J0;;p ;K0;#I"shutdown([how]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di(;EiA;!@O;"I"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; ; F; ;,;;;I"BasicSocket#setsockopt;F;[[@0;[[@Vi;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;H ;II" overload;F;J0;;q ;K0;#I"'setsockopt(level, optname, optval);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" level;T0[I" optname;T0[I" optval;T0; @o;H ;II" overload;F;J0;;q ;K0;#I"setsockopt(socketoption);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@O;"I"^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; ; F; ;,;;;I"BasicSocket#getsockopt;F;[[I"lev;T0[I" optname;T0;[[@Vi/;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.unpack("i")[0] 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;H ;II" overload;F;J0;;r ;K0;#I"getsockopt(level, optname);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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.unpack("i")[0] 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;Ao;B;CT;Di;Ei+;!@O;"I"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; ; F; ;,;;;I"BasicSocket#getsockname;F;[;[[@Vi`;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;H ;II" overload;F;J0;;s ;K0;#I"getsockname;T;IC;";T;[;[;I";T;0; @:;@F;Mi;N0;[; @:;[;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;Ao;B;CT;DiS;Ei];!@O;"I"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; ; F; ;,;;;I"BasicSocket#getpeername;F;[;[[@Vi;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;H ;II" overload;F;J0;;t ;K0;#I"getpeername;T;IC;";T;[;[;I";T;0; @P;@F;Mi;N0;[; @P;[;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; @P;@F;Ao;B;CT;Dio;Ei|;!@O;"I"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; ; F; ;,;;;I"BasicSocket#getpeereid;F;[;[[@Vi;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;H ;II" overload;F;J0;;u ;K0;#I"getpeereid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @f;[;I"@return [Array];T;0; @f;@F;Mi;N0;[; @f;[;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; @f;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"BasicSocket#local_address;F;[;[[@Vi;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;H ;II" overload;F;J0;;v ;K0;#I"local_address;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"BasicSocket#remote_address;F;[;[[@Vi;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;H ;II" overload;F;J0;;w ;K0;#I"remote_address;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I"BasicSocket#send;F;[[@0;[[@Vi;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;H ;II" overload;F;J0;;};K0;#I"(send(mesg, flags [, dest_sockaddr]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei;!@O;"I"iVALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock) { struct rsock_send_arg arg; VALUE flags, to; rb_io_t *fptr; ssize_t n; 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)"; } GetOpenFile(sock, fptr); arg.fd = fptr->fd; arg.flags = NUM2INT(flags); while (rsock_maybe_fd_writable(arg.fd), (n = (ssize_t)BLOCKING_REGION_FD(func, &arg)) < 0) { if (rb_io_wait_writable(arg.fd)) { continue; } rb_sys_fail(funcname); } return SSIZET2NUM(n); };T;#I" VALUE;T;$To; ; F; ;,;;;I"BasicSocket#recv;F;[[@0;[[@Vi;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;H ;II" overload;F;J0;;x ;K0;#I"$recv(maxlen[, flags[, outbuf]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dix;Ei;!@O;"I"}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; ; F; ;,;;;I"&BasicSocket#do_not_reverse_lookup;F;[;[[@ViR;T;;n ;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;H ;II" overload;F;J0;;n ;K0;#I"do_not_reverse_lookup;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiA;EiP;!@O;"I"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; ; F; ;,;;;I"'BasicSocket#do_not_reverse_lookup=;F;[[I" state;T0;[[@Vii;T;;o ;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;H ;II" overload;F;J0;;o ;K0;#I"!do_not_reverse_lookup=(bool);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di[;Eif;!@O;"I"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; ; F; ;,;;;I" BasicSocket#__recv_nonblock;F;[ [I"len;T0[I"flg;T0[I"str;T0[I"ex;T0;[[@Vi;T;:__recv_nonblock;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@O;"I"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; ; F; ;,;;;I" BasicSocket#__read_nonblock;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @,;!@O;$To; ; F; ;,;;;I"!BasicSocket#__write_nonblock;F;[;[;F;;;;0;[;{;IC;" ;T;[;[;@;0; @5;!@O;$To; ; F; ;,;;;I"BasicSocket#__sendmsg;F;[ [I" data;T0[I" flags;T0[I"dest_sockaddr;T0[I" controls;T0;[[I"ext/socket/ancdata.c;Ti;T;:__sendmsg;0;[;{;IC;" ;T;[;[;@;0; @>;!@O;"I"VALUE rsock_bsock_sendmsg(VALUE sock, VALUE data, VALUE flags, VALUE dest_sockaddr, VALUE controls) { return bsock_sendmsg_internal(sock, data, flags, dest_sockaddr, controls, Qtrue, 0); };T;#I" VALUE;T;$To; ; F; ;,;;;I"#BasicSocket#__sendmsg_nonblock;F;[ [I" data;T0[I" flags;T0[I"dest_sockaddr;T0[I" controls;T0[I"ex;T0;[[@Ki";T;:__sendmsg_nonblock;0;[;{;IC;" ;T;[;[;@;0; @S;!@O;"I"VALUE rsock_bsock_sendmsg_nonblock(VALUE sock, VALUE data, VALUE flags, VALUE dest_sockaddr, VALUE controls, VALUE ex) { return bsock_sendmsg_internal(sock, data, flags, dest_sockaddr, controls, ex, 1); };T;#I" VALUE;T;$To; ; F; ;,;;;I"BasicSocket#__recvmsg;F;[ [I" dlen;T0[I" flags;T0[I" clen;T0[I"scm_rights;T0;[[@Ki;T;:__recvmsg;0;[;{;IC;" ;T;[;[;@;0; @i;!@O;"I"VALUE rsock_bsock_recvmsg(VALUE sock, VALUE dlen, VALUE flags, VALUE clen, VALUE scm_rights) { VALUE ex = Qtrue; return bsock_recvmsg_internal(sock, dlen, flags, clen, scm_rights, ex, 0); };T;#I" VALUE;T;$To; ; F; ;,;;;I"#BasicSocket#__recvmsg_nonblock;F;[ [I" dlen;T0[I" flags;T0[I" clen;T0[I"scm_rights;T0[I"ex;T0;[[@Ki;T;:__recvmsg_nonblock;0;[;{;IC;" ;T;[;[;@;0; @};!@O;"I"VALUE rsock_bsock_recvmsg_nonblock(VALUE sock, VALUE dlen, VALUE flags, VALUE clen, VALUE scm_rights, VALUE ex) { return bsock_recvmsg_internal(sock, dlen, flags, clen, scm_rights, ex, 1); };T;#I" VALUE;T;$T;&@O;'IC;[;&@O;(IC;[;&@O;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Vi[@Vi;T;;m ;;0;;;[;{;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; @O;@F;Ao;B;CT;Di;Ei;!@;I"BasicSocket;F;1o;2 ;30;40;50;;;!@;7@;F0;F0;F0o; ;IC;[ o; ; F; ;,;;;I"UNIXServer#initialize;F;[[I" path;T0;[[I"ext/socket/unixserver.c;Ti;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(path);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"jstatic VALUE unix_svr_init(VALUE sock, VALUE path) { return rsock_init_unixsock(sock, path, 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UNIXServer#accept;F;[;[[@i6;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;H ;II" overload;F;J0;;;K0;#I" accept;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di%;Ei3;!@;"I"&static VALUE unix_accept(VALUE sock) { rb_io_t *fptr; struct sockaddr_un from; socklen_t fromlen; GetOpenFile(sock, fptr); fromlen = (socklen_t)sizeof(struct sockaddr_un); return rsock_s_accept(rb_cUNIXSocket, fptr->fd, (struct sockaddr*)&from, &fromlen); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"!UNIXServer#__accept_nonblock;F;[[I"ex;T0;[[@iD;T;:__accept_nonblock;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;DiC;EiC;!@;"I"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; ; F; ;,;;;I"UNIXServer#sysaccept;F;[;[[@ic;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;H ;II" overload;F;J0;; ;K0;#I"sysaccept;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiQ;Ei`;!@;"I"static VALUE unix_sysaccept(VALUE sock) { rb_io_t *fptr; struct sockaddr_un from; socklen_t fromlen; GetOpenFile(sock, fptr); fromlen = (socklen_t)sizeof(struct sockaddr_un); return rsock_s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UNIXServer#listen;F;[;[;F;: listen;;0;[;{;IC;" ;T;[;[;@;0; @;!@;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iu[@i{;T;:UNIXServer;;0;;;[;{;IC;">UNIXServer represents a UNIX domain stream server socket. ;T;[;[;I"A UNIXServer represents a UNIX domain stream server socket. ;T;0; @;@F;Ao;B;CT;Diu;Eix;!@;I"UNIXServer;F;1o;2 ;30;40;50;:UNIXSocket;!@;7o; ;IC;[o; ; F; ;,;;;I"UNIXSocket#initialize;F;[[I" path;T0;[[I"ext/socket/unixsocket.c;Ti|;T;;;0;[;{;IC;"Creates a new UNIX client socket connected to _path_. require 'socket' s = UNIXSocket.new("/tmp/sock") s.send "hello", 0 ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(path);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Diu;Ei~;!@;"I"fstatic VALUE unix_init(VALUE sock, VALUE path) { return rsock_init_unixsock(sock, path, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"UNIXSocket#path;F;[;[[@$i;T;;;0;[;{;IC;"wReturns the path of the local address of unixsocket. s = UNIXServer.new("/tmp/sock") p s.path #=> "/tmp/sock" ;T;[o;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[;[;I";T;0; @8;@F;Mi;N0;[; @8;[;I"Returns the path of the local address of unixsocket. s = UNIXServer.new("/tmp/sock") p s.path #=> "/tmp/sock" @overload path;T;0; @8;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"UNIXSocket#addr;F;[;[[@$i;T;;i ;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;H ;II" overload;F;J0;;i ;K0;#I" addr;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @N;[;I"@return [Array];T;0; @N;@F;Mi;N0;[; @N;[;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; @N;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"UNIXSocket#peeraddr;F;[;[[@$i ;T;;j ;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;H ;II" overload;F;J0;;j ;K0;#I" peeraddr;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @i;[;I"@return [Array];T;0; @i;@F;Mi;N0;[; @i;[;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; @i;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"UNIXSocket#recvfrom;F;[[@0;[[@$i;T;;k ;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;H ;II" overload;F;J0;;k ;K0;#I")recvfrom(maxlen [, flags[, outbuf]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"maxlen[, flags[, outbuf]];T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"{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; ; F; ;,;;;I"UNIXSocket#send_io;F;[[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;H ;II" overload;F;J0;; ;K0;#I"send_io(io);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @;[;I"@return [nil];T;0; @;@F;Mi;N0;[[I"io;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"UNIXSocket#recv_io;F;[[@0;[[@$iN;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;H ;II" overload;F;J0;; ;K0;#I"recv_io([klass [, mode]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @;[;I"@return [IO];T;0; @;@F;Mi;N0;[[I"[klass [, mode]];T0; @;[;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; @;@F;Ao;B;CT;Di4;EiL;!@;"I"static 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); if (rsock_cmsg_cloexec_state < 0) rsock_cmsg_cloexec_state = rsock_detect_cloexec(fd); if (rsock_cmsg_cloexec_state == 0 || fd <= 2) 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; ; F; ;;;;I"UNIXSocket.socketpair;F;[[@0;[[@$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;H ;II" overload;F;J0;: pair;K0;#I"pair([type [, protocol]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"[type [, protocol]];T0; @o;H ;II" overload;F;J0;; ;K0;#I"$socketpair([type [, protocol]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei*;!@;"I"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; ; F; ;;;;I"UNIXSocket.pair;F;[[@0;[[@$i+;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"pair([type [, protocol]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"[type [, protocol]];T0; @ o;H ;II" overload;F;J0;; ;K0;#I"$socketpair([type [, protocol]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[I"[type [, protocol]];T0; @ ;[;@;0; @ ;@F;Ao;B;CT;Di;Ei*;!@;"I"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;-{;.[;[[@$iD[@$iI;T;; ;;0;;;[;{;IC;">UNIXSocket represents a UNIX domain stream client socket. ;T;[;[;I"@ UNIXSocket represents a UNIX domain stream client socket. ;T;0; @;@F;Ao;B;CT;DiD;EiF;!@;I"UNIXSocket;F;1o;2 ;30;40;50;;m ;!@;7@O;F0;F0@o; ;IC;[ o; ; F; ;,;;;I"TCPServer#accept;F;[;[[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;H ;II" overload;F;J0;;;K0;#I" accept;T;IC;";T;[;[;I";T;0; @M;@F;Mi;N0;[; @M;[;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; @M;@F;Ao;B;CT;Di/;Ei9;!@K;"I"static VALUE tcp_accept(VALUE sock) { rb_io_t *fptr; union_sockaddr from; socklen_t fromlen; GetOpenFile(sock, fptr); fromlen = (socklen_t)sizeof(from); return rsock_s_accept(rb_cTCPSocket, fptr->fd, &from.addr, &fromlen); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" TCPServer#__accept_nonblock;F;[[I"ex;T0;[[@RiI;T;;~ ;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @d;@F;Ao;B;CT;DiH;EiH;!@K;"I"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; ; F; ;,;;;I"TCPServer#sysaccept;F;[;[[@Rib;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;H ;II" overload;F;J0;; ;K0;#I"sysaccept;T;IC;";T;[;[;I";T;0; @t;@F;Mi;N0;[; @t;[;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; @t;@F;Ao;B;CT;DiT;Ei_;!@K;"I"static VALUE tcp_sysaccept(VALUE sock) { rb_io_t *fptr; union_sockaddr from; socklen_t fromlen; GetOpenFile(sock, fptr); fromlen = (socklen_t)sizeof(from); return rsock_s_accept(0, fptr->fd, &from.addr, &fromlen); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TCPServer#initialize;F;[[@0;[[@Ri&;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new([hostname,] port);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei#;!@K;"I"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); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"TCPServer#listen;F;[;[;F;; ;;0;[;{;IC;" ;T;[;[;@;0; @;!@K;$T;&@K;'IC;[;&@K;(IC;[;&@K;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Riq[@Ri;T;:TCPServer;;0;;;[;{;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; @K;@F;Ao;B;CT;Diq;Ei;!@;I"TCPServer;F;1o;2 ;30;40;50;:TCPSocket;!@;7o; ;IC;[o; ; F; ;;;;I"TCPSocket.gethostbyname;F;[[I" host;T0;[[I"ext/socket/tcpsocket.c;Ti@;T;:gethostbyname;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;H ;II" overload;F;J0;; ;K0;#I"gethostbyname(hostname);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di-;Ei>;!@;"I"static VALUE tcp_s_gethostbyname(VALUE obj, VALUE host) { 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; ; F; ;,;;;I"TCPSocket#initialize;F;[[@0;[[@i;T;;;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. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Bnew(remote_host, remote_port, local_host=nil, local_port=nil);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[ [I"remote_host;T0[I"remote_port;T0[I"local_host;TI"nil;T[I"local_port;TI"nil;T; @;[;I"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. @overload new(remote_host, remote_port, local_host=nil, local_port=nil);T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"Pstatic VALUE tcp_init(int argc, VALUE *argv, VALUE sock) { VALUE remote_host, remote_serv; VALUE local_host, local_serv; rb_scan_args(argc, argv, "22", &remote_host, &remote_serv, &local_host, &local_serv); return rsock_init_inetsock(sock, remote_host, remote_serv, local_host, local_serv, INET_CLIENT); };T;#I"static VALUE;T;$T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iK[@i];T;; ;;0;;;[;{;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;Ao;B;CT;DiK;EiZ;!@;I"TCPSocket;F;1o;2 ;30;40;50;;h ;!@;7@;F0;F0o; ;IC;[0o; ; F; ;,;;;I"Addrinfo#initialize;F;[[@0;[[I"ext/socket/raddrinfo.c;Ti ;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(sockaddr);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" sockaddr;T0; @o;H ;II" overload;F;J0;; ;K0;#I"new(sockaddr, family);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" sockaddr;T0[I" family;T0; @o;H ;II" overload;F;J0;; ;K0;#I"$new(sockaddr, family, socktype);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" sockaddr;T0[I" family;T0[I" socktype;T0; @o;H ;II" overload;F;J0;; ;K0;#I".new(sockaddr, family, socktype, protocol);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[ [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;Ao;B;CT;Di;Ei ;!@;"I" 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; ; F; ;,;;;I"Addrinfo#inspect;F;[;[[@i;T;;i;0;[;{;IC;"returns a string which shows addrinfo in human-readable form. Addrinfo.tcp("localhost", 80).inspect #=> "#" Addrinfo.unix("/tmp/sock").inspect #=> "#" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @[;[;I"@return [String];T;0; @[;@F;Mi;N0;[; @[;[;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; @[;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Addrinfo#inspect_sockaddr;F;[;[[@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;H ;II" overload;F;J0;; ;K0;#I"inspect_sockaddr;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @v;[;I"@return [String];T;0; @v;@F;Mi;N0;[; @v;[;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; @v;@F;Ao;B;CT;Di;Ei;!@;"I"pVALUE rsock_addrinfo_inspect_sockaddr(VALUE self) { return inspect_sockaddr(self, rb_str_new("", 0)); };T;#I" VALUE;T;$To; ; F; ;;;;I"Addrinfo.getaddrinfo;F;[[@0;[[@iG ;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;H ;II" overload;F;J0;; ;K0;#I"Fgetaddrinfo(nodename, service, family, socktype, protocol, flags);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[ [I" nodename;T0[I" service;T0[I" family;T0[I" socktype;T0[I" protocol;T0[I" flags;T0; @o;H ;II" overload;F;J0;; ;K0;#I"?getaddrinfo(nodename, service, family, socktype, protocol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[ [I" nodename;T0[I" service;T0[I" family;T0[I" socktype;T0[I" protocol;T0; @o;H ;II" overload;F;J0;; ;K0;#I"5getaddrinfo(nodename, service, family, socktype);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[ [I" nodename;T0[I" service;T0[I" family;T0[I" socktype;T0; @o;H ;II" overload;F;J0;; ;K0;#I"+getaddrinfo(nodename, service, family);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" nodename;T0[I" service;T0[I" family;T0; @o;H ;II" overload;F;J0;; ;K0;#I"#getaddrinfo(nodename, service);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;EiI ;!@;"I"3static VALUE addrinfo_s_getaddrinfo(int argc, VALUE *argv, VALUE self) { VALUE node, service, family, socktype, protocol, flags; rb_scan_args(argc, argv, "24", &node, &service, &family, &socktype, &protocol, &flags); return addrinfo_list_new(node, service, family, socktype, protocol, flags); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Addrinfo.ip;F;[[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;H ;II" overload;F;J0;; ;K0;#I" ip(host);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;DiP ;EiX ;!@;"I"*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; ; F; ;;;;I"Addrinfo.tcp;F;[[I" host;T0[I" port;T0;[[@ip ;T;:tcp;0;[;{;IC;"returns an addrinfo object for TCP address. Addrinfo.tcp("localhost", "smtp") #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"tcp(host, port);T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[[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;Ao;B;CT;Dih ;Eim ;!@;"I"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; ; F; ;;;;I"Addrinfo.udp;F;[[I" host;T0[I" port;T0;[[@i ;T;:udp;0;[;{;IC;"returns an addrinfo object for UDP address. Addrinfo.udp("localhost", "daytime") #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"udp(host, port);T;IC;";T;[;[;I";T;0; @A;@F;Mi;N0;[[I" host;T0[I" port;T0; @A;[;I"returns an addrinfo object for UDP address. Addrinfo.udp("localhost", "daytime") #=> # @overload udp(host, port);T;0; @A;@F;Ao;B;CT;Diw ;Ei| ;!@;"I"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; ; F; ;;;;I"Addrinfo.unix;F;[[@0;[[@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;H ;II" overload;F;J0;; ;K0;#I"unix(path [, socktype]);T;IC;";T;[;[;I";T;0; @_;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@;"I"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); OBJ_INFECT(addr, path); return addr; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#afamily;F;[;[[@i;T;: afamily;0;[;{;IC;"sreturns the address family as an integer. Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true ;T;[o;H ;II" overload;F;J0;; ;K0;#I" afamily;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @x;[;I"@return [Integer];T;0; @x;@F;Mi;N0;[; @x;[;I"returns the address family as an integer. Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true @overload afamily @return [Integer];T;0; @x;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Addrinfo#pfamily;F;[;[[@i;T;: pfamily;0;[;{;IC;"treturns the protocol family as an integer. Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true ;T;[o;H ;II" overload;F;J0;; ;K0;#I" pfamily;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"returns the protocol family as an integer. Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true @overload pfamily @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"|static VALUE addrinfo_pfamily(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return INT2NUM(rai->pfamily); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#socktype;F;[;[[@i;T;: socktype;0;[;{;IC;"ureturns the socket type as an integer. Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true ;T;[o;H ;II" overload;F;J0;; ;K0;#I" socktype;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"returns the socket type as an integer. Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true @overload socktype @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"~static VALUE addrinfo_socktype(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return INT2NUM(rai->socktype); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#protocol;F;[;[[@i;T;: protocol;0;[;{;IC;"ureturns the socket type as an integer. Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true ;T;[o;H ;II" overload;F;J0;; ;K0;#I" protocol;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"returns the socket type as an integer. Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true @overload protocol @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"~static VALUE addrinfo_protocol(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return INT2NUM(rai->protocol); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#canonname;F;[;[[@i;T;:canonname;0;[;{;IC;"returns the canonical name as an 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;H ;II" overload;F;J0;; ;K0;#I"canonname;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @;[;I"@return [String, nil];T;0; @;@F;Mi;N0;[; @;[;I"returns the canonical name as an 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;Ao;B;CT;Di;Ei;!@;"I"|static VALUE addrinfo_canonname(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return rai->canonname; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#ipv4?;F;[;[[@i9;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;H ;II" overload;F;J0;; ;K0;#I" ipv4?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di-;Ei7;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6?;F;[;[[@iL;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;H ;II" overload;F;J0;; ;K0;#I" ipv6?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di@;EiJ;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#unix?;F;[;[[@ic;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;H ;II" overload;F;J0;; ;K0;#I" unix?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @6;[;I"@return [Boolean];T;0; @6;@F;Mi;N0;[; @6;[;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; @6;@F;Ao;B;CT;DiW;Eia;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ip?;F;[;[[@i%;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;H ;II" overload;F;J0;; ;K0;#I"ip?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @Q;[;I"@return [Boolean];T;0; @Q;@F;Mi;N0;[; @Q;[;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; @Q;@F;Ao;B;CT;Di;Ei#;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ip_unpack;F;[;[[@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;H ;II" overload;F;J0;; ;K0;#I"ip_unpack;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @l;[;I"@return [Array];T;0; @l;@F;Mi;N0;[; @l;[;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; @l;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Addrinfo#ip_address;F;[;[[@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;H ;II" overload;F;J0;; ;K0;#I"ip_address;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Addrinfo#ip_port;F;[;[[@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;H ;II" overload;F;J0;; ;K0;#I" ip_port;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv4_private?;F;[;[[@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;L ;II" return;F;J@;0;K[@; @;[;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;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv4_loopback?;F;[;[[@i;T;:ipv4_loopback?;0;[;{;IC;"VReturns true for IPv4 loopback address (127.0.0.0/8). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"WReturns true for IPv4 loopback address (127.0.0.0/8). It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv4_multicast?;F;[;[[@i%;T;:ipv4_multicast?;0;[;{;IC;"WReturns true for IPv4 multicast address (224.0.0.0/4). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"XReturns true for IPv4 multicast address (224.0.0.0/4). It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di!;Ei#;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_unspecified?;F;[;[[@i>;T;:ipv6_unspecified?;0;[;{;IC;"PReturns true for IPv6 unspecified address (::). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"QReturns true for IPv6 unspecified address (::). It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di:;Ei<;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_loopback?;F;[;[[@iJ;T;:ipv6_loopback?;0;[;{;IC;"NReturns true for IPv6 loopback address (::1). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"OReturns true for IPv6 loopback address (::1). It returns false otherwise. ;T;0; @;@F;Ao;B;CT;DiF;EiH;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_multicast?;F;[;[[@iV;T;:ipv6_multicast?;0;[;{;IC;"TReturns true for IPv6 multicast address (ff00::/8). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @ ;[;I"UReturns true for IPv6 multicast address (ff00::/8). It returns false otherwise. ;T;0; @ ;@F;Ao;B;CT;DiR;EiT;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_linklocal?;F;[;[[@ib;T;:ipv6_linklocal?;0;[;{;IC;"VReturns true for IPv6 link local address (ff80::/10). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"WReturns true for IPv6 link local address (ff80::/10). It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di^;Ei`;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_sitelocal?;F;[;[[@in;T;:ipv6_sitelocal?;0;[;{;IC;"VReturns true for IPv6 site local address (ffc0::/10). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @/;[;I"WReturns true for IPv6 site local address (ffc0::/10). It returns false otherwise. ;T;0; @/;@F;Ao;B;CT;Dij;Eil;Mi;!@;"I"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; ; F; ;,;;;I" Addrinfo#ipv6_unique_local?;F;[;[[@iz;T;:ipv6_unique_local?;0;[;{;IC;"`Returns true for IPv6 unique local address (fc00::/7, RFC4193). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @@;[;I"aReturns true for IPv6 unique local address (fc00::/7, RFC4193). It returns false otherwise. ;T;0; @@;@F;Ao;B;CT;Div;Eix;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_v4mapped?;F;[;[[@i;T;:ipv6_v4mapped?;0;[;{;IC;"[Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @Q;[;I"\Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80). It returns false otherwise. ;T;0; @Q;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_v4compat?;F;[;[[@i;T;:ipv6_v4compat?;0;[;{;IC;"WReturns true for IPv4-compatible IPv6 address (::/80). It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @b;[;I"XReturns true for IPv4-compatible IPv6 address (::/80). It returns false otherwise. ;T;0; @b;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I" Addrinfo#ipv6_mc_nodelocal?;F;[;[[@i;T;:ipv6_mc_nodelocal?;0;[;{;IC;"ZReturns true for IPv6 multicast node-local scope address. It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @s;[;I"[Returns true for IPv6 multicast node-local scope address. It returns false otherwise. ;T;0; @s;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I" Addrinfo#ipv6_mc_linklocal?;F;[;[[@i;T;:ipv6_mc_linklocal?;0;[;{;IC;"ZReturns true for IPv6 multicast link-local scope address. It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"[Returns true for IPv6 multicast link-local scope address. It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I" Addrinfo#ipv6_mc_sitelocal?;F;[;[[@i;T;:ipv6_mc_sitelocal?;0;[;{;IC;"ZReturns true for IPv6 multicast site-local scope address. It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"[Returns true for IPv6 multicast site-local scope address. It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_mc_orglocal?;F;[;[[@i;T;:ipv6_mc_orglocal?;0;[;{;IC;"bReturns true for IPv6 multicast organization-local scope address. It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"cReturns true for IPv6 multicast organization-local scope address. It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_mc_global?;F;[;[[@i;T;:ipv6_mc_global?;0;[;{;IC;"VReturns true for IPv6 multicast global scope address. It returns false otherwise.;T;[o;L ;II" return;F;J@;0;K[@; @;[;I"WReturns true for IPv6 multicast global scope address. It returns false otherwise. ;T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"Addrinfo#ipv6_to_ipv4;F;[;[[@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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Addrinfo#unix_path;F;[;[[@i ;T;:unix_path;0;[;{;IC;"gReturns the socket path as a string. Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock" ;T;[o;H ;II" overload;F;J0;; ;K0;#I"unix_path;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"}Returns the socket path as a string. Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock" @overload unix_path;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"\static VALUE addrinfo_unix_path(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); int family = ai_get_afamily(rai); struct sockaddr_un *addr; char *s, *e; if (family != AF_UNIX) rb_raise(rb_eSocket, "need AF_UNIX address"); addr = &rai->addr.un; s = addr->sun_path; e = (char*)addr + rai->sockaddr_len; if (e < s) rb_raise(rb_eSocket, "too short AF_UNIX address: %"PRIuSIZE" bytes given for minimum %"PRIuSIZE" bytes.", (size_t)rai->sockaddr_len, (size_t)(s - (char *)addr)); if (addr->sun_path + sizeof(addr->sun_path) < e) rb_raise(rb_eSocket, "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", (size_t)(e - addr->sun_path), sizeof(addr->sun_path)); while (s < e && *(e-1) == '\0') e--; return rb_str_new(s, e-s); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#to_sockaddr;F;[;[[@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;H ;II" overload;F;J0;; ;K0;#I"to_sockaddr;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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); OBJ_INFECT(ret, self); return ret; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#to_s;F;[;[[@i;T;;h;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;H ;II" overload;F;J0;; ;K0;#I"to_sockaddr;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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); OBJ_INFECT(ret, self); return ret; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Addrinfo#getnameinfo;F;[[@0;[[@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;H ;II" overload;F;J0;; ;K0;#I"getnameinfo;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;;[;I"@return [Array];T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;; ;K0;#I"getnameinfo(flags);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;;[;I"@return [Array];T;0; @;;@F;Mi;N0;[[I" flags;T0; @;;[;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; @;;@F;Ao;B;CT;Din;Ei|;!@;"I"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; ; F; ;,;;;I"Addrinfo#marshal_dump;F;[;[[@i;T;;e;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @f;@F;Ao;B;CT;Di;Ei;!@;"I"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: { struct sockaddr_un *su = &rai->addr.un; char *s, *e; s = su->sun_path; e = (char*)su + rai->sockaddr_len; while (s < e && *(e-1) == '\0') e--; sockaddr = rb_str_new(s, e-s); 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; ; F; ;,;;;I"Addrinfo#marshal_load;F;[[I"ary;T0;[[@i@;T;;f;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @t;@F;Ao;B;CT;Di?;Ei?;!@;"I"< 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); 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;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I" Addrinfo;F;1@S6@@Oo; ;IC;[o; ; F; ;,;;;I"Socket#initialize;F;[[@0;[[I"ext/socket/socket.c;Ti;T;;;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;H ;II" overload;F;J0;; ;K0;#I"'new(domain, socktype [, protocol]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Diw;Ei;!@;"I"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; ; F; ;,;;;I"Socket#connect;F;[[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 time 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 time 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;H ;II" overload;F;J0;;;K0;#I"connect(remote_sockaddr);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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 time 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 time 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;Ao;B;CT;Di@;Ei;!@;"I"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); if (n < 0) { rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai); } return INT2FIX(n); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket#__connect_nonblock;F;[[I" addr;T0[I"ex;T0;[[@i;T;:__connect_nonblock;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Socket#bind;F;[[I" addr;T0;[[@i8;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;H ;II" overload;F;J0;;;K0;#I"bind(local_sockaddr);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei6;!@;"I"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; ; F; ;,;;;I"Socket#listen;F;[[I"log;T0;[[@i;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"listen( int );T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @;[;I"@return [0];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;DiF;Ei;!@;"I"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; ; F; ;,;;;I"Socket#accept;F;[;[[@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;H ;II" overload;F;J0;;;K0;#I" accept;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di;Ei;!@;"I"?static VALUE sock_accept(VALUE sock) { rb_io_t *fptr; VALUE sock2; union_sockaddr buf; socklen_t len = (socklen_t)sizeof buf; GetOpenFile(sock, fptr); sock2 = rsock_s_accept(rb_cSocket,fptr->fd,&buf.addr,&len); return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, &buf.addr, len)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket#__accept_nonblock;F;[[I"ex;T0;[[@i-;T;;~ ;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;;@F;Ao;B;CT;Di,;Ei,;!@;"I"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; ; F; ;,;;;I"Socket#sysaccept;F;[;[[@id;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;H ;II" overload;F;J0;; ;K0;#I"sysaccept;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @K;[;I"@return [Array];T;0; @K;@F;Mi;N0;[; @K;[;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; @K;@F;Ao;B;CT;Di>;Eib;!@;"I"9static VALUE sock_sysaccept(VALUE sock) { rb_io_t *fptr; VALUE sock2; union_sockaddr buf; socklen_t len = (socklen_t)sizeof buf; GetOpenFile(sock, fptr); sock2 = rsock_s_accept(0,fptr->fd,&buf.addr,&len); return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, &buf.addr, len)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket#recvfrom;F;[[@0;[[@i;T;;k ;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;H ;II" overload;F;J0;;k ;K0;#I"recvfrom(maxlen);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @f;[;I"@return [Array];T;0; @f;@F;Mi;N0;[[I" maxlen;T0; @fo;H ;II" overload;F;J0;;k ;K0;#I"recvfrom(maxlen, flags);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @f;[;I"@return [Array];T;0; @f;@F;Mi;N0;[[I" maxlen;T0[I" flags;T0; @f;[;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; @f;@F;Ao;B;CT;Di;Ei;!@;"I"}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; ; F; ;,;;;I"Socket#__recvfrom_nonblock;F;[ [I"len;T0[I"flg;T0[I"str;T0[I"ex;T0;[[@i ;T;;f ;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di ;Ei ;!@;"I"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; ; F; ;;;;I"Socket.socketpair;F;[[@0;[[@i!;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"!pair(domain, type, protocol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" domain;T0[I" type;T0[I" protocol;T0; @o;H ;II" overload;F;J0;; ;K0;#I"'socketpair(domain, type, protocol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;;;;I"Socket.pair;F;[[@0;[[@i!;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"!pair(domain, type, protocol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" domain;T0[I" type;T0[I" protocol;T0; @o;H ;II" overload;F;J0;; ;K0;#I"'socketpair(domain, type, protocol);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" domain;T0[I" type;T0[I" protocol;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei ;!@;"I"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; ; F; ;;;;I"Socket.gethostname;F;[;[[@i;T;:gethostname;0;[;{;IC;" ;T;[;[;@;0; @;!@;"I"~static VALUE sock_gethostname(VALUE obj) { struct utsname un; uname(&un); return rb_str_new2(un.nodename); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.gethostbyname;F;[[I" host;T0;[[@i;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"gethostbyname(hostname);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"static VALUE sock_s_gethostbyname(VALUE obj, VALUE host) { 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; ; F; ;;;;I"Socket.gethostbyaddr;F;[[@0;[[@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;H ;II" overload;F;J0;; ;K0;#I"5gethostbyaddr(address_string [, address_family]);T;IC;";T;[;[;I";T;0; @?;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"rstatic VALUE sock_s_gethostbyaddr(int argc, VALUE *argv) { VALUE addr, family; struct hostent *h; char **pch; VALUE ary, names; int t = AF_INET; 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; ; F; ;;;;I"Socket.getservbyname;F;[[@0;[[@iR;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;H ;II" overload;F;J0;; ;K0;#I" getservbyname(service_name);T;IC;";T;[;[;I";T;0; @X;@F;Mi;N0;[[I"service_name;T0; @Xo;H ;II" overload;F;J0;; ;K0;#I"/getservbyname(service_name, protocol_name);T;IC;";T;[;[;I";T;0; @X;@F;Mi;N0;[[I"service_name;T0[I"protocol_name;T0; @X;[;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; @X;@F;Ao;B;CT;DiE;EiO;!@;"I"static VALUE sock_s_getservbyname(int argc, VALUE *argv) { 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; ; F; ;;;;I"Socket.getservbyport;F;[[@0;[[@i{;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;H ;II" overload;F;J0;; ;K0;#I"*getservbyport(port [, protocol_name]);T;IC;";T;[;[;I";T;0; @};@F;Mi;N0;[[I"port[, protocol_name];T0; @};[;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; @};@F;Ao;B;CT;Din;Eix;!@;"I"static VALUE sock_s_getservbyport(int argc, VALUE *argv) { 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_tainted_str_new2(sp->s_name); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.getaddrinfo;F;[[@0;[[@i;T;; ;0;[;{;IC;"]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 same as numeric address. +nil+: obey to the current +do_not_reverse_lookup+ flag. If Addrinfo object is preferred, use Addrinfo.getaddrinfo. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"agetaddrinfo(nodename, servname[, family[, socktype[, protocol[, flags[, reverse_lookup]]]]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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 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;Ao;B;CT;Di;Ei;!@;"I"static VALUE sock_s_getaddrinfo(int argc, VALUE *argv) { 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; ; F; ;;;;I"Socket.getnameinfo;F;[[@0;[[@i;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"$getnameinfo(sockaddr [, flags]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I" static VALUE sock_s_getnameinfo(int argc, VALUE *argv) { VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags, tmp; char *hptr, *pptr; 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)); } /* host */ if (NIL_P(host)) { hptr = NULL; } else { strncpy(hbuf, StringValueCStr(host), sizeof(hbuf)); hbuf[sizeof(hbuf) - 1] = '\0'; hptr = hbuf; } /* port */ if (NIL_P(port)) { strcpy(pbuf, "0"); pptr = NULL; } else if (FIXNUM_P(port)) { snprintf(pbuf, sizeof(pbuf), "%ld", NUM2LONG(port)); pptr = pbuf; } else { strncpy(pbuf, StringValueCStr(port), sizeof(pbuf)); pbuf[sizeof(pbuf) - 1] = '\0'; pptr = pbuf; } hints.ai_socktype = (fl & NI_DGRAM) ? SOCK_DGRAM : SOCK_STREAM; /* af */ hints.ai_family = NIL_P(af) ? PF_UNSPEC : rsock_family_arg(af); error = rb_getaddrinfo(hptr, pptr, &hints, &res); if (error) goto error_exit_addr; 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_addr: saved_errno = errno; if (res) rb_freeaddrinfo(res); errno = saved_errno; rsock_raise_socket_error("getaddrinfo", error); 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; ; F; ;;;;I"Socket.sockaddr_in;F;[[I" port;T0[I" host;T0;[[@i;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;H ;II" overload;F;J0;; ;K0;#I"sockaddr_in(port, host);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" port;T0[I" host;T0; @o;H ;II" overload;F;J0;:pack_sockaddr_in;K0;#I"!pack_sockaddr_in(port, host);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Dit;Ei;!@;"I"Gstatic 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); OBJ_INFECT(addr, port); OBJ_INFECT(addr, host); return addr; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.pack_sockaddr_in;F;[[I" port;T0[I" host;T0;[[@i;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;H ;II" overload;F;J0;; ;K0;#I"sockaddr_in(port, host);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" port;T0[I" host;T0; @o;H ;II" overload;F;J0;; ;K0;#I"!pack_sockaddr_in(port, host);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" port;T0[I" host;T0; @;[;@;0; @;@F;Ao;B;CT;Dit;Ei;!@;"I"Gstatic 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); OBJ_INFECT(addr, port); OBJ_INFECT(addr, host); return addr; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.unpack_sockaddr_in;F;[[I" addr;T0;[[@i;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;H ;II" overload;F;J0;; ;K0;#I"!unpack_sockaddr_in(sockaddr);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @';[;I"@return [Array];T;0; @';@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"static 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)); OBJ_INFECT(host, addr); return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.sockaddr_un;F;[[I" path;T0;[[@i;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;H ;II" overload;F;J0;; ;K0;#I"sockaddr_un(path);T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[[I" path;T0; @Fo;H ;II" overload;F;J0;:pack_sockaddr_un;K0;#I"pack_sockaddr_un(path);T;IC;";T;[;[;I";T;0; @F;@F;Mi;N0;[[I" path;T0; @F;[;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; @F;@F;Ao;B;CT;Di;Ei;!@;"I"{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)); OBJ_INFECT(addr, path); return addr; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.pack_sockaddr_un;F;[[I" path;T0;[[@i;T;; ;0;[;{;IC;"vPacks _path_ as an AF_UNIX sockaddr string. Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..." ;T;[o;H ;II" overload;F;J0;; ;K0;#I"sockaddr_un(path);T;IC;";T;[;[;I";T;0; @j;@F;Mi;N0;[[I" path;T0; @jo;H ;II" overload;F;J0;; ;K0;#I"pack_sockaddr_un(path);T;IC;";T;[;[;I";T;0; @j;@F;Mi;N0;[[I" path;T0; @j;[;@f;0; @j;@F;Ao;B;CT;Di;Ei;!@;"I"{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)); OBJ_INFECT(addr, path); return addr; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.unpack_sockaddr_un;F;[[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;H ;II" overload;F;J0;; ;K0;#I"!unpack_sockaddr_un(sockaddr);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"Lstatic 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)); OBJ_INFECT(path, addr); return path; };T;#I"static VALUE;T;$To; ; F; ;;;;I"Socket.ip_address_list;F;[;[[@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;H ;II" overload;F;J0;; ;K0;#I"ip_address_list;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiQ;Ei^;!@;"I" 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; ; F; ;,;;;I"Socket::Ifaddr#inspect;F;[;[[I"ext/socket/ifaddr.c;Tid;T;;i;0;[;{;IC;"3Returns a string to show contents of _ifaddr_. ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"ZReturns a string to show contents of _ifaddr_. @overload inspect @return [String];T;0; @;@F;Ao;B;CT;Di];Eia;!@;"I"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; ; F; ;,;;;I"Socket::Ifaddr#name;F;[;[[@i;T;;>;0;[;{;IC;",Returns the interface name of _ifaddr_. ;T;[o;H ;II" overload;F;J0;;>;K0;#I" name;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"PReturns the interface name of _ifaddr_. @overload name @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Socket::Ifaddr#ifindex;F;[;[[@i;T;: ifindex;0;[;{;IC;"-Returns the interface index of _ifaddr_. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" ifindex;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"UReturns the interface index of _ifaddr_. @overload ifindex @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Socket::Ifaddr#flags;F;[;[[@i;T;: flags;0;[;{;IC;"#Returns the flags of _ifaddr_. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" flags;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"IReturns the flags of _ifaddr_. @overload flags @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"static VALUE ifaddr_flags(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); return IFAFLAGS2NUM(ifa->ifa_flags); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket::Ifaddr#addr;F;[;[[@i;T;;i ;0;[;{;IC;"^Returns the address of _ifaddr_. nil is returned if address is not available in _ifaddr_. ;T;[o;H ;II" overload;F;J0;;i ;K0;#I" addr;T;IC;";T;[;[;I";T;0; @1;@F;Mi;N0;[; @1;[;I"oReturns the address of _ifaddr_. nil is returned if address is not available in _ifaddr_. @overload addr;T;0; @1;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Socket::Ifaddr#netmask;F;[;[[@i;T;: netmask;0;[;{;IC;"fReturns the netmask address of _ifaddr_. nil is returned if netmask is not available in _ifaddr_. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" netmask;T;IC;";T;[;[;I";T;0; @G;@F;Mi;N0;[; @G;[;I"zReturns the netmask address of _ifaddr_. nil is returned if netmask is not available in _ifaddr_. @overload netmask;T;0; @G;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Socket::Ifaddr#broadaddr;F;[;[[@i;T;:broadaddr;0;[;{;IC;"hReturns the broadcast address of _ifaddr_. nil is returned if the flags doesn't have IFF_BROADCAST. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"broadaddr;T;IC;";T;[;[;I";T;0; @];@F;Mi;N0;[; @];[;I"~Returns the broadcast address of _ifaddr_. nil is returned if the flags doesn't have IFF_BROADCAST. @overload broadaddr;T;0; @];@F;Ao;B;CT;Di;Ei;!@;"I" 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; ; F; ;,;;;I"Socket::Ifaddr#dstaddr;F;[;[[@i;T;: dstaddr;0;[;{;IC;"lReturns the destination address of _ifaddr_. nil is returned if the flags doesn't have IFF_POINTOPOINT. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" dstaddr;T;IC;";T;[;[;I";T;0; @s;@F;Mi;N0;[; @s;[;I"{Returns the destination address of _ifaddr_. nil is returned if the flags doesn't have IFF_POINTOPOINT. @overload dstaddr;T;0; @s;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"Socket::Ifaddr#vhid;F;[;[[@i ;T;: vhid;0;[;{;IC;"OReturns the vhid address of _ifaddr_. nil is returned if there is no vhid. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" vhid;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"tReturns the vhid address of _ifaddr_. nil is returned if there is no vhid. @overload vhid @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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;;0;;;[;{;IC;"ASocket::Ifaddr represents a result of getifaddrs() function. ;T;[;[;I"C Socket::Ifaddr represents a result of getifaddrs() function. ;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Socket::Ifaddr;F;1@S6o; ; F; ;;;;I"Socket.getifaddrs;F;[;[[@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;H ;II" overload;F;J0;; ;K0;#I"getifaddrs;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"Tstatic VALUE socket_s_getifaddrs(VALUE self) { return rsock_getifaddrs(); };T;#I"static VALUE;T;$To; ;IC;[o;9;[[I"ext/socket/constdefs.c;Ti6;F;:SOCK_STREAM;;;;;;[;{;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;Ao;B;CT;Di5;Ei5;!@;I"#Socket::Constants::SOCK_STREAM;F;;Ei>;!@;I"%Socket::Constants::MSG_DONTROUTE;F;;@F;Ao;B;CT;Din;Ein;!@;I" Socket::Constants::MSG_HOLD;F;;@F;Ao;B;CT;Dir;Eir;!@;I"Socket::Constants::IP_MTU;F;Unblock IPv4 multicast packets with a give source address ;T;[;[;I">Unblock IPv4 multicast packets with a give source address;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I")Socket::Constants::IP_UNBLOCK_SOURCE;F;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;Ao;B;CT;Di8;Ei8;!@;I"&Socket::Constants::SO_RCVBUFFORCE;F;;Ei>;!@;I"$Socket::Constants::SO_KEEPALIVE;F;;!@;I" Socket::Constants::IPX_TYPE;F;Valid flag mask for getaddrinfo (not for application use) ;T;[;[;I">Valid flag mask for getaddrinfo (not for application use);T;0; @p;@F;Ao;B;CT;Di;Ei;!@;I"Socket::Constants::AI_MASK;F;dst ;T;[;[;I"9dev_hard_start_xmit() is allowed to release skb->dst;T;0; @;@F;Ao;B;CT;Dix ;Eix ;!@;I",Socket::Constants::IFF_XMIT_DST_RELEASE;F;;@F;Ao;B;CT;DiL;EiL;!@;I"Socket::PF_LAT;F; ;;;;;;[;{;IC;"Exterior Gateway Protocol ;T;[;[;I"Exterior Gateway Protocol;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Socket::IPPROTO_EGP;F;Unblock IPv4 multicast packets with a give source address ;T;[;[;I">Unblock IPv4 multicast packets with a give source address;T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Socket::IP_UNBLOCK_SOURCE;F;;@F;Ao;B;CT;Di;Ei;!@;I"Socket::MCAST_LEAVE_GROUP;F;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;Ao;B;CT;Di6;Ei6;!@;I"Socket::SO_RCVBUFFORCE;F;;Ei>;!@;I"Socket::SO_NOFCS;F;;@F;Ao;B;CT;Di;Ei;!@;I"Socket::TCP_CONGESTION;F;Valid flag mask for getaddrinfo (not for application use) ;T;[;[;I">Valid flag mask for getaddrinfo (not for application use);T;0; @;@F;Ao;B;CT;Di;Ei;!@;I"Socket::AI_MASK;F;;@F;Ao;B;CT;Di;Ei;!@;I"Socket::IPV6_RECVPKTINFO;F; ;;;;;;[;{;IC;"auto media select active ;T;[;[;I"auto media select active;T;0; @;@F;Ao;B;CT;Di> ;Ei> ;!@;I"Socket::IFF_AUTOMEDIA;F;;@F;Ao;B;CT;Di ;Ei ;!@;I"Socket::IFF_PPROMISC;F;dst ;T;[;[;I"9dev_hard_start_xmit() is allowed to release skb->dst;T;0; @ ;@F;Ao;B;CT;Div ;Eiv ;!@;I"!Socket::IFF_XMIT_DST_RELEASE;F; # p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") #=> # ;T;[o;H ;II" overload;F;J0;:Socket::AncillaryData.new;K0;#I"HSocket::AncillaryData.new(family, cmsg_level, cmsg_type, cmsg_data);T;IC;";T;[;[;I";T;0; @0;@F;Mi;N0;[ [I" family;T0[I"cmsg_level;T0[I"cmsg_type;T0[I"cmsg_data;T0; @0;[;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; @0;@F;Ao;B;CT;Di0;EiM;!@.;"I"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; ; F; ;,;;;I""Socket::AncillaryData#inspect;F;[;[[@Ki;T;;i;0;[;{;IC;"returns a string which shows ancillarydata in human-readable form. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").inspect #=> "#" ;T;[o;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @V;[;I"@return [String];T;0; @V;@F;Mi;N0;[; @V;[;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; @V;@F;Ao;B;CT;Di;Ei;!@.;"I"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; ; F; ;,;;;I"!Socket::AncillaryData#family;F;[;[[@Kiw;T;: family;0;[;{;IC;"yreturns the socket family as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").family #=> 10 ;T;[o;H ;II" overload;F;J0;;v ;K0;#I" family;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @q;[;I"@return [Integer];T;0; @q;@F;Mi;N0;[; @q;[;I"returns the socket family as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").family #=> 10 @overload family @return [Integer];T;0; @q;@F;Ao;B;CT;Din;Eiu;!@.;"I"`static VALUE ancillary_family_m(VALUE self) { return INT2NUM(ancillary_family(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Socket::AncillaryData#level;F;[;[[@Ki;T;; ;0;[;{;IC;"ureturns the cmsg level as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").level #=> 41 ;T;[o;H ;II" overload;F;J0;; ;K0;#I" level;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"returns the cmsg level as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").level #=> 41 @overload level @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@.;"I"^static VALUE ancillary_level_m(VALUE self) { return INT2NUM(ancillary_level(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket::AncillaryData#type;F;[;[[@Ki;T;;s;0;[;{;IC;"rreturns the cmsg type as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").type #=> 2 ;T;[o;H ;II" overload;F;J0;;s;K0;#I" type;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;I"returns the cmsg type as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").type #=> 2 @overload type @return [Integer];T;0; @;@F;Ao;B;CT;Di;Ei;!@.;"I"\static VALUE ancillary_type_m(VALUE self) { return INT2NUM(ancillary_type(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket::AncillaryData#data;F;[;[[@Ki;T;: data;0;[;{;IC;"qreturns the cmsg data as a string. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").data #=> "" ;T;[o;H ;II" overload;F;J0;;w ;K0;#I" data;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"returns the cmsg data as a string. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").data #=> "" @overload data @return [String];T;0; @;@F;Ao;B;CT;Di;Ei;!@.;"I"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; ; F; ;,;;;I"#Socket::AncillaryData#cmsg_is?;F;[[I" vlevel;T0[I" vtype;T0;[[@KiD;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;H ;II" overload;F;J0;;x ;K0;#I"cmsg_is?(level, type);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[I" level;T0[I" type;T0; @;[;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; @;@F;Ao;B;CT;Di8;EiB;Mi;!@.;"I"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; ; F; ;;;;I"Socket::AncillaryData.int;F;[ [I" vfamily;T0[I" vlevel;T0[I" vtype;T0[I" integer;T0;[[@Kip;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;H ;II" overload;F;J0;:Socket::AncillaryData.int;K0;#I"FSocket::AncillaryData.int(family, cmsg_level, cmsg_type, integer);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[ [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;Ao;B;CT;Dic;Eim;!@.;"I"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; ; F; ;,;;;I"Socket::AncillaryData#int;F;[;[[@Ki;T;;y ;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;H ;II" overload;F;J0;;y ;K0;#I"int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @&;[;I"@return [Integer];T;0; @&;@F;Mi;N0;[; @&;[;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;Ao;B;CT;Diz;Ei;!@.;"I"^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; ; F; ;;;;I"&Socket::AncillaryData.unix_rights;F;[[@0;[[@Ki;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;H ;II" overload;F;J0;:&Socket::AncillaryData.unix_rights;K0;#I"5Socket::AncillaryData.unix_rights(io1, io2, ...);T;IC;";T;[;[;I";T;0; @A;@F;Mi;N0;[[I"io1;T0[I"io2;T0[I"...;T0; @A;[;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; @A;@F;Ao;B;CT;Di;Ei;!@.;"I"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; ; F; ;,;;;I"&Socket::AncillaryData#unix_rights;F;[;[[@Ki;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;H ;II" overload;F;J0;;{ ;K0;#I"unix_rights;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"array-of-IOs;TI"nil;T; @^;[;I" @return [array-of-IOs, nil];T;0; @^;@F;Mi;N0;[; @^;[;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;Ao;B;CT;Di;Ei;!@.;"I"@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; ; F; ;,;;;I"$Socket::AncillaryData#timestamp;F;[;[[@Ki,;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;H ;II" overload;F;J0;;} ;K0;#I"timestamp;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @z;[;I"@return [Time];T;0; @z;@F;Mi;N0;[; @z;[;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; @z;@F;Ao;B;CT;Di;Ei*;!@.;"I"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; ; F; ;;;;I"%Socket::AncillaryData.ip_pktinfo;F;[[@0;[[@Ki;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;H ;II" overload;F;J0;:%Socket::AncillaryData.ip_pktinfo;K0;#I"4Socket::AncillaryData.ip_pktinfo(addr, ifindex);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" addr;T0[I" ifindex;T0; @o;H ;II" overload;F;J0;; ;K0;#I">Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@.;"I"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; ; F; ;,;;;I"%Socket::AncillaryData#ip_pktinfo;F;[;[[@Ki;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;H ;II" overload;F;J0;;~ ;K0;#I"ip_pktinfo;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@.;"I" 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; ; F; ;;;;I"'Socket::AncillaryData.ipv6_pktinfo;F;[[I" v_addr;T0[I"v_ifindex;T0;[[@Ki;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;H ;II" overload;F;J0;:'Socket::AncillaryData.ipv6_pktinfo;K0;#I"6Socket::AncillaryData.ipv6_pktinfo(addr, ifindex);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" addr;T0[I" ifindex;T0; @;[;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; @;@F;Ao;B;CT;Di ;Ei;!@.;"I"&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; ; F; ;,;;;I"'Socket::AncillaryData#ipv6_pktinfo;F;[;[[@Ki[;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;H ;II" overload;F;J0;; ;K0;#I"ipv6_pktinfo;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiM;EiY;!@.;"I"`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; ; F; ;,;;;I",Socket::AncillaryData#ipv6_pktinfo_addr;F;[;[[@Kiy;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;H ;II" overload;F;J0;; ;K0;#I"ipv6_pktinfo_addr;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Dik;Eiv;!@.;"I" 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; ; F; ;,;;;I"/Socket::AncillaryData#ipv6_pktinfo_ifindex;F;[;[[@Ki;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;H ;II" overload;F;J0;; ;K0;#I"ipv6_pktinfo_ifindex;T;IC;";T;[;[;I";T;0; @(;@F;Mi;N0;[; @(;[;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;Ao;B;CT;Di;Ei;!@.;"I"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;-{;.[;[[@Ki[@Ki;T;:AncillaryData;;0;;;[;{;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;Ao;B;CT;Di;Ei;!@;I"Socket::AncillaryData;F;1@ # ;T;[o;H ;II" overload;F;J0;:Socket::Option.new;K0;#I"5Socket::Option.new(family, level, optname, data);T;IC;";T;[;[;I";T;0; @R;@F;Mi;N0;[ [I" family;T0[I" level;T0[I" optname;T0[I" data;T0; @R;[;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; @R;@F;Ao;B;CT;DiW;Ei^;!@P;"I"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; ; F; ;,;;;I"Socket::Option#family;F;[;[[@_i|;T;;v ;0;[;{;IC;"}returns the socket family as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).family #=> 10 ;T;[o;H ;II" overload;F;J0;;v ;K0;#I" family;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @y;[;I"@return [Integer];T;0; @y;@F;Mi;N0;[; @y;[;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; @y;@F;Ao;B;CT;Dix;Ei;!@P;"I"estatic VALUE sockopt_family_m(VALUE self) { return rb_attr_get(self, rb_intern("family")); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket::Option#level;F;[;[[@_i;T;; ;0;[;{;IC;"{returns the socket level as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).level #=> 41 ;T;[o;H ;II" overload;F;J0;; ;K0;#I" level;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@P;"I"Zstatic VALUE sockopt_level_m(VALUE self) { return INT2NUM(sockopt_level(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket::Option#optname;F;[;[[@_i;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;H ;II" overload;F;J0;; ;K0;#I" optname;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@P;"I"^static VALUE sockopt_optname_m(VALUE self) { return INT2NUM(sockopt_optname(self)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Socket::Option#data;F;[;[[@_i;T;;w ;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;H ;II" overload;F;J0;;w ;K0;#I" data;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;,;;;I"Socket::Option#inspect;F;[;[[@_i;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@P;"I") 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; ; F; ;;;;I"Socket::Option.int;F;[ [I" vfamily;T0[I" vlevel;T0[I" voptname;T0[I" vint;T0;[[@_i;T;;y ;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;H ;II" overload;F;J0;:Socket::Option.int;K0;#I"8Socket::Option.int(family, level, optname, integer);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[ [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;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;,;;;I"Socket::Option#int;F;[;[[@_i;T;;y ;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;H ;II" overload;F;J0;;y ;K0;#I"int;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @3 ;[;I"@return [Integer];T;0; @3 ;@F;Mi;N0;[; @3 ;[;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; @3 ;@F;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;;;;I"Socket::Option.byte;F;[ [I" vfamily;T0[I" vlevel;T0[I" voptname;T0[I" vint;T0;[[@_i;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;H ;II" overload;F;J0;:Socket::Option.byte;K0;#I"9Socket::Option.byte(family, level, optname, integer);T;IC;";T;[;[;I";T;0; @N ;@F;Mi;N0;[ [I" family;T0[I" level;T0[I" optname;T0[I" integer;T0; @N ;[;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; @N ;@F;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;,;;;I"Socket::Option#byte;F;[;[[@_i;T;; ;0;[;{;IC;"Returns the data in _sockopt_ as an byte. sockopt = Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.byte => 1 ;T;[o;H ;II" overload;F;J0;; ;K0;#I" byte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @t ;[;I"@return [Integer];T;0; @t ;@F;Mi;N0;[; @t ;[;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; @t ;@F;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;;;;I"Socket::Option.bool;F;[ [I" vfamily;T0[I" vlevel;T0[I" voptname;T0[I" vbool;T0;[[@_i;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;H ;II" overload;F;J0;:Socket::Option.bool;K0;#I"6Socket::Option.bool(family, level, optname, bool);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[ [I" family;T0[I" level;T0[I" optname;T0[I" bool;T0; @ ;[;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; @ ;@F;Ao;B;CT;Di ;Ei;!@P;"I"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; ; F; ;,;;;I"Socket::Option#bool;F;[;[[@_i/;T;; ;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;H ;II" overload;F;J0;; ;K0;#I" bool;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di&;Ei-;!@P;"I"\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; ; F; ;;;;I"Socket::Option.linger;F;[[I" vonoff;T0[I" vsecs;T0;[[@_iM;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;H ;II" overload;F;J0;:Socket::Option.linger;K0;#I"'Socket::Option.linger(onoff, secs);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di?;EiJ;!@P;"I"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; ; F; ;,;;;I"Socket::Option#linger;F;[;[[@_id;T;; ;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;H ;II" overload;F;J0;; ;K0;#I" linger;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @ ;[;I"@return [Array];T;0; @ ;@F;Mi;N0;[; @ ;[;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;Ao;B;CT;Di[;Eib;!@P;"I"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; ; F; ;;;;I"&Socket::Option.ipv4_multicast_ttl;F;[[I" value;T0;[[@_i;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;H ;II" overload;F;J0;:&Socket::Option.ipv4_multicast_ttl;K0;#I"/Socket::Option.ipv4_multicast_ttl(integer);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;,;;;I"&Socket::Option#ipv4_multicast_ttl;F;[;[[@_i;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"ipv4_multicast_ttl;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @# ;[;I"@return [Integer];T;0; @# ;@F;Mi;N0;[; @# ;[;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;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;;;;I"'Socket::Option.ipv4_multicast_loop;F;[[I" value;T0;[[@_i;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;H ;II" overload;F;J0;:'Socket::Option.ipv4_multicast_loop;K0;#I"0Socket::Option.ipv4_multicast_loop(integer);T;IC;";T;[;[;I";T;0; @> ;@F;Mi;N0;[[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;Ao;B;CT;Diz;Ei;!@P;"I"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; ; F; ;,;;;I"'Socket::Option#ipv4_multicast_loop;F;[;[[@_i;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"ipv4_multicast_loop;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @X ;[;I"@return [Integer];T;0; @X ;@F;Mi;N0;[; @X ;[;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; @X ;@F;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;,;;;I"Socket::Option#unpack;F;[[I" template;T0;[[@_i;T;;;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;H ;II" overload;F;J0;;;K0;#I"unpack(template);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @s ;[;I"@return [Array];T;0; @s ;@F;Mi;N0;[[I" template;T0; @s ;[;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; @s ;@F;Ao;B;CT;Di;Ei;!@P;"I"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; ; F; ;,;;;I"Socket::Option#to_s;F;[;[[@_i;T;;h;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;H ;II" overload;F;J0;;w ;K0;#I" data;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;@;0; @ ;@F;Ao;B;CT;Di;Ei;!@P;"I"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;&@P;'IC;[;&@P;(IC;[;&@P;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@_i[@_i;T;; ;;0;;;[;{;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; @P;@F;Ao;B;CT;Di;Ei;!@;I"Socket::Option;F;1@<;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i[@i;T;: Socket;;0;;;[;{;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;Ao;B;CT;Di;Ei ;Mi;!@;I" Socket;F;1o;2 ;30;40;50;;m ;!@;7@O;F0o; ;IC;[o; ; F; ;,;;;I"SOCKSSocket#initialize;F;[[I" host;T0[I" serv;T0;[[I"ext/socket/sockssocket.c;Ti;T;;;0;[;{;IC;"DOpens a SOCKS connection to +host+ via the SOCKS server +serv+. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(host, serv);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" host;T0[I" serv;T0; @ ;[;I"aOpens a SOCKS connection to +host+ via the SOCKS server +serv+. @overload new(host, serv);T;0; @ ;@F;Ao;B;CT;Di;Ei;!@ ;"I"static VALUE socks_init(VALUE sock, VALUE host, VALUE serv) { static int init = 0; if (init == 0) { SOCKSinit("ruby"); init = 1; } return rsock_init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"SOCKSSocket#close;F;[;[[@ i,;T;;;0;[;{;IC;"!Closes the SOCKS connection. ;T;[;[;I"#Closes the SOCKS connection. ;T;0; @ ;@F;Ao;B;CT;Di(;Ei*;!@ ;"I"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;-{;.[;[[@ i<[@ iC;T;:SOCKSSocket;;0;;;[;{;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;Ao;B;CT;Di<;Ei@;!@;I"SOCKSSocket;F;1o;2 ;30;40;50;; ;!@;7@;F0o; ;IC;[;&@ ;'IC;[;&@ ;(IC;[;&@ ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[I"ext/socket/init.c;Ti:;F;:SocketError;;0;;;[;{;IC;" ;T;[;[;@;0; @ ;!@;I"SocketError;F;1@7@o; ;IC;[o;9;[[@Pi $;F;:MONTHNAMES;;;;;;[;{;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; @4 ;@F;Ao;B;CT;Di $;Ei $;!@2 ;I"Date::MONTHNAMES;F; true See also ::jd.;T;[o;H ;II" overload;F;J0;; ;K0;#I"'valid_jd?(jd[, start=Date::ITALY]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;Mi;!@2 ;"I"Ustatic 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); 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; ; F; ;;;;I"Date.valid_ordinal?;F;[[@0;[[@PiK ;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;H ;II" overload;F;J0;; ;K0;#I"4valid_ordinal?(year, yday[, start=Date::ITALY]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di@ ;EiI ;Mi;!@2 ;"I"xstatic 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); 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; ; F; ;;;;I"Date.valid_civil?;F;[[@0;[[@Pi ;T;:valid_civil?;0;[;{;IC;"Returns true if the given calendar date is valid, and false if not. Date.valid_date?(2001,2,3) #=> true Date.valid_date?(2001,2,29) #=> false See also ::jd and ::civil.;T;[o;H ;II" overload;F;J0;; ;K0;#I"9valid_civil?(year, month, mday[, start=Date::ITALY]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T; @ o;H ;II" overload;F;J0;:valid_date?;K0;#I"8valid_date?(year, month, mday[, start=Date::ITALY]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T; @ ;[;I"WReturns true if the given calendar date is valid, and false if not. Date.valid_date?(2001,2,3) #=> true Date.valid_date?(2001,2,29) #=> false 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;Ao;B;CT;Di ;Ei ;Mi;!@2 ;"I"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); 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; ; F; ;;;;I"Date.valid_date?;F;[[@0;[[@Pi ;T;; ;0;[;{;IC;"Returns true if the given calendar date is valid, and false if not. Date.valid_date?(2001,2,3) #=> true Date.valid_date?(2001,2,29) #=> false See also ::jd and ::civil.;T;[o;H ;II" overload;F;J0;; ;K0;#I"9valid_civil?(year, month, mday[, start=Date::ITALY]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T; @ o;H ;II" overload;F;J0;; ;K0;#I"8valid_date?(year, month, mday[, start=Date::ITALY]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di ;Ei ;Mi;!@2 ;"I"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); 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; ; F; ;;;;I"Date.valid_commercial?;F;[[@0;[[@Pi ;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;H ;II" overload;F;J0;; ;K0;#I"Avalid_commercial?(cwyear, cweek, cwday[, start=Date::ITALY]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @A ;[;I"@return [Boolean];T;0; @A ;@F;Mi;N0;[[I" cwyear;T0[I" cweek;T0[I"cwday[, start;TI"Date::ITALY];T; @A ;[;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; @A ;@F;Ao;B;CT;Di ;Ei ;Mi;!@2 ;"I"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); 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; ; F; ;;;;I"Date.julian_leap?;F;[[I"y;T0;[[@PiT ;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;H ;II" overload;F;J0;; ;K0;#I"julian_leap?(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @d ;[;I"@return [Boolean];T;0; @d ;@F;Mi;N0;[[I" year;T0; @d ;[;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; @d ;@F;Ao;B;CT;DiJ ;EiR ;Mi;!@2 ;"I"static VALUE date_s_julian_leap_p(VALUE klass, VALUE y) { VALUE nth; int ry; decode_year(y, +1, &nth, &ry); return f_boolcast(c_julian_leap_p(ry)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.gregorian_leap?;F;[[I"y;T0;[[@Pii ;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;H ;II" overload;F;J0;; ;K0;#I"gregorian_leap?(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" year;T0; @ o;H ;II" overload;F;J0;: leap?;K0;#I"leap?(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di^ ;Eih ;Mi;!@2 ;"I"static VALUE date_s_gregorian_leap_p(VALUE klass, VALUE y) { VALUE nth; int ry; decode_year(y, -1, &nth, &ry); return f_boolcast(c_gregorian_leap_p(ry)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.leap?;F;[[I"y;T0;[[@Pii ;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"gregorian_leap?(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" year;T0; @ o;H ;II" overload;F;J0;; ;K0;#I"leap?(year);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @ ;[;I"@return [Boolean];T;0; @ ;@F;Mi;N0;[[I" year;T0; @ ;[;@ ;0; @ ;@F;Ao;B;CT;Di^ ;Eih ;Mi;!@2 ;"I"static VALUE date_s_gregorian_leap_p(VALUE klass, VALUE y) { VALUE nth; int ry; decode_year(y, -1, &nth, &ry); return f_boolcast(c_gregorian_leap_p(ry)); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.new!;F;[[@0;[[@Pi ;T;: new!;0;[;{;IC;" ;T;[;[;@;0; @ ;!@2 ;"I"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; ; F; ;;;;I" Date.jd;F;[[@0;[[@Pi ;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;H ;II" overload;F;J0;; ;K0;#I"$jd([jd=0[, start=Date::ITALY]]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@2 ;"I"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: 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; ; F; ;;;;I"Date.ordinal;F;[[@0;[[@Pi ;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;H ;II" overload;F;J0;; ;K0;#I"9ordinal([year=-4712[, yday=1[, start=Date::ITALY]]]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@2 ;"I"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: num2int_with_frac(d, positive_inf); case 1: y = vy; } { VALUE nth; int ry, rd, rjd, ns; if (!valid_ordinal_p(y, d, sg, &nth, &ry, &rd, &rjd, &ns)) rb_raise(rb_eArgError, "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; ; F; ;;;;I"Date.civil;F;[[@0;[[@Pi7 ;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;H ;II" overload;F;J0;; ;K0;#I"Bcivil([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" [year;TI"5-4712[, month=1[, mday=1[, start=Date::ITALY]]]];T; @ o;H ;II" overload;F;J0;; ;K0;#I"@new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei4 ;!@2 ;"I"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; ; F; ;;;;I"Date.commercial;F;[[@0;[[@Pi ;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;H ;II" overload;F;J0;; ;K0;#I"Jcommercial([cwyear=-4712[, cweek=1[, cwday=1[, start=Date::ITALY]]]]);T;IC;";T;[;[;I";T;0; @D ;@F;Mi;N0;[[I" [cwyear;TI"6-4712[, cweek=1[, cwday=1[, start=Date::ITALY]]]];T; @D ;[;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; @D ;@F;Ao;B;CT;Dix ;Ei ;!@2 ;"I"static 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: 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_commercial_p(y, w, d, sg, &nth, &ry, &rw, &rd, &rjd, &ns)) rb_raise(rb_eArgError, "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; ; F; ;;;;I"Date.weeknum;F;[[@0;[[@Pi ;T;: weeknum;0;[;{;IC;" ;T;[;[;@;0; @^ ;!@2 ;"I"Bstatic 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(rb_eArgError, "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; ; F; ;;;;I"Date.nth_kday;F;[[@0;[[@Pi ;T;: nth_kday;0;[;{;IC;" ;T;[;[;@;0; @k ;!@2 ;"I"Pstatic 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(rb_eArgError, "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; ; F; ;;;;I"Date.today;F;[[@0;[[@Pi8;T;: today;0;[;{;IC;"aCreates a date object denoting the present day. Date.today #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"today([start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @x ;@F;Mi;N0;[[I" [start;TI"Date::ITALY];T; @x ;[;I"Creates a date object denoting the present day. Date.today #=> # @overload today([start=Date::ITALY]);T;0; @x ;@F;Ao;B;CT;Di0;Ei5;!@2 ;"I"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; ; F; ;;;;I"Date._strptime;F;[[@0;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"%_strptime(string[, format='%F']);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @ ;[;I"@return [Hash];T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;;;;I"Date.strptime;F;[[@0;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"Istrptime([string='-4712-01-01'[, format='%F'[, start=Date::ITALY]]]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;;;;I"Date._parse;F;[[@0;[[@Pi;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 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} ;T;[o;H ;II" overload;F;J0;; ;K0;#I" _parse(string[, comp=true]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @ ;[;I"@return [Hash];T;0; @ ;@F;Mi;N0;[[I"string[, comp;TI" true];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 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} @overload _parse(string[, comp=true]) @return [Hash];T;0; @ ;@F;Ao;B;CT;Di;Ei;!@2 ;"I"}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; ; F; ;;;;I"Date.parse;F;[[@0;[[@Pi;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 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') #=> # ;T;[o;H ;II" overload;F;J0;;;K0;#I"Bparse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" string;TI"4'-4712-01-01'[, comp=true[, start=Date::ITALY]];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 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') #=> # @overload parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]);T;0; @ ;@F;Ao;B;CT;Di;Ei;!@2 ;"I"static VALUE date_s_parse(int argc, VALUE *argv, VALUE klass) { VALUE str, comp, sg; rb_scan_args(argc, argv, "03", &str, &comp, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: comp = Qtrue; case 2: sg = INT2FIX(DEFAULT_SG); } { VALUE argv2[2], hash; argv2[0] = str; argv2[1] = comp; hash = date_s__parse(2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date._iso8601;F;[[I"str;T0;[[@Pi";T;: _iso8601;0;[;{;IC;"'Returns a hash of parsed elements. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"_iso8601(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"UReturns a hash of parsed elements. @overload _iso8601(string) @return [Hash];T;0; @;@F;Ao;B;CT;Di;Ei ;!@2 ;"I"\static VALUE date_s__iso8601(VALUE klass, VALUE str) { return date__iso8601(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.iso8601;F;[[@0;[[@Pi3;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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"7iso8601(string='-4712-01-01'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[[I" string;TI"''-4712-01-01'[, start=Date::ITALY];T; @#;[;I"KCreates 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') #=> # @overload iso8601(string='-4712-01-01'[, start=Date::ITALY]);T;0; @#;@F;Ao;B;CT;Di(;Ei0;!@2 ;"I"\static VALUE date_s_iso8601(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__iso8601(klass, str); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date._rfc3339;F;[[I"str;T0;[[@PiM;T;: _rfc3339;0;[;{;IC;"'Returns a hash of parsed elements. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"_rfc3339(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @=;[;I"@return [Hash];T;0; @=;@F;Mi;N0;[[I" string;T0; @=;[;I"UReturns a hash of parsed elements. @overload _rfc3339(string) @return [Hash];T;0; @=;@F;Ao;B;CT;DiG;EiK;!@2 ;"I"\static VALUE date_s__rfc3339(VALUE klass, VALUE str) { return date__rfc3339(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.rfc3339;F;[[@0;[[@Pi\;T;: rfc3339;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Frfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @\;@F;Mi;N0;[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];T; @\;[;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') #=> # @overload rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;0; @\;@F;Ao;B;CT;DiS;EiY;!@2 ;"I"kstatic VALUE date_s_rfc3339(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__rfc3339(klass, str); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date._xmlschema;F;[[I"str;T0;[[@Piv;T;:_xmlschema;0;[;{;IC;"'Returns a hash of parsed elements. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"_xmlschema(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @v;[;I"@return [Hash];T;0; @v;@F;Mi;N0;[[I" string;T0; @v;[;I"WReturns a hash of parsed elements. @overload _xmlschema(string) @return [Hash];T;0; @v;@F;Ao;B;CT;Dip;Eit;!@2 ;"I"`static VALUE date_s__xmlschema(VALUE klass, VALUE str) { return date__xmlschema(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.xmlschema;F;[[@0;[[@Pi;T;:xmlschema;0;[;{;IC;"Creates a new Date object by parsing from a string according to some typical XML Schema formats. Date.xmlschema('2001-02-03') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"9xmlschema(string='-4712-01-01'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI"''-4712-01-01'[, start=Date::ITALY];T; @;[;I"Creates a new Date object by parsing from a string according to some typical XML Schema formats. Date.xmlschema('2001-02-03') #=> # @overload xmlschema(string='-4712-01-01'[, start=Date::ITALY]);T;0; @;@F;Ao;B;CT;Di|;Ei;!@2 ;"I"`static VALUE date_s_xmlschema(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__xmlschema(klass, str); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date._rfc2822;F;[[I"str;T0;[[@Pi;T;: _rfc2822;0;[;{;IC;"'Returns a hash of parsed elements. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"_rfc2822(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I" string;T0; @o;H ;II" overload;F;J0;: _rfc822;K0;#I"_rfc822(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"{Returns a hash of parsed elements. @overload _rfc2822(string) @return [Hash] @overload _rfc822(string) @return [Hash];T;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"\static VALUE date_s__rfc2822(VALUE klass, VALUE str) { return date__rfc2822(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date._rfc822;F;[[I"str;T0;[[@Pi;T;; ;0;[;{;IC;"'Returns a hash of parsed elements. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"_rfc2822(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I" string;T0; @o;H ;II" overload;F;J0;; ;K0;#I"_rfc822(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"\static VALUE date_s__rfc2822(VALUE klass, VALUE str) { return date__rfc2822(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.rfc2822;F;[[@0;[[@Pi;T;: rfc2822;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Krfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @ o;H ;II" overload;F;J0;: rfc822;K0;#I"Jrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @ ;[;I"UCreates 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') #=> # @overload rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) @overload rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;0; @ ;@F;Ao;B;CT;Di;Ei;!@2 ;"I"pstatic VALUE date_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__rfc2822(klass, str); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.rfc822;F;[[@0;[[@Pi;T;; ;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Krfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @/o;H ;II" overload;F;J0;; ;K0;#I"Jrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @/;[;@+;0; @/;@F;Ao;B;CT;Di;Ei;!@2 ;"I"pstatic VALUE date_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__rfc2822(klass, str); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date._httpdate;F;[[I"str;T0;[[@Pi;T;:_httpdate;0;[;{;IC;"'Returns a hash of parsed elements. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"_httpdate(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @S;[;I"@return [Hash];T;0; @S;@F;Mi;N0;[[I" string;T0; @S;[;I"VReturns a hash of parsed elements. @overload _httpdate(string) @return [Hash];T;0; @S;@F;Ao;B;CT;Di;Ei;!@2 ;"I"^static VALUE date_s__httpdate(VALUE klass, VALUE str) { return date__httpdate(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.httpdate;F;[[@0;[[@Pi;T;: httpdate;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Khttpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @r;@F;Mi;N0;[[I" string;TI":'Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY];T; @r;[;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') #=> # @overload httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]);T;0; @r;@F;Ao;B;CT;Di;Ei;!@2 ;"I"qstatic VALUE date_s_httpdate(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__httpdate(klass, str); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date._jisx0301;F;[[I"str;T0;[[@Pi;T;:_jisx0301;0;[;{;IC;"'Returns a hash of parsed elements. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"_jisx0301(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @;[;I"@return [Hash];T;0; @;@F;Mi;N0;[[I" string;T0; @;[;I"VReturns a hash of parsed elements. @overload _jisx0301(string) @return [Hash];T;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"^static VALUE date_s__jisx0301(VALUE klass, VALUE str) { return date__jisx0301(str); };T;#I"static VALUE;T;$To; ; F; ;;;;I"Date.jisx0301;F;[[@0;[[@Pi;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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"8jisx0301(string='-4712-01-01'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI"''-4712-01-01'[, start=Date::ITALY];T; @;[;I"LCreates 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') #=> # @overload jisx0301(string='-4712-01-01'[, start=Date::ITALY]);T;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"^static VALUE date_s_jisx0301(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__jisx0301(klass, str); return d_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#initialize;F;[[@0;[[@Pi= ;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"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: num2int_with_frac(d, positive_inf); case 2: m = NUM2INT(vm); case 1: 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(rb_eArgError, "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(rb_eArgError, "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; ; F; ;,;;;I"Date#initialize_copy;F;[[I" date;T0;[[@Pi;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"kstatic VALUE d_lite_initialize_copy(VALUE copy, VALUE date) { rb_check_frozen(copy); rb_check_trusted(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; ; F; ;,;;;I"Date#fill;F;[;[[@Pi;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"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; ; F; ;,;;;I" Date#ajd;F;[;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"ajd;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"Ustatic VALUE d_lite_ajd(VALUE self) { get_d1(self); return m_ajd(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#amjd;F;[;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I" amjd;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"Wstatic VALUE d_lite_amjd(VALUE self) { get_d1(self); return m_amjd(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#jd;F;[;[[@Pi;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"jd;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @;[;I"@return [Integer];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@2 ;"I"^static VALUE d_lite_jd(VALUE self) { get_d1(self); return m_real_local_jd(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#mjd;F;[;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"mjd;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @5;[;I"@return [Integer];T;0; @5;@F;Mi;N0;[; @5;[;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; @5;@F;Ao;B;CT;Di ;Ei;!@2 ;"I"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; ; F; ;,;;;I" Date#ld;F;[;[[@Pi#;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;H ;II" overload;F;J0;; ;K0;#I"ld;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @P;[;I"@return [Integer];T;0; @P;@F;Mi;N0;[; @P;[;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; @P;@F;Ao;B;CT;Di;Ei!;!@2 ;"I"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; ; F; ;,;;;I"Date#year;F;[;[[@Pi3;T;;L;0;[;{;IC;"`Returns the year. Date.new(2001,2,3).year #=> 2001 (Date.new(1,1,1) - 1).year #=> 0 ;T;[o;H ;II" overload;F;J0;;L;K0;#I" year;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @k;[;I"@return [Integer];T;0; @k;@F;Mi;N0;[; @k;[;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; @k;@F;Ao;B;CT;Di*;Ei1;!@2 ;"I"\static VALUE d_lite_year(VALUE self) { get_d1(self); return m_real_year(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#yday;F;[;[[@PiB;T;;N;0;[;{;IC;"MReturns the day of the year (1-366). Date.new(2001,2,3).yday #=> 34 ;T;[o;H ;II" overload;F;J0;;N;K0;#I" yday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;I"qReturns the day of the year (1-366). Date.new(2001,2,3).yday #=> 34 @overload yday @return [Fixnum];T;0; @;@F;Ao;B;CT;Di:;Ei@;!@2 ;"I"`static VALUE d_lite_yday(VALUE self) { get_d1(self); return INT2FIX(m_yday(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#mon;F;[;[[@PiR;T;;J;0;[;{;IC;"@Returns the month (1-12). Date.new(2001,2,3).mon #=> 2 ;T;[o;H ;II" overload;F;J0;;J;K0;#I"mon;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;K;K0;#I" month;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;I"Returns the month (1-12). Date.new(2001,2,3).mon #=> 2 @overload mon @return [Fixnum] @overload month @return [Fixnum];T;0; @;@F;Ao;B;CT;DiI;EiQ;!@2 ;"I"^static VALUE d_lite_mon(VALUE self) { get_d1(self); return INT2FIX(m_mon(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#month;F;[;[[@PiR;T;;K;0;[;{;IC;"@Returns the month (1-12). Date.new(2001,2,3).mon #=> 2 ;T;[o;H ;II" overload;F;J0;;J;K0;#I"mon;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;K;K0;#I" month;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;DiI;EiQ;!@2 ;"I"^static VALUE d_lite_mon(VALUE self) { get_d1(self); return INT2FIX(m_mon(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#mday;F;[;[[@Pib;T;;H;0;[;{;IC;"LReturns the day of the month (1-31). Date.new(2001,2,3).mday #=> 3 ;T;[o;H ;II" overload;F;J0;;H;K0;#I" mday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;I;K0;#I"day;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiY;Eia;!@2 ;"I"`static VALUE d_lite_mday(VALUE self) { get_d1(self); return INT2FIX(m_mday(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#day;F;[;[[@Pib;T;;I;0;[;{;IC;"LReturns the day of the month (1-31). Date.new(2001,2,3).mday #=> 3 ;T;[o;H ;II" overload;F;J0;;H;K0;#I" mday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;;I;K0;#I"day;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;DiY;Eia;!@2 ;"I"`static VALUE d_lite_mday(VALUE self) { get_d1(self); return INT2FIX(m_mday(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#day_fraction;F;[;[[@Piq;T;:day_fraction;0;[;{;IC;"aReturns the fractional part of the day. DateTime.new(2001,2,3,12).day_fraction #=> (1/2) ;T;[o;H ;II" overload;F;J0;; ;K0;#I"day_fraction;T;IC;";T;[;[;I";T;0; @?;@F;Mi;N0;[; @?;[;I"zReturns the fractional part of the day. DateTime.new(2001,2,3,12).day_fraction #=> (1/2) @overload day_fraction;T;0; @?;@F;Ao;B;CT;Dii;Ein;!@2 ;"I"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; ; F; ;,;;;I"Date#cwyear;F;[;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I" cwyear;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @U;[;I"@return [Integer];T;0; @U;@F;Mi;N0;[; @U;[;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; @U;@F;Ao;B;CT;Diz;Ei;!@2 ;"I"`static VALUE d_lite_cwyear(VALUE self) { get_d1(self); return m_real_cwyear(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#cweek;F;[;[[@Pi;T;: cweek;0;[;{;IC;"QReturns the calendar week number (1-53). Date.new(2001,2,3).cweek #=> 5 ;T;[o;H ;II" overload;F;J0;; ;K0;#I" cweek;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @p;[;I"@return [Fixnum];T;0; @p;@F;Mi;N0;[; @p;[;I"vReturns the calendar week number (1-53). Date.new(2001,2,3).cweek #=> 5 @overload cweek @return [Fixnum];T;0; @p;@F;Ao;B;CT;Di;Ei;!@2 ;"I"bstatic VALUE d_lite_cweek(VALUE self) { get_d1(self); return INT2FIX(m_cweek(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#cwday;F;[;[[@Pi;T;: cwday;0;[;{;IC;"]Returns the day of calendar week (1-7, Monday is 1). Date.new(2001,2,3).cwday #=> 6 ;T;[o;H ;II" overload;F;J0;; ;K0;#I" cwday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@2 ;"I"bstatic VALUE d_lite_cwday(VALUE self) { get_d1(self); return INT2FIX(m_cwday(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#wnum0;F;[;[[@Pi;T;: wnum0;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"bstatic VALUE d_lite_wnum0(VALUE self) { get_d1(self); return INT2FIX(m_wnum0(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#wnum1;F;[;[[@Pi;T;: wnum1;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"bstatic VALUE d_lite_wnum1(VALUE self) { get_d1(self); return INT2FIX(m_wnum1(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#wday;F;[;[[@Pi;T;;M;0;[;{;IC;"VReturns the day of week (0-6, Sunday is zero). Date.new(2001,2,3).wday #=> 6 ;T;[o;H ;II" overload;F;J0;;M;K0;#I" wday;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@2 ;"I"`static VALUE d_lite_wday(VALUE self) { get_d1(self); return INT2FIX(m_wday(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#sunday?;F;[;[[@Pi;T;;W;0;[;{;IC;"(Returns true if the date is Sunday.;T;[o;H ;II" overload;F;J0;;W;K0;#I" sunday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"PReturns true if the date is Sunday. @overload sunday? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"lstatic VALUE d_lite_sunday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#monday?;F;[;[[@Pi;T;;X;0;[;{;IC;"(Returns true if the date is Monday.;T;[o;H ;II" overload;F;J0;;X;K0;#I" monday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"PReturns true if the date is Monday. @overload monday? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"lstatic VALUE d_lite_monday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 1); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#tuesday?;F;[;[[@Pi;T;;Y;0;[;{;IC;")Returns true if the date is Tuesday.;T;[o;H ;II" overload;F;J0;;Y;K0;#I" tuesday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;I"RReturns true if the date is Tuesday. @overload tuesday? @return [Boolean];T;0; @;@F;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"mstatic VALUE d_lite_tuesday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 2); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#wednesday?;F;[;[[@Pi;T;;Z;0;[;{;IC;"+Returns true if the date is Wednesday.;T;[o;H ;II" overload;F;J0;;Z;K0;#I"wednesday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @*;[;I"@return [Boolean];T;0; @*;@F;Mi;N0;[; @*;[;I"VReturns true if the date is Wednesday. @overload wednesday? @return [Boolean];T;0; @*;@F;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"ostatic VALUE d_lite_wednesday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 3); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#thursday?;F;[;[[@Pi;T;;[;0;[;{;IC;"*Returns true if the date is Thursday.;T;[o;H ;II" overload;F;J0;;[;K0;#I"thursday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @E;[;I"@return [Boolean];T;0; @E;@F;Mi;N0;[; @E;[;I"TReturns true if the date is Thursday. @overload thursday? @return [Boolean];T;0; @E;@F;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"nstatic VALUE d_lite_thursday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 4); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#friday?;F;[;[[@Pi;T;;\;0;[;{;IC;"(Returns true if the date is Friday.;T;[o;H ;II" overload;F;J0;;\;K0;#I" friday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @`;[;I"@return [Boolean];T;0; @`;@F;Mi;N0;[; @`;[;I"PReturns true if the date is Friday. @overload friday? @return [Boolean];T;0; @`;@F;Ao;B;CT;Di;Ei ;Mi;!@2 ;"I"lstatic VALUE d_lite_friday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 5); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#saturday?;F;[;[[@Pi;T;;];0;[;{;IC;"*Returns true if the date is Saturday.;T;[o;H ;II" overload;F;J0;;];K0;#I"saturday?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @{;[;I"@return [Boolean];T;0; @{;@F;Mi;N0;[; @{;[;I"TReturns true if the date is Saturday. @overload saturday? @return [Boolean];T;0; @{;@F;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"nstatic VALUE d_lite_saturday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 6); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#nth_kday?;F;[[I"n;T0[I"k;T0;[[@Pi#;T;:nth_kday?;0;[;{;IC;" ;T;[o;L ;II" return;F;J@;0;K[@; @;[;@;0; @;Mi;!@2 ;"I"]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; ; F; ;,;;;I"Date#hour;F;[;[[@PiO#;T;;G;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#min;F;[;[[@PiO#;T;;;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#minute;F;[;[[@PiO#;T;: minute;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#sec;F;[;[[@PiO#;T;;F;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#second;F;[;[[@PiO#;T;: second;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#julian?;F;[;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I" julian?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"kstatic VALUE d_lite_julian_p(VALUE self) { get_d1(self); return f_boolcast(m_julian_p(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#gregorian?;F;[;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"gregorian?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"qstatic VALUE d_lite_gregorian_p(VALUE self) { get_d1(self); return f_boolcast(m_gregorian_p(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#leap?;F;[;[[@Pi;T;; ;0;[;{;IC;"qReturns true if the year is a leap year. Date.new(2000).leap? #=> true Date.new(2001).leap? #=> false;T;[o;H ;II" overload;F;J0;; ;K0;#I" leap?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;Mi;!@2 ;"I"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; ; F; ;,;;;I"Date#start;F;[;[[@Pi;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;H ;II" overload;F;J0;;;K0;#I" start;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @6;[;I"@return [Float];T;0; @6;@F;Mi;N0;[; @6;[;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; @6;@F;Ao;B;CT;Di;Ei;!@2 ;"I"_static VALUE d_lite_start(VALUE self) { get_d1(self); return DBL2NUM(m_sg(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#new_start;F;[[@0;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"#new_start([start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @Q;@F;Mi;N0;[[I" [start;TI"Date::ITALY];T; @Q;[;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; @Q;@F;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#italy;F;[;[[@Pi/;T;: italy;0;[;{;IC;"9This method is equivalent to new_start(Date::ITALY). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" italy;T;IC;";T;[;[;I";T;0; @k;@F;Mi;N0;[; @k;[;I"KThis method is equivalent to new_start(Date::ITALY). @overload italy;T;0; @k;@F;Ao;B;CT;Di);Ei,;!@2 ;"I"^static VALUE d_lite_italy(VALUE self) { return dup_obj_with_new_start(self, ITALY); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#england;F;[;[[@Pi;;T;: england;0;[;{;IC;";This method is equivalent to new_start(Date::ENGLAND). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" england;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"OThis method is equivalent to new_start(Date::ENGLAND). @overload england;T;0; @;@F;Ao;B;CT;Di5;Ei8;!@2 ;"I"bstatic VALUE d_lite_england(VALUE self) { return dup_obj_with_new_start(self, ENGLAND); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#julian;F;[;[[@PiG;T;: julian;0;[;{;IC;":This method is equivalent to new_start(Date::JULIAN). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" julian;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"MThis method is equivalent to new_start(Date::JULIAN). @overload julian;T;0; @;@F;Ao;B;CT;DiA;EiD;!@2 ;"I"`static VALUE d_lite_julian(VALUE self) { return dup_obj_with_new_start(self, JULIAN); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#gregorian;F;[;[[@PiS;T;:gregorian;0;[;{;IC;"=This method is equivalent to new_start(Date::GREGORIAN). ;T;[o;H ;II" overload;F;J0;; ;K0;#I"gregorian;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"SThis method is equivalent to new_start(Date::GREGORIAN). @overload gregorian;T;0; @;@F;Ao;B;CT;DiM;EiP;!@2 ;"I"fstatic VALUE d_lite_gregorian(VALUE self) { return dup_obj_with_new_start(self, GREGORIAN); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#+;F;[[I" other;T0;[[@Pi;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;H ;II" overload;F;J0;;(;K0;#I" +(other);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I" Date#-;F;[[I" other;T0;[[@Pi;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;H ;II" overload;F;J0;;<;K0;#I" -(other);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#next_day;F;[[@0;[[@Pi6;T;: next_day;0;[;{;IC;"(This method is equivalent to d + n. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"next_day([n=1]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[n;TI"1];T; @;[;I"DThis method is equivalent to d + n. @overload next_day([n=1]);T;0; @;@F;Ao;B;CT;Di0;Ei3;!@2 ;"I"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; ; F; ;,;;;I"Date#prev_day;F;[[@0;[[@PiG;T;: prev_day;0;[;{;IC;"(This method is equivalent to d - n. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"prev_day([n=1]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"[n;TI"1];T; @;[;I"DThis method is equivalent to d - n. @overload prev_day([n=1]);T;0; @;@F;Ao;B;CT;DiA;EiD;!@2 ;"I"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; ; F; ;,;;;I"Date#next;F;[;[[@PiY;T;;;0;[;{;IC;"6Returns a date object denoting the following day. ;T;[o;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[;[;I";T;0; @+;@F;Mi;N0;[; @+o;H ;II" overload;F;J0;;;K0;#I" next;T;IC;";T;[;[;I";T;0; @+;@F;Mi;N0;[; @+;[;I"VReturns a date object denoting the following day. @overload succ @overload next;T;0; @+;@F;Ao;B;CT;DiR;EiV;!@2 ;"I"astatic VALUE d_lite_next(VALUE self) { return d_lite_next_day(0, (VALUE *)NULL, self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#succ;F;[;[[@PiY;T;;;0;[;{;IC;"6Returns a date object denoting the following day. ;T;[o;H ;II" overload;F;J0;;;K0;#I" succ;T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[; @Io;H ;II" overload;F;J0;;;K0;#I" next;T;IC;";T;[;[;I";T;0; @I;@F;Mi;N0;[; @I;[;@E;0; @I;@F;Ao;B;CT;DiR;EiV;!@2 ;"I"astatic VALUE d_lite_next(VALUE self) { return d_lite_next_day(0, (VALUE *)NULL, self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#>>;F;[[I" other;T0;[[@Piv;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;H ;II" overload;F;J0;;;K0;#I" >>(n);T;IC;";T;[;[;I";T;0; @f;@F;Mi;N0;[[I"n;T0; @f;[;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;@F;Ao;B;CT;Di_;Eis;!@2 ;"I" 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(rb_eArgError, "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; ; F; ;,;;;I" Date#<<;F;[[I" other;T0;[[@Pi;T;;Q;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;H ;II" overload;F;J0;;Q;K0;#I" <<(n);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#next_month;F;[[@0;[[@Pi;T;:next_month;0;[;{;IC;"DThis method is equivalent to d >> n. See Date#>> for examples. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"next_month([n=1]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#prev_month;F;[[@0;[[@Pi;T;:prev_month;0;[;{;IC;"DThis method is equivalent to d << n. See Date#<< for examples. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"prev_month([n=1]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#next_year;F;[[@0;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"next_year([n=1]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#prev_year;F;[[@0;[[@Pi;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;H ;II" overload;F;J0;; ;K0;#I"prev_year([n=1]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#step;F;[[@0;[[@Pi;T;;;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;H ;II" overload;F;J0;;;K0;#I"step(limit[, step=1]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I"limit[, step;TI"1];T; @o;H ;II" overload;F;J0;;;K0;#I"step(limit[, step=1]);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" date;T; @o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"!@yield [date] @return [self];T;0; @;@F;Mi;N0;[[I"limit[, step;TI"1];T; @;[;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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#upto;F;[[I"max;T0;[[@PiJ;T;;0;0;[;{;IC;";This method is equivalent to step(max, 1){|date| ...}. ;T;[o;H ;II" overload;F;J0;;0;K0;#I"upto(max);T;IC;";T;[;[;I";T;0; @1;@F;Mi;N0;[[I"max;T0; @1o;H ;II" overload;F;J0;;0;K0;#I"upto(max);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" date;T; @1o;L ;II" return;F;JI";T;0;K[I" self;T; @1;[;I"!@yield [date] @return [self];T;0; @1;@F;Mi;N0;[[I"max;T0; @1;[;I"This method is equivalent to step(max, 1){|date| ...}. @overload upto(max) @overload upto(max) @yield [date] @return [self];T;0; @1;@F;Ao;B;CT;DiC;EiI;!@2 ;"I"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; ; F; ;,;;;I"Date#downto;F;[[I"min;T0;[[@Pi`;T;;;0;[;{;IC;"= 0) { rb_yield(date); date = d_lite_plus(date, INT2FIX(-1)); } return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I" Date#<=>;F;[[I" other;T0;[[@Pi;T;;V;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;H ;II" overload;F;J0;;V;K0;#I"<=>(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[ I"-1;TI"0;TI"+1;TI"nil;T; @;[;I"@return [-1, 0, +1, nil];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I" Date#===;F;[[I" other;T0;[[@Pi ;T;;O;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;H ;II" overload;F;J0;;O;K0;#I"===(other);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @;[;I"@return [Boolean];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei ;!@2 ;"I"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; ; F; ;,;;;I"Date#eql?;F;[[I" other;T0;[[@Pi,;T;;R;0;[;{;IC;" :nodoc:;T;[o;L ;II" return;F;J@;0;K[@; @;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di+;Ei+;Mi;!@2 ;"I"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; ; F; ;,;;;I"Date#hash;F;[;[[@Pi5;T;;U;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di4;Ei4;!@2 ;"I"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; ; F; ;,;;;I"Date#to_s;F;[;[[@PiQ;T;;h;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;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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; @;@F;Ao;B;CT;DiH;EiO;!@2 ;"I"^static VALUE d_lite_to_s(VALUE self) { return strftimev("%Y-%m-%d", self, set_tmx); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#inspect_raw;F;[;[[@Pi;T;:inspect_raw;0;[;{;IC;" ;T;[;[;@;0; @ ;!@2 ;"I"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; ; F; ;,;;;I"Date#inspect;F;[;[[@Pi;T;;i;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;H ;II" overload;F;J0;;i;K0;#I" inspect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"1Returns 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; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#strftime;F;[[@0;[[@Pi ;T;;c;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;H ;II" overload;F;J0;;c;K0;#I"strftime([format='%F']);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @1;[;I"@return [String];T;0; @1;@F;Mi;N0;[[I" [format;TI" '%F'];T; @1;[;I"b 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; @1;@F;Ao;B;CT;Di[;Ei ;!@2 ;"I"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; ; F; ;,;;;I"Date#asctime;F;[;[[@Pi.;T;;D;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;H ;II" overload;F;J0;;D;K0;#I" asctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @P;[;I"@return [String];T;0; @P;@F;Mi;N0;[; @Po;H ;II" overload;F;J0;;C;K0;#I" ctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @P;[;I"@return [String];T;0; @P;@F;Mi;N0;[; @P;[;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; @P;@F;Ao;B;CT;Di$;Ei-;!@2 ;"I"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; ; F; ;,;;;I"Date#ctime;F;[;[[@Pi.;T;;C;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;H ;II" overload;F;J0;;D;K0;#I" asctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @x;[;I"@return [String];T;0; @x;@F;Mi;N0;[; @xo;H ;II" overload;F;J0;;C;K0;#I" ctime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @x;[;I"@return [String];T;0; @x;@F;Mi;N0;[; @x;[;@t;0; @x;@F;Ao;B;CT;Di$;Ei-;!@2 ;"I"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; ; F; ;,;;;I"Date#iso8601;F;[;[[@Pi;;T;; ;0;[;{;IC;"1This method is equivalent to strftime('%F'). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" iso8601;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I"xmlschema;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"This method is equivalent to strftime('%F'). @overload iso8601 @return [String] @overload xmlschema @return [String];T;0; @;@F;Ao;B;CT;Di4;Ei:;!@2 ;"I"astatic VALUE d_lite_iso8601(VALUE self) { return strftimev("%Y-%m-%d", self, set_tmx); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#xmlschema;F;[;[[@Pi;;T;; ;0;[;{;IC;"1This method is equivalent to strftime('%F'). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" iso8601;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I"xmlschema;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;Di4;Ei:;!@2 ;"I"astatic VALUE d_lite_iso8601(VALUE self) { return strftimev("%Y-%m-%d", self, set_tmx); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#rfc3339;F;[;[[@PiG;T;; ;0;[;{;IC;"7This method is equivalent to strftime('%FT%T%:z'). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" rfc3339;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;I"^This method is equivalent to strftime('%FT%T%:z'). @overload rfc3339 @return [String];T;0; @;@F;Ao;B;CT;DiA;EiE;!@2 ;"I"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; ; F; ;,;;;I"Date#rfc2822;F;[;[[@PiT;T;; ;0;[;{;IC;"BThis method is equivalent to strftime('%a, %-d %b %Y %T %z'). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" rfc2822;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ o;H ;II" overload;F;J0;; ;K0;#I" rfc822;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[; @ ;[;I"This method is equivalent to strftime('%a, %-d %b %Y %T %z'). @overload rfc2822 @return [String] @overload rfc822 @return [String];T;0; @ ;@F;Ao;B;CT;DiM;EiS;!@2 ;"I"lstatic VALUE d_lite_rfc2822(VALUE self) { return strftimev("%a, %-d %b %Y %T %z", self, set_tmx); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#rfc822;F;[;[[@PiT;T;; ;0;[;{;IC;"BThis method is equivalent to strftime('%a, %-d %b %Y %T %z'). ;T;[o;H ;II" overload;F;J0;; ;K0;#I" rfc2822;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @1;[;I"@return [String];T;0; @1;@F;Mi;N0;[; @1o;H ;II" overload;F;J0;; ;K0;#I" rfc822;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @1;[;I"@return [String];T;0; @1;@F;Mi;N0;[; @1;[;@-;0; @1;@F;Ao;B;CT;DiM;EiS;!@2 ;"I"lstatic VALUE d_lite_rfc2822(VALUE self) { return strftimev("%a, %-d %b %Y %T %z", self, set_tmx); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#httpdate;F;[;[[@Pia;T;; ;0;[;{;IC;"UThis method is equivalent to strftime('%a, %d %b %Y %T GMT'). See also RFC 2616. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" httpdate;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @X;[;I"@return [String];T;0; @X;@F;Mi;N0;[; @X;[;I"}This method is equivalent to strftime('%a, %d %b %Y %T GMT'). See also RFC 2616. @overload httpdate @return [String];T;0; @X;@F;Ao;B;CT;DiZ;Ei_;!@2 ;"I"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; ; F; ;,;;;I"Date#jisx0301;F;[;[[@Pi;T;; ;0;[;{;IC;"]Returns a string in a JIS X 0301 format. Date.new(2001,2,3).jisx0301 #=> "H13.02.03" ;T;[o;H ;II" overload;F;J0;; ;K0;#I" jisx0301;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @s;[;I"@return [String];T;0; @s;@F;Mi;N0;[; @s;[;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; @s;@F;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#marshal_dump_old;F;[;[[@Pi;T;:marshal_dump_old;0;[;{;IC;" ;T;[;[;@;0; @;!@2 ;"I""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; ; F; ;,;;;I"Date#marshal_dump;F;[;[[@Pi;T;;e;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#marshal_load;F;[[I"a;T0;[[@Pi;T;;f;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"static 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); rb_check_trusted(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) { rb_raise(rb_eArgError, "cannot load complex into simple"); } set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD); } else { 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; ; F; ;;;;I"Date._load;F;[[I"s;T0;[[@Pi;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @;@F;Ao;B;CT;Di;Ei;!@2 ;"I"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; ; F; ;,;;;I"Date#to_time;F;[;[[@Pim!;T;;3;0;[;{;IC;".Returns a Time object which denotes self. ;T;[o;H ;II" overload;F;J0;;3;K0;#I" to_time;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @;[;I"@return [Time];T;0; @;@F;Mi;N0;[; @;[;I"SReturns a Time object which denotes self. @overload to_time @return [Time];T;0; @;@F;Ao;B;CT;Dig!;Eik!;!@2 ;"I"static VALUE date_to_time(VALUE self) { get_d1(self); return f_local3(rb_cTime, m_real_year(dat), INT2FIX(m_mon(dat)), INT2FIX(m_mday(dat))); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#to_date;F;[;[[@Pi~!;T;;4;0;[;{;IC;"Returns self. ;T;[o;H ;II" overload;F;J0;;4;K0;#I" to_date;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @;[;I"7Returns self. @overload to_date @return [self];T;0; @;@F;Ao;B;CT;Dix!;Ei|!;!@2 ;"I"?static VALUE date_to_date(VALUE self) { return self; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"Date#to_datetime;F;[;[[@Pi!;T;;5;0;[;{;IC;"2Returns a DateTime object which denotes self. ;T;[o;H ;II" overload;F;J0;;5;K0;#I"to_datetime;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"JReturns a DateTime object which denotes self. @overload to_datetime;T;0; @;@F;Ao;B;CT;Di!;Ei!;!@2 ;"I"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; ; F; ;;;;I"Date.test_civil;F;[;[[@Pi";T;:test_civil;0;[;{;IC;" tests ;T;[;[;I" tests;T;0; @;@F;Ao;B;CT;Di%;Ei%;!@2 ;"I"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; ; F; ;;;;I"Date.test_ordinal;F;[;[[@Pi:";T;:test_ordinal;0;[;{;IC;" ;T;[;[;@;0; @";!@2 ;"I"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; ; F; ;;;;I"Date.test_commercial;F;[;[[@Pib";T;:test_commercial;0;[;{;IC;" ;T;[;[;@;0; @.;!@2 ;"I"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; ; F; ;;;;I"Date.test_weeknum;F;[;[[@Pi";T;:test_weeknum;0;[;{;IC;" ;T;[;[;@;0; @:;!@2 ;"I"*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; ; F; ;;;;I"Date.test_nth_kday;F;[;[[@Pi";T;:test_nth_kday;0;[;{;IC;" ;T;[;[;@;0; @F;!@2 ;"I"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; ; F; ;;;;I"Date.test_unit_conv;F;[;[[@Pi";T;:test_unit_conv;0;[;{;IC;" ;T;[;[;@;0; @R;!@2 ;"I"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; ; F; ;;;;I"Date.test_all;F;[;[[@Pi #;T;: test_all;0;[;{;IC;" ;T;[;[;@;0; @^;!@2 ;"I"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;&@2 ;'IC;[;&@2 ;(IC;[@;&@2 ;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Pi$;F;: Date;;0;;;[;{;IC;" ;T;[;[;@;0; @2 ;Mi;!@;I" Date;F;1@ # DateTime.jd(2451945) #=> # DateTime.jd(Rational('0.5')) #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Rjd([jd=0[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]);T;IC;";T;[;[;I";T;0; @{;@F;Mi;N0;[[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;Ao;B;CT;Di*;Ei3;!@y;"I"8static 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: num2int_with_frac(s, positive_inf); case 3: num2int_with_frac(min, 3); case 2: num2int_with_frac(h, 2); case 1: 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(rb_eArgError, "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; ; F; ;;;;I"DateTime.ordinal;F;[[@0;[[@Piz;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"gordinal([year=-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Din;Eiw;!@y;"I"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: num2int_with_frac(s, positive_inf); case 4: num2int_with_frac(min, 4); case 3: num2int_with_frac(h, 3); case 2: num2int_with_frac(d, 2); case 1: 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(rb_eArgError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(rb_eArgError, "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; ; F; ;;;;I"DateTime.civil;F;[[@0;[[@Pi;T;; ;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;H ;II" overload;F;J0;; ;K0;#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;Mi;N0;[[I" [year;TI"c-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T; @o;H ;II" overload;F;J0;; ;K0;#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;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@y;"I"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; ; F; ;;;;I"DateTime.new;F;[[@0;[[@Pi;T;; ;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;H ;II" overload;F;J0;; ;K0;#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;Mi;N0;[[I" [year;TI"c-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T; @o;H ;II" overload;F;J0;; ;K0;#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;Mi;N0;[[I" [year;TI"c-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T; @;[;@;0; @;@F;Ao;B;CT;Di;Ei;!@y;"I"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; ; F; ;;;;I"DateTime.commercial;F;[[@0;[[@Pi3;T;; ;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;H ;II" overload;F;J0;; ;K0;#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;Mi;N0;[[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;Ao;B;CT;Di(;Ei0;!@y;"I"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: num2int_with_frac(s, positive_inf); case 5: num2int_with_frac(min, 5); case 4: num2int_with_frac(h, 4); case 3: num2int_with_frac(d, 3); case 2: w = NUM2INT(vw); case 1: 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(rb_eArgError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(rb_eArgError, "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; ; F; ;;;;I"DateTime.weeknum;F;[[@0;[[@Piv;T;; ;0;[;{;IC;" ;T;[;[;@;0; @;!@y;"I"Zstatic 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(rb_eArgError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(rb_eArgError, "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; ; F; ;;;;I"DateTime.nth_kday;F;[[@0;[[@Pi;T;; ;0;[;{;IC;" ;T;[;[;@;0; @;!@y;"I"hstatic 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(rb_eArgError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(rb_eArgError, "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; ; F; ;;;;I"DateTime.now;F;[[@0;[[@Pi ;T;;7;0;[;{;IC;"zCreates a DateTime object denoting the present time. DateTime.now #=> # ;T;[o;H ;II" overload;F;J0;;7;K0;#I"now([start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @,;@F;Mi;N0;[[I" [start;TI"Date::ITALY];T; @,;[;I"Creates a DateTime object denoting the present time. DateTime.now #=> # @overload now([start=Date::ITALY]);T;0; @,;@F;Ao;B;CT;Di;Ei;!@y;"I"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) #ifdef HAVE_ALTZONE 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; ; F; ;;;;I"DateTime._strptime;F;[[@0;[[@Pi;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"*_strptime(string[, format='%FT%T%z']);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @F;[;I"@return [Hash];T;0; @F;@F;Mi;N0;[[I"string[, format;TI"'%FT%T%z'];T; @F;[;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;@F;Ao;B;CT;Di;Ei;!@y;"I"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; ; F; ;;;;I"DateTime.strptime;F;[[@0;[[@Pi;T;; ;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;H ;II" overload;F;J0;; ;K0;#I"]strptime([string='-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=Date::ITALY]]]);T;IC;";T;[;[;I";T;0; @e;@F;Mi;N0;[[I" [string;TI"K'-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=Date::ITALY]]];T; @e;[;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; @e;@F;Ao;B;CT;Di;Ei;!@y;"I"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; ; F; ;;;;I"DateTime.parse;F;[[@0;[[@Pi;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 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') #=> # ;T;[o;H ;II" overload;F;J0;;;K0;#I"Qparse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI"C'-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]];T; @;[;I"bParses the given representation of date and time, and creates a DateTime object. This method does not function as a validator. 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') #=> # @overload parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]);T;0; @;@F;Ao;B;CT;Di ;Ei;!@y;"I"static VALUE datetime_s_parse(int argc, VALUE *argv, VALUE klass) { VALUE str, comp, sg; rb_scan_args(argc, argv, "03", &str, &comp, &sg); 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); } { VALUE argv2[2], hash; argv2[0] = str; argv2[1] = comp; hash = date_s__parse(2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"DateTime.iso8601;F;[[@0;[[@PiF;T;; ;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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Fiso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];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') #=> # @overload iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;0; @;@F;Ao;B;CT;Di8;EiC;!@y;"I"pstatic VALUE datetime_s_iso8601(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__iso8601(klass, str); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"DateTime.rfc3339;F;[[@0;[[@Pid;T;; ;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Frfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];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') #=> # @overload rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;0; @;@F;Ao;B;CT;DiZ;Eia;!@y;"I"pstatic VALUE datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__rfc3339(klass, str); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"DateTime.xmlschema;F;[[@0;[[@Pi;T;; ;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Hxmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];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') #=> # @overload xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;0; @;@F;Ao;B;CT;Dix;Ei;!@y;"I"tstatic VALUE datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__xmlschema(klass, str); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"DateTime.rfc2822;F;[[@0;[[@Pi;T;; ;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Krfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @o;H ;II" overload;F;J0;; ;K0;#I"Jrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @;[;I"oCreates 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') #=> # @overload rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) @overload rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;0; @;@F;Ao;B;CT;Di;Ei;!@y;"I"ustatic VALUE datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__rfc2822(klass, str); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"DateTime.rfc822;F;[[@0;[[@Pi;T;; ;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Krfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @ o;H ;II" overload;F;J0;; ;K0;#I"Jrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T; @ ;[;@;0; @ ;@F;Ao;B;CT;Di;Ei;!@y;"I"ustatic VALUE datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__rfc2822(klass, str); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"DateTime.httpdate;F;[[@0;[[@Pi;T;; ;0;[;{;IC;"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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Khttpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @0;@F;Mi;N0;[[I" string;TI":'Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY];T; @0;[;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') #=> # @overload httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]);T;0; @0;@F;Ao;B;CT;Di;Ei;!@y;"I"vstatic VALUE datetime_s_httpdate(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__httpdate(klass, str); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;;;;I"DateTime.jisx0301;F;[[@0;[[@Pi;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') #=> # ;T;[o;H ;II" overload;F;J0;; ;K0;#I"Gjisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;IC;";T;[;[;I";T;0; @J;@F;Mi;N0;[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];T; @J;[;I"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') #=> # @overload jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]);T;0; @J;@F;Ao;B;CT;Di;Ei;!@y;"I"rstatic VALUE datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass) { VALUE str, sg; rb_scan_args(argc, argv, "02", &str, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { VALUE hash = date_s__jisx0301(klass, str); return dt_new_by_frags(klass, hash, sg); } };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#hour;F;[;[[@Pi>;T;;G;0;[;{;IC;"JReturns the hour (0-23). DateTime.new(2001,2,3,4,5,6).hour #=> 4 ;T;[o;H ;II" overload;F;J0;;G;K0;#I" hour;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @d;[;I"@return [Fixnum];T;0; @d;@F;Mi;N0;[; @d;[;I"nReturns the hour (0-23). DateTime.new(2001,2,3,4,5,6).hour #=> 4 @overload hour @return [Fixnum];T;0; @d;@F;Ao;B;CT;Di6;Ei<;!@y;"I"`static VALUE d_lite_hour(VALUE self) { get_d1(self); return INT2FIX(m_hour(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#min;F;[;[[@PiN;T;;;0;[;{;IC;"KReturns the minute (0-59). DateTime.new(2001,2,3,4,5,6).min #=> 5 ;T;[o;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I" minute;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiE;EiM;!@y;"I"^static VALUE d_lite_min(VALUE self) { get_d1(self); return INT2FIX(m_min(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#minute;F;[;[[@PiN;T;; ;0;[;{;IC;"KReturns the minute (0-59). DateTime.new(2001,2,3,4,5,6).min #=> 5 ;T;[o;H ;II" overload;F;J0;;;K0;#I"min;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I" minute;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;DiE;EiM;!@y;"I"^static VALUE d_lite_min(VALUE self) { get_d1(self); return INT2FIX(m_min(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#sec;F;[;[[@Pi^;T;;F;0;[;{;IC;"KReturns the second (0-59). DateTime.new(2001,2,3,4,5,6).sec #=> 6 ;T;[o;H ;II" overload;F;J0;;F;K0;#I"sec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I" second;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;DiU;Ei];!@y;"I"^static VALUE d_lite_sec(VALUE self) { get_d1(self); return INT2FIX(m_sec(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#second;F;[;[[@Pi^;T;; ;0;[;{;IC;"KReturns the second (0-59). DateTime.new(2001,2,3,4,5,6).sec #=> 6 ;T;[o;H ;II" overload;F;J0;;F;K0;#I"sec;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;; ;K0;#I" second;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Fixnum;T; @;[;I"@return [Fixnum];T;0; @;@F;Mi;N0;[; @;[;@;0; @;@F;Ao;B;CT;DiU;Ei];!@y;"I"^static VALUE d_lite_sec(VALUE self) { get_d1(self); return INT2FIX(m_sec(dat)); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#sec_fraction;F;[;[[@Pin;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;H ;II" overload;F;J0;; ;K0;#I"sec_fraction;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @o;H ;II" overload;F;J0;:second_fraction;K0;#I"second_fraction;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Die;Eik;!@y;"I"dstatic VALUE d_lite_sec_fraction(VALUE self) { get_d1(self); return m_sf_in_sec(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#second_fraction;F;[;[[@Pin;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;H ;II" overload;F;J0;; ;K0;#I"sec_fraction;T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[; @;o;H ;II" overload;F;J0;; ;K0;#I"second_fraction;T;IC;";T;[;[;I";T;0; @;;@F;Mi;N0;[; @;;[;@7;0; @;;@F;Ao;B;CT;Die;Eik;!@y;"I"dstatic VALUE d_lite_sec_fraction(VALUE self) { get_d1(self); return m_sf_in_sec(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#offset;F;[;[[@Pi};T;;;0;[;{;IC;"JReturns the offset. DateTime.parse('04pm+0730').offset #=> (5/16) ;T;[o;H ;II" overload;F;J0;;;K0;#I" offset;T;IC;";T;[;[;I";T;0; @X;@F;Mi;N0;[; @X;[;I"]Returns the offset. DateTime.parse('04pm+0730').offset #=> (5/16) @overload offset;T;0; @X;@F;Ao;B;CT;Diu;Eiz;!@y;"I"^static VALUE d_lite_offset(VALUE self) { get_d1(self); return m_of_in_day(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#zone;F;[;[[@Pi;T;;Q;0;[;{;IC;"MReturns the timezone. DateTime.parse('04pm+0730').zone #=> "+07:30" ;T;[o;H ;II" overload;F;J0;;Q;K0;#I" zone;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @n;[;I"@return [String];T;0; @n;@F;Mi;N0;[; @n;[;I"qReturns the timezone. DateTime.parse('04pm+0730').zone #=> "+07:30" @overload zone @return [String];T;0; @n;@F;Ao;B;CT;Di;Ei;!@y;"I"Wstatic VALUE d_lite_zone(VALUE self) { get_d1(self); return m_zone(dat); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#new_offset;F;[[@0;[[@Pix;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;H ;II" overload;F;J0;; ;K0;#I"new_offset([offset=0]);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Din;Eiu;!@y;"I"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; ; F; ;,;;;I"DateTime#to_s;F;[;[[@Pi ;T;;h;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;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@y;"I"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; ; F; ;,;;;I"DateTime#strftime;F;[[@0;[[@Pi ;T;;c;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;H ;II" overload;F;J0;;c;K0;#I""strftime([format='%FT%T%:z']);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I" [format;TI"'%FT%T%:z'];T; @;[;I"H 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;Ao;B;CT;Di ;Ei ;!@y;"I"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; ; F; ;,;;;I"DateTime#iso8601;F;[[@0;[[@Pi ;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').iso8601(9) #=> "2001-02-03T04:05:06.123456789+07:00" ;T;[o;H ;II" overload;F;J0;; ;K0;#I"iso8601([n=0]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[I"[n;TI"0];T; @o;H ;II" overload;F;J0;; ;K0;#I"xmlschema([n=0]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @;[;I"@return [String];T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@y;"I"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; ; F; ;,;;;I"DateTime#xmlschema;F;[[@0;[[@Pi ;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').iso8601(9) #=> "2001-02-03T04:05:06.123456789+07:00" ;T;[o;H ;II" overload;F;J0;; ;K0;#I"iso8601([n=0]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[I"[n;TI"0];T; @ o;H ;II" overload;F;J0;; ;K0;#I"xmlschema([n=0]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @ ;[;I"@return [String];T;0; @ ;@F;Mi;N0;[[I"[n;TI"0];T; @ ;[;@;0; @ ;@F;Ao;B;CT;Di ;Ei ;!@y;"I"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; ; F; ;,;;;I"DateTime#rfc3339;F;[[@0;[[@Pi ;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;H ;II" overload;F;J0;; ;K0;#I"rfc3339([n=0]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @:;[;I"@return [String];T;0; @:;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei ;!@y;"I"vstatic VALUE dt_lite_rfc3339(int argc, VALUE *argv, VALUE self) { return dt_lite_iso8601(argc, argv, self); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"DateTime#jisx0301;F;[[@0;[[@Pi!;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;H ;II" overload;F;J0;; ;K0;#I"jisx0301([n=0]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @Y;[;I"@return [String];T;0; @Y;@F;Mi;N0;[[I"[n;TI"0];T; @Y;[;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; @Y;@F;Ao;B;CT;Di ;Ei ;!@y;"I"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; ; F; ;,;;;I"DateTime#to_time;F;[;[[@Pi!;T;;3;0;[;{;IC;".Returns a Time object which denotes self. ;T;[o;H ;II" overload;F;J0;;3;K0;#I" to_time;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Time;T; @x;[;I"@return [Time];T;0; @x;@F;Mi;N0;[; @x;[;I"SReturns a Time object which denotes self. @overload to_time @return [Time];T;0; @x;@F;Ao;B;CT;Di!;Ei!;!@y;"I"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; ; F; ;,;;;I"DateTime#to_date;F;[;[[@Pi!;T;;4;0;[;{;IC;".Returns a Date object which denotes self. ;T;[o;H ;II" overload;F;J0;;4;K0;#I" to_date;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"BReturns a Date object which denotes self. @overload to_date;T;0; @;@F;Ao;B;CT;Di!;Ei!;!@y;"I"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; ; F; ;,;;;I"DateTime#to_datetime;F;[;[[@Pi!;T;;5;0;[;{;IC;"Returns self. ;T;[o;H ;II" overload;F;J0;;5;K0;#I"to_datetime;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" self;T; @;[;I"@return [self];T;0; @;@F;Mi;N0;[; @;[;I";Returns self. @overload to_datetime @return [self];T;0; @;@F;Ao;B;CT;Di!;Ei!;!@y;"I"Gstatic VALUE datetime_to_datetime(VALUE self) { return self; };T;#I"static VALUE;T;$T;&@y;'IC;[;&@y;(IC;[;&@y;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@Piz%;F;: DateTime;;0;;;[;{;IC;" ;T;[;[;@;0; @y;Mi;!@;I" DateTime;F;1@2 @Oo; ;IC;[ o; ; F; ;,;;;I"PTY#getpty;F;[[@0;[[I"ext/pty/pty.c;Ti2;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;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @;[;I"@yield [r, w, pid];T;0; @;@F;Mi;N0;[[I"command_line;T0; @o;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"command_line;T0; @o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @;[;I"@yield [r, w, pid];T;0; @;@F;Mi;N0;[[I" command;T0[I"arguments;T0[I"...;T0; @o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"PTY.getpty;F;@;@;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;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @,;[;I"@yield [r, w, pid];T;0; @,;@F;Mi;N0;[[I"command_line;T0; @,o;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @,;[;I"@return [Array];T;0; @,;@F;Mi;N0;[[I"command_line;T0; @,o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @,;[;I"@yield [r, w, pid];T;0; @,;@F;Mi;N0;[[I" command;T0[I"arguments;T0[I"...;T0; @,o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @,;[;I"@return [Array];T;0; @,;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei3;Mi;!@;"@*;#@+;$To; ; F; ;,;;;I"PTY#spawn;F;[[@0;[[@i2;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;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @|;[;I"@yield [r, w, pid];T;0; @|;@F;Mi;N0;[[I"command_line;T0; @|o;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @|;[;I"@return [Array];T;0; @|;@F;Mi;N0;[[I"command_line;T0; @|o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @|;[;I"@yield [r, w, pid];T;0; @|;@F;Mi;N0;[[I" command;T0[I"arguments;T0[I"...;T0; @|o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @|;[;I"@return [Array];T;0; @|;@F;Mi;N0;[[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;N0;!@;"I"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; ; T; ;;;;I"PTY.spawn;F;@~;@;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;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @;[;I"@yield [r, w, pid];T;0; @;@F;Mi;N0;[[I"command_line;T0; @o;H ;II" overload;F;J0;;;K0;#I"spawn(command_line);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I"command_line;T0; @o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"r;TI"w;TI"pid;T; @;[;I"@yield [r, w, pid];T;0; @;@F;Mi;N0;[[I" command;T0[I"arguments;T0[I"...;T0; @o;H ;II" overload;F;J0;;;K0;#I"#spawn(command, arguments, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @;[;I"@return [Array];T;0; @;@F;Mi;N0;[[I" command;T0[I"arguments;T0[I"...;T0; @;[;@z;0; @;@F;Ao;B;CT;Di;Ei3;Mi;!@;"@;#@;$To; ; F; ;;;;I"PTY.check;F;[[@0;[[@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;H ;II" overload;F;J0;;;K0;#I"check(pid, raise = false);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"Process::Status;TI"nil;T; @!;[;I"#@return [Process::Status, nil];T;0; @!;@F;Mi;N0;[[I"pid;T0[I" raise;TI" false;T; @!o;H ;II" overload;F;J0;;;K0;#I"check(pid, true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;TI"raises PTY::ChildExited;T; @!;[;I"+@return [nil, raises PTY::ChildExited];T;0; @!;@F;Mi;N0;[[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;Ao;B;CT;Diu;Ei;!@;"I"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; ; F; ;;;;I" PTY.open;F;[;[[@i;T;;;0;[;{;IC;"Allocates a pty (pseudo-terminal). In the block form, yields two arguments 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;H ;II" overload;F;J0;;;K0;#I" open;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @U;[;I"@return [Array];T;0; @U;@F;Mi;N0;[; @Uo;H ;II" overload;F;J0;;;K0;#I" open;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"master_io;TI"slave_file;T; @U;[;I"#@yield [master_io, slave_file];T;0; @U;@F;Mi;N0;[; @U;[;I"Allocates a pty (pseudo-terminal). In the block form, yields two arguments 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; @U;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"PTY::ChildExited#status;T;[;[[@iK;T;;5;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;Ao;B;CT;DiH;EiJ;!@~;"I"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;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!o;2 ;30;40;50;:PTY;!@;7@;F0;I"PTY::ChildExited;T;1@*;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;; ;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"PTY;Fo; ;IC;[o; ;IC;[o; ;IC;[o; ;IC;["o; ; F; ;;;;I"+JSON::Ext::Generator::State.from_state;T;[[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;H ;II" overload;F;J0;; ;K0;#I"from_state(opts);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" opts;T0; @;[;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; @;@F;Ao;B;CT;Di;Ei;!@;"I"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 { if (NIL_P(CJSON_SAFE_STATE_PROTOTYPE)) { CJSON_SAFE_STATE_PROTOTYPE = rb_const_get(mJSON, i_SAFE_STATE_PROTOTYPE); } return rb_funcall(CJSON_SAFE_STATE_PROTOTYPE, i_dup, 0); } };T;#I"=static VALUE cState_from_state_s(VALUE self, VALUE opts);T;$To; ; F; ;,;;;I"+JSON::Ext::Generator::State#initialize;T;[[@0;[[@i;T;;;0;[;{;IC;"Instantiates 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. * *buffer_initial_length*: sets the initial length of the generator's internal buffer. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"new(opts = {});T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" opts;TI"{};T; @;[;I"Instantiates 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. * *buffer_initial_length*: sets the initial length of the generator's internal buffer. @overload new(opts = {});T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I";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; ; F; ;,;;;I"0JSON::Ext::Generator::State#initialize_copy;T;[[I" orig;T0;[[@i;T;;];0;[;{;IC;"UInitializes this object from orig if it can be duplicated/cloned and returns it. ;T;[o;H ;II" overload;F;J0;;];K0;#I"initialize_copy(orig);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"'JSON::Ext::Generator::State#indent;T;[;[[@i;T;: indent;0;[;{;IC;"GReturns the string that is used to indent levels in the JSON text. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" indent();T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"\Returns the string that is used to indent levels in the JSON text. @overload indent();T;0; @;@F;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"(JSON::Ext::Generator::State#indent=;T;[[I" indent;T0;[[@i;T;: indent=;0;[;{;IC;"DSets the string that is used to indent levels in the JSON text. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"indent=(indent);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[I" indent;T0; @;[;I"`Sets the string that is used to indent levels in the JSON text. @overload indent=(indent);T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"&JSON::Ext::Generator::State#space;T;[;[[@i5;T;: space;0;[;{;IC;"[Returns the string that is used to insert a space between the tokens in a JSON string. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" space();T;IC;";T;[;[;I";T;0; @7;@F;Mi;N0;[; @7;[;I"oReturns the string that is used to insert a space between the tokens in a JSON string. @overload space();T;0; @7;@F;Ao;B;CT;Di/;Ei3;!@;"I"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; ; F; ;,;;;I"'JSON::Ext::Generator::State#space=;T;[[I" space;T0;[[@iA;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;H ;II" overload;F;J0;; ;K0;#I"space=(space);T;IC;";T;[;[;I";T;0; @M;@F;Mi;N0;[[I" space;T0; @M;[;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; @M;@F;Ao;B;CT;Di;;Ei?;!@;"I"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; ; F; ;,;;;I"-JSON::Ext::Generator::State#space_before;T;[;[[@iZ;T;:space_before;0;[;{;IC;"VReturns the string that is used to insert a space before the ':' in JSON objects. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"space_before();T;IC;";T;[;[;I";T;0; @g;@F;Mi;N0;[; @g;[;I"qReturns the string that is used to insert a space before the ':' in JSON objects. @overload space_before();T;0; @g;@F;Ao;B;CT;DiU;EiX;!@;"I"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; ; F; ;,;;;I".JSON::Ext::Generator::State#space_before=;T;[[I"space_before;T0;[[@ie;T;:space_before=;0;[;{;IC;"SSets the string that is used to insert a space before the ':' in JSON objects. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" space_before=(space_before);T;IC;";T;[;[;I";T;0; @};@F;Mi;N0;[[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;Ao;B;CT;Di`;Eic;!@;"I"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; ; F; ;,;;;I"*JSON::Ext::Generator::State#object_nl;T;[;[[@i;T;:object_nl;0;[;{;IC;"PThis string is put at the end of a line that holds a JSON object (or Hash). ;T;[o;H ;II" overload;F;J0;; ;K0;#I"object_nl();T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"hThis string is put at the end of a line that holds a JSON object (or Hash). @overload object_nl();T;0; @;@F;Ao;B;CT;Diy;Ei};!@;"I"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; ; F; ;,;;;I"+JSON::Ext::Generator::State#object_nl=;T;[[I"object_nl;T0;[[@i;T;:object_nl=;0;[;{;IC;"PThis string is put at the end of a line that holds a JSON object (or Hash). ;T;[o;H ;II" overload;F;J0;; ;K0;#I"object_nl=(object_nl);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I")JSON::Ext::Generator::State#array_nl;T;[;[[@i;T;: array_nl;0;[;{;IC;"EThis string is put at the end of a line that holds a JSON array. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"array_nl();T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;I"\This string is put at the end of a line that holds a JSON array. @overload array_nl();T;0; @;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"*JSON::Ext::Generator::State#array_nl=;T;[[I" array_nl;T0;[[@i;T;:array_nl=;0;[;{;IC;"EThis string is put at the end of a line that holds a JSON array. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"array_nl=(array_nl);T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I",JSON::Ext::Generator::State#max_nesting;T;[;[[@i;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;H ;II" overload;F;J0;; ;K0;#I"max_nesting;T;IC;";T;[;[;I";T;0; @;@F;Mi;N0;[; @;[;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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"-JSON::Ext::Generator::State#max_nesting=;T;[[I" depth;T0;[[@i;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;H ;II" overload;F;J0;; ;K0;#I"max_nesting=(depth);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"0JSON::Ext::Generator::State#check_circular?;T;[;[[@i;T;:check_circular?;0;[;{;IC;"ZReturns true, if circular data structures should be checked, otherwise returns false.;T;[o;H ;II" overload;F;J0;; ;K0;#I"check_circular?;T;IC;";T;[;[;I";T;0; @' ;@F;Mi;N0;[; @' o;L ;II" return;F;J@;0;K[@; @' ;[;I"vReturns true, if circular data structures should be checked, otherwise returns false. @overload check_circular?;T;0; @' ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"~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; ; F; ;,;;;I"+JSON::Ext::Generator::State#allow_nan?;T;[;[[@i;T;:allow_nan?;0;[;{;IC;"`Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.;T;[o;H ;II" overload;F;J0;; ;K0;#I"allow_nan?;T;IC;";T;[;[;I";T;0; @@ ;@F;Mi;N0;[; @@ o;L ;II" return;F;J@;0;K[@; @@ ;[;I"wReturns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false. @overload allow_nan?;T;0; @@ ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I",JSON::Ext::Generator::State#ascii_only?;T;[;[[@i;T;;;0;[;{;IC;"`Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.;T;[o;H ;II" overload;F;J0;;;K0;#I"ascii_only?;T;IC;";T;[;[;I";T;0; @Y ;@F;Mi;N0;[; @Y o;L ;II" return;F;J@;0;K[@; @Y ;[;I"xReturns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false. @overload ascii_only?;T;0; @Y ;@F;Ao;B;CT;Di;Ei;Mi;!@;"I"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; ; F; ;,;;;I"&JSON::Ext::Generator::State#depth;T;[;[[@i;T;: depth;0;[;{;IC;"FThis integer returns the current depth of data structure nesting. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" depth;T;IC;";T;[;[;I";T;0; @r ;@F;Mi;N0;[; @r ;[;I"XThis integer returns the current depth of data structure nesting. @overload depth;T;0; @r ;@F;Ao;B;CT;Di;Ei;!@;"I"fstatic VALUE cState_depth(VALUE self) { GET_STATE(self); return LONG2FIX(state->depth); };T;#I"*static VALUE cState_depth(VALUE self);T;$To; ; F; ;,;;;I"'JSON::Ext::Generator::State#depth=;T;[[I" depth;T0;[[@i;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;H ;II" overload;F;J0;; ;K0;#I"depth=(depth);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di ;Ei;!@;"I"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; ; F; ;,;;;I"6JSON::Ext::Generator::State#buffer_initial_length;T;[;[[@i;T;:buffer_initial_length;0;[;{;IC;"CThis integer returns the current initial length of the buffer. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"buffer_initial_length;T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[; @ ;[;I"eThis integer returns the current initial length of the buffer. @overload buffer_initial_length;T;0; @ ;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I"7JSON::Ext::Generator::State#buffer_initial_length=;T;[[I"buffer_initial_length;T0;[[@i);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;H ;II" overload;F;J0;; ;K0;#I"#buffer_initial_length=(length);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[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;Ao;B;CT;Di#;Ei';!@;"I"[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; ; F; ;,;;;I"*JSON::Ext::Generator::State#configure;T;[[I" opts;T0;[[@i2;T;:configure;0;[;{;IC;"KConfigure this State instance with the Hash _opts_, and return itself. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"configure(opts);T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[[I" opts;T0; @ ;[;I"gConfigure this State instance with the Hash _opts_, and return itself. @overload configure(opts);T;0; o; ; F; ;,;;;I"&JSON::Ext::Generator::State#merge;T;[;[[@i];F;;;;0;[;{;@ ;!@;"I"O 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); return self; };T;#I":static VALUE cState_configure(VALUE self, VALUE opts);T;@F;Ao;B;CT;Di,;Ei0;!@;"I"O 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); return self; };T;#@ ;$T@ o; ; F; ;,;;;I"%JSON::Ext::Generator::State#to_h;T;[;[[@i;T;;;0;[;{;IC;"hReturns the configuration instance variables as a hash, that can be passed to the configure method. ;T;[o;H ;II" overload;F;J0;;;K0;#I" to_h;T;IC;";T;[;[;I";T;0; @ ;@F;Mi;N0;[; @ ;[;I"yReturns the configuration instance variables as a hash, that can be passed to the configure method. @overload to_h;T;0; o; ; F; ;,;;;I"(JSON::Ext::Generator::State#to_hash;T;[;[[@i_;F;;;;0;[;{;@ ;!@;"I"static 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_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;Ao;B;CT;Di;Ei;!@;"I"static 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_depth), LONG2FIX(state->depth)); rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length)); return result; };T;#@!;$T@!o; ; F; ;,;;;I"#JSON::Ext::Generator::State#[];T;[[I" name;T0;[[@i;T;;;0;[;{;IC;"1Returns the value returned by method +name+. ;T;[o;H ;II" overload;F;J0;;;K0;#I" [](name);T;IC;";T;[;[;I";T;0; @!;@F;Mi;N0;[[I" name;T0; @!;[;I"FReturns the value returned by method +name+. @overload [](name);T;0; @!;@F;Ao;B;CT;Di;Ei;!@;"I"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_ivar_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name))); } };T;#I"5static VALUE cState_aref(VALUE self, VALUE name);T;$To; ; F; ;,;;;I"$JSON::Ext::Generator::State#[]=;T;[[I" name;T0[I" value;T0;[[@i;T;;+;0;[;{;IC;"&Sets the attribute name to value. ;T;[o;H ;II" overload;F;J0;;+;K0;#I"[]=(name, value);T;IC;";T;[;[;I";T;0; @,!;@F;Mi;N0;[[I" name;T0[I" value;T0; @,!;[;I"CSets the attribute name to value. @overload []=(name, value);T;0; @,!;@F;Ao;B;CT;Di;Ei;!@;"I"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; ; F; ;,;;;I")JSON::Ext::Generator::State#generate;T;[[I"obj;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"generate(obj);T;IC;";T;[;[;I";T;0; @J!;@F;Mi;N0;[[I"obj;T0; @J!;[;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; @J!;@F;Ao;B;CT;Di;Ei;!@;"I"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;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@ ; @!;;.[;[[@iD;F;: State;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I" JSON::Ext::Generator::State;T;1@JSON::Ext::Generator::GeneratorMethods::TrueClass#to_json;T;[[@0;[[@i;T;; ;0;[;{;IC;",Returns a JSON string for true: 'true'. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"to_json(*);T;IC;";T;[;[;I";T;0; @=#;@F;Mi;N0;[[I"*;T0; @=#;[;I"CReturns a JSON string for true: 'true'. @overload to_json(*);T;0; @=#;@F;Ao;B;CT;Di;Ei;!@;#;"I"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;&@;#;'IC;[;&@;#;(IC;[;&@;#;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i};F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @;#;Mi;!@s!;I"6JSON::Ext::Generator::GeneratorMethods::TrueClass;To; ;IC;[o; ; F; ;,;;;I"?JSON::Ext::Generator::GeneratorMethods::FalseClass#to_json;T;[[@0;[[@i;T;; ;0;[;{;IC;".Returns a JSON string for false: 'false'. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"to_json(*);T;IC;";T;[;[;I";T;0; @g#;@F;Mi;N0;[[I"*;T0; @g#;[;I"EReturns a JSON string for false: 'false'. @overload to_json(*);T;0; @g#;@F;Ao;B;CT;Di;Ei;!@e#;"I"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;&@e#;'IC;[;&@e#;(IC;[;&@e#;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @e#;Mi;!@s!;I"7JSON::Ext::Generator::GeneratorMethods::FalseClass;To; ;IC;[o; ; F; ;,;;;I"=JSON::Ext::Generator::GeneratorMethods::NilClass#to_json;T;[[@0;[[@i;T;; ;0;[;{;IC;"+Returns a JSON string for nil: 'null'. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"to_json(*);T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[[I"*;T0; @#;[;I"BReturns a JSON string for nil: 'null'. @overload to_json(*);T;0; @#;@F;Ao;B;CT;Di;Ei;!@#;"I"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;-{;.[;[[@i;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @#;Mi;!@s!;I"5JSON::Ext::Generator::GeneratorMethods::NilClass;T;&@s!;'IC;[;&@s!;(IC;[;&@s!;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@id;F;:GeneratorMethods;;0;;;[;{;IC;" ;T;[;[;@;0; @s!;!@;I"+JSON::Ext::Generator::GeneratorMethods;T;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i;[@i?;T;;;;0;;;[;{;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; @;@F;Ao;B;CT;Di;;EiC;!o;2 ;3@;4I"JSON::Ext;T;50;:Ext;!@;7@;F0;I"JSON::Ext::Generator;To; ;IC;[o; ; F; ;,;;;I"!JSON::Ext::Parser#initialize;T;[[@0;[[I"ext/json/parser/parser.c;Ti;T;;;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;H ;II" overload;F;J0;; ;K0;#I"new(source, opts;T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;!@#;"I"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_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; ; F; ;,;;;I"JSON::Ext::Parser#parse;T;[;[[@#iN;T;;;0;[;{;IC;"`Parses the current JSON text _source_ and returns the complete data structure as a result. ;T;[o;H ;II" overload;F;J0;;;K0;#I" parse();T;IC;";T;[;[;I";T;0; @#;@F;Mi;N0;[; @#;[;I"u Parses the current JSON text _source_ and returns the complete data structure as a result. @overload parse();T;0; @#;@F;Ao;B;CT;DiH;EiL;!@#;"I"a static VALUE cParser_parse(VALUE self) { char *p, *pe; int cs = EVIL; VALUE result = Qnil; GET_PARSER; #line 1861 "parser.c" { cs = JSON_start; } #line 760 "parser.rl" p = json->source; pe = p + json->len; #line 1870 "parser.c" { if ( p == pe ) goto _test_eof; switch ( cs ) { st1: if ( ++p == pe ) goto _test_eof1; case 1: switch( (*p) ) { case 13: goto st1; case 32: goto st1; case 34: goto tr2; case 45: goto tr2; case 47: goto st6; case 73: goto tr2; case 78: goto tr2; case 91: goto tr2; case 102: goto tr2; case 110: goto tr2; case 116: goto tr2; case 123: goto tr2; } if ( (*p) > 10 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr2; } else if ( (*p) >= 9 ) goto st1; goto st0; st0: cs = 0; goto _out; tr2: #line 736 "parser.rl" { char *np = JSON_parse_value(json, p, pe, &result, 0); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} } goto st10; st10: if ( ++p == pe ) goto _test_eof10; case 10: #line 1914 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; case 47: goto st2; } if ( 9 <= (*p) && (*p) <= 10 ) goto st10; goto st0; st2: if ( ++p == pe ) goto _test_eof2; case 2: switch( (*p) ) { case 42: goto st3; case 47: goto st5; } goto st0; st3: if ( ++p == pe ) goto _test_eof3; case 3: if ( (*p) == 42 ) goto st4; goto st3; st4: if ( ++p == pe ) goto _test_eof4; case 4: switch( (*p) ) { case 42: goto st4; case 47: goto st10; } goto st3; st5: if ( ++p == pe ) goto _test_eof5; case 5: if ( (*p) == 10 ) goto st10; goto st5; st6: if ( ++p == pe ) goto _test_eof6; case 6: switch( (*p) ) { case 42: goto st7; case 47: goto st9; } goto st0; st7: if ( ++p == pe ) goto _test_eof7; case 7: if ( (*p) == 42 ) goto st8; goto st7; st8: if ( ++p == pe ) goto _test_eof8; case 8: switch( (*p) ) { case 42: goto st8; case 47: goto st1; } goto st7; st9: if ( ++p == pe ) goto _test_eof9; case 9: if ( (*p) == 10 ) goto st1; goto st9; } _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 763 "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; ; F; ;,;;;I"JSON::Ext::Parser#source;T;[;[[@#i;T;;;0;[;{;IC;"[Returns a copy of the current _source_ string, that was used to construct this Parser. ;T;[o;H ;II" overload;F;J0;;;K0;#I" source();T;IC;";T;[;[;I";T;0; @$;@F;Mi;N0;[; @$;[;I"pReturns a copy of the current _source_ string, that was used to construct this Parser. @overload source();T;0; @$;@F;Ao;B;CT;Di;Ei;!@#;"I"fstatic 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;; ;;0;;;[;{;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;Ao;B;CT;Di;Ei;Mi;!o;2 ;3@;4I"JSON::Ext;T;50;; ;!@;7@;F0;I"JSON::Ext::Parser;T;1@<;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i>[@#i*;F;; ;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!@;I"JSON::Ext;F;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@i=[@#i);F;: JSON;;0;;;[;{;IC;" ;T;[;[;@;0; @;!@;I" JSON;Fo; ;IC;[o; ; F; ;;;;I" GC.start;F;[[@0;[[@i;T;;;0;[;{;IC;"Initiates garbage collection, unless manually disabled. This method is defined with keyword arguments that default to true: def GC.start(full_mark: true, immediate_sweep: true); end Use full_mark: false to perform a minor GC. Use immediate_sweep: false to defer sweeping (use lazy sweep). Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" start;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @\$;[;I"@return [nil];T;0; @\$;@F;Mi;N0;[; @\$o;H ;II" overload;F;J0;;x;K0;#I"garbage_collect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @\$;[;I"@return [nil];T;0; @\$;@F;Mi;N0;[; @\$o;H ;II" overload;F;J0;;y;K0;#I"GC;(garbage_collect);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @\$;[;I"@return [nil];T;0; @\$;@F;Mi;N0;[; @\$o;H ;II" overload;F;J0;;;K0;#I"2start(full_mark: true, immediate_sweep: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @\$;[;I"@return [nil];T;0; @\$;@F;Mi;N0;[[I"full_mark:;TI" true;T[I"immediate_sweep:;TI" true;T; @\$o;H ;II" overload;F;J0;;x;K0;#I" false GC.enable #=> true GC.enable #=> false ;T;[o;H ;II" overload;F;J0;; ;K0;#I" enable;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$;[;I"@return [Boolean];T;0; @$;@F;Mi;N0;[; @$;[;I"Enables garbage collection, returning +true+ if garbage collection was previously disabled. GC.disable #=> false GC.enable #=> true GC.enable #=> false @overload enable @return [Boolean];T;0; @$;@F;Ao;B;CT;Dij;Eit;!@Z$;"I"VALUE rb_gc_enable(void) { rb_objspace_t *objspace = &rb_objspace; int old = dont_gc; dont_gc = FALSE; return old ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;;;;I"GC.disable;F;[;[[@i;T;;;0;[;{;IC;"Disables garbage collection, returning +true+ if garbage collection was already disabled. GC.disable #=> false GC.disable #=> true ;T;[o;H ;II" overload;F;J0;;;K0;#I" disable;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$;[;I"@return [Boolean];T;0; @$;@F;Mi;N0;[; @$;[;I"Disables garbage collection, returning +true+ if garbage collection was already disabled. GC.disable #=> false GC.disable #=> true @overload disable @return [Boolean];T;0; @$;@F;Ao;B;CT;Di;Ei;!@Z$;"I"VALUE rb_gc_disable(void) { rb_objspace_t *objspace = &rb_objspace; int old = dont_gc; gc_rest(objspace); dont_gc = TRUE; return old ? Qtrue : Qfalse; };T;#I" VALUE;T;$To; ; F; ;;;;I"GC.stress;F;[;[[@iC;T;: stress;0;[;{;IC;".Returns current status of GC stress mode. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" stress;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @$;[;I"@return [Boolean];T;0; @$;@F;Mi;N0;[; @$;[;I"UReturns current status of GC stress mode. @overload stress @return [Boolean];T;0; @$;@F;Ao;B;CT;Di<;Ei@;!@Z$;"I"{static VALUE gc_stress_get(VALUE self) { rb_objspace_t *objspace = &rb_objspace; return ruby_gc_stress_mode; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC.stress=;F;[[I" flag;T0;[[@ib;T;: stress=;0;[;{;IC;"sUpdates the GC stress mode. When stress mode is enabled, the GC is invoked at every GC opportunity: all memory and object allocations. Enabling stress mode will degrade performance, it is only for debugging. flag can be true, false, or an integer bit-ORed following flags. 0x01:: no major GC 0x02:: no immediate sweep 0x04:: full mark after malloc/calloc/realloc ;T;[o;H ;II" overload;F;J0;; ;K0;#I"stress=(flag);T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[[I" flag;T0; @%;[;I"Updates the GC stress mode. When stress mode is enabled, the GC is invoked at every GC opportunity: all memory and object allocations. Enabling stress mode will degrade performance, it is only for debugging. flag can be true, false, or an integer bit-ORed following flags. 0x01:: no major GC 0x02:: no immediate sweep 0x04:: full mark after malloc/calloc/realloc @overload stress=(flag);T;0; @%;@F;Ao;B;CT;DiQ;Ei^;!@Z$;"I"static VALUE gc_stress_set_m(VALUE self, VALUE flag) { rb_objspace_t *objspace = &rb_objspace; gc_stress_set(objspace, flag); return flag; };T;#I"static VALUE;T;$To; ; F; ;;;;I" GC.count;F;[;[[@i.;T;;r;0;[;{;IC;"lThe number of times GC occurred. It returns the number of times GC occurred since the process started. ;T;[o;H ;II" overload;F;J0;;r;K0;#I" count;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @/%;[;I"@return [Integer];T;0; @/%;@F;Mi;N0;[; @/%;[;I"The number of times GC occurred. It returns the number of times GC occurred since the process started. @overload count @return [Integer];T;0; @/%;@F;Ao;B;CT;Di$;Ei+;!@Z$;"I"Ostatic VALUE gc_count(VALUE self) { return SIZET2NUM(rb_gc_count()); };T;#I"static VALUE;T;$To; ; F; ;;;;I" GC.stat;F;[[@0;[[@i;T;;3;0;[;{;IC;"Returns a Hash containing information about the GC. The hash includes information about internal statistics about GC such as: { :count=>0, :heap_allocated_pages=>24, :heap_sorted_length=>24, :heap_allocatable_pages=>0, :heap_available_slots=>9783, :heap_live_slots=>7713, :heap_free_slots=>2070, :heap_final_slots=>0, :heap_marked_slots=>0, :heap_eden_pages=>24, :heap_tomb_pages=>0, :total_allocated_pages=>24, :total_freed_pages=>0, :total_allocated_objects=>7796, :total_freed_objects=>83, :malloc_increase_bytes=>2389312, :malloc_increase_bytes_limit=>16777216, :minor_gc_count=>0, :major_gc_count=>0, :remembered_wb_unprotected_objects=>0, :remembered_wb_unprotected_objects_limit=>0, :old_objects=>0, :old_objects_limit=>0, :oldmalloc_increase_bytes=>2389760, :oldmalloc_increase_bytes_limit=>16777216 } 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;H ;II" overload;F;J0;;3;K0;#I" stat;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @J%;[;I"@return [Hash];T;0; @J%;@F;Mi;N0;[; @J%o;H ;II" overload;F;J0;;3;K0;#I"stat(hash);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @J%;[;I"@return [Hash];T;0; @J%;@F;Mi;N0;[[I" hash;T0; @J%o;H ;II" overload;F;J0;;3;K0;#I"stat(:key);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Numeric;T; @J%;[;I"@return [Numeric];T;0; @J%;@F;Mi;N0;[[I":;TI"key;T; @J%;[;I"Returns a Hash containing information about the GC. The hash includes information about internal statistics about GC such as: { :count=>0, :heap_allocated_pages=>24, :heap_sorted_length=>24, :heap_allocatable_pages=>0, :heap_available_slots=>9783, :heap_live_slots=>7713, :heap_free_slots=>2070, :heap_final_slots=>0, :heap_marked_slots=>0, :heap_eden_pages=>24, :heap_tomb_pages=>0, :total_allocated_pages=>24, :total_freed_pages=>0, :total_allocated_objects=>7796, :total_freed_objects=>83, :malloc_increase_bytes=>2389312, :malloc_increase_bytes_limit=>16777216, :minor_gc_count=>0, :major_gc_count=>0, :remembered_wb_unprotected_objects=>0, :remembered_wb_unprotected_objects_limit=>0, :old_objects=>0, :old_objects_limit=>0, :oldmalloc_increase_bytes=>2389760, :oldmalloc_increase_bytes_limit=>16777216 } 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(hash) @return [Hash] @overload stat(:key) @return [Numeric];T;0; @J%;@F;Ao;B;CT;Di;Ei;!@Z$;"I"static VALUE gc_stat(int argc, VALUE *argv, VALUE self) { VALUE arg = Qnil; if (rb_check_arity(argc, 0, 1) == 1) { arg = argv[0]; if (SYMBOL_P(arg)) { size_t value = gc_stat_internal(arg); return SIZET2NUM(value); } else if (!RB_TYPE_P(arg, T_HASH)) { rb_raise(rb_eTypeError, "non-hash or symbol given"); } } else { arg = rb_hash_new(); } gc_stat_internal(arg); return arg; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC.latest_gc_info;F;[[@0;[[@i;T;:latest_gc_info;0;[;{;IC;"BReturns information about the most recent garbage collection. ;T;[o;H ;II" overload;F;J0;; ;K0;#I"latest_gc_info;T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;; ;K0;#I"latest_gc_info(hash);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Hash;T; @%;[;I"@return [Hash];T;0; @%;@F;Mi;N0;[[I" hash;T0; @%o;H ;II" overload;F;J0;; ;K0;#I"latest_gc_info(:major_by);T;IC;";T;[;[;I";T;0; @%;@F;Mi;N0;[[I":;TI" major_by;T; @%;[;I"Returns information about the most recent garbage collection. @overload latest_gc_info @overload latest_gc_info(hash) @return [Hash] @overload latest_gc_info(:major_by);T;0; @%;@F;Ao;B;CT;Di;Ei;!@Z$;"I"static VALUE gc_latest_gc_info(int argc, VALUE *argv, VALUE self) { rb_objspace_t *objspace = &rb_objspace; VALUE arg = Qnil; if (rb_check_arity(argc, 0, 1) == 1) { arg = argv[0]; if (!SYMBOL_P(arg) && !RB_TYPE_P(arg, T_HASH)) { rb_raise(rb_eTypeError, "non-hash or symbol given"); } } else { arg = rb_hash_new(); } return gc_info_decode(objspace, arg, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"GC#garbage_collect;F;[[@0;[[@i;T;;x;0;[;{;IC;"Initiates garbage collection, unless manually disabled. This method is defined with keyword arguments that default to true: def GC.start(full_mark: true, immediate_sweep: true); end Use full_mark: false to perform a minor GC. Use immediate_sweep: false to defer sweeping (use lazy sweep). Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them. ;T;[ o;H ;II" overload;F;J0;;;K0;#I" start;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @%;[;I"@return [nil];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;;x;K0;#I"garbage_collect;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @%;[;I"@return [nil];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;;y;K0;#I"GC;(garbage_collect);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @%;[;I"@return [nil];T;0; @%;@F;Mi;N0;[; @%o;H ;II" overload;F;J0;;;K0;#I"2start(full_mark: true, immediate_sweep: true);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @%;[;I"@return [nil];T;0; @%;@F;Mi;N0;[[I"full_mark:;TI" true;T[I"immediate_sweep:;TI" true;T; @%o;H ;II" overload;F;J0;;x;K0;#I" true or false;T;IC;";T;[;[;I";T;0; @,&;@F;Mi;N0;[[I" ->true;T0; @,&o;L ;II" return;F;J@;0;K[@; @,&;[;I"^The current status of GC profile mode. @overload GC::Profiler.enabled? -> true or false;T;0; @,&;@F;Ao;B;CT;Di%;Ei%;Mi;!@*&;"I"static VALUE gc_profile_enable_get(VALUE self) { rb_objspace_t *objspace = &rb_objspace; return objspace->profile.run ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC::Profiler.enable;F;[;[[@i%%;T;; ;0;[;{;IC;"Starts the GC profiler. ;T;[o;H ;II" overload;F;J0;:GC::Profiler.enable;K0;#I"GC::Profiler.enable -> nil;T;IC;";T;[;[;I";T;0; @G&;@F;Mi;N0;[[I" ->nil;T0; @G&;[;I"DStarts the GC profiler. @overload GC::Profiler.enable -> nil;T;0; @G&;@F;Ao;B;CT;Di%;Ei!%;!@*&;"I"static VALUE gc_profile_enable(void) { rb_objspace_t *objspace = &rb_objspace; objspace->profile.run = TRUE; objspace->profile.current_record = 0; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC::Profiler.raw_data;F;[;[[@i $;T;: raw_data;0;[;{;IC;"Returns an Array of individual raw profile data Hashes ordered from earliest to latest by +:GC_INVOKE_TIME+. For example: [ { :GC_TIME=>1.3000000000000858e-05, :GC_INVOKE_TIME=>0.010634999999999999, :HEAP_USE_SIZE=>289640, :HEAP_TOTAL_SIZE=>588960, :HEAP_TOTAL_OBJECTS=>14724, :GC_IS_MARKED=>false }, # ... ] The keys mean: +:GC_TIME+:: Time elapsed in seconds for this GC run +:GC_INVOKE_TIME+:: Time elapsed in seconds from startup to when the GC was invoked +:HEAP_USE_SIZE+:: Total bytes of heap used +:HEAP_TOTAL_SIZE+:: Total size of heap in bytes +:HEAP_TOTAL_OBJECTS+:: Total number of objects +:GC_IS_MARKED+:: Returns +true+ if the GC is in mark phase If ruby was built with +GC_PROFILE_MORE_DETAIL+, you will also have access to the following hash keys: +:GC_MARK_TIME+:: +:GC_SWEEP_TIME+:: +:ALLOCATE_INCREASE+:: +:ALLOCATE_LIMIT+:: +:HEAP_USE_PAGES+:: +:HEAP_LIVE_OBJECTS+:: +:HEAP_FREE_OBJECTS+:: +:HAVE_FINALIZE+:: ;T;[o;H ;II" overload;F;J0;:GC::Profiler.raw_data;K0;#I")GC::Profiler.raw_data -> [Hash, ...];T;IC;";T;[;[;I";T;0; @_&;@F;Mi;N0;[[I"->[Hash, ...];T0; @_&;[;I"Returns an Array of individual raw profile data Hashes ordered from earliest to latest by +:GC_INVOKE_TIME+. For example: [ { :GC_TIME=>1.3000000000000858e-05, :GC_INVOKE_TIME=>0.010634999999999999, :HEAP_USE_SIZE=>289640, :HEAP_TOTAL_SIZE=>588960, :HEAP_TOTAL_OBJECTS=>14724, :GC_IS_MARKED=>false }, # ... ] The keys mean: +:GC_TIME+:: Time elapsed in seconds for this GC run +:GC_INVOKE_TIME+:: Time elapsed in seconds from startup to when the GC was invoked +:HEAP_USE_SIZE+:: Total bytes of heap used +:HEAP_TOTAL_SIZE+:: Total size of heap in bytes +:HEAP_TOTAL_OBJECTS+:: Total number of objects +:GC_IS_MARKED+:: Returns +true+ if the GC is in mark phase If ruby was built with +GC_PROFILE_MORE_DETAIL+, you will also have access to the following hash keys: +:GC_MARK_TIME+:: +:GC_SWEEP_TIME+:: +:ALLOCATE_INCREASE+:: +:ALLOCATE_LIMIT+:: +:HEAP_USE_PAGES+:: +:HEAP_LIVE_OBJECTS+:: +:HEAP_FREE_OBJECTS+:: +:HAVE_FINALIZE+:: @overload GC::Profiler.raw_data -> [Hash, ...];T;0; @_&;@F;Ao;B;CT;Di#;Ei$;!@*&;"I" static VALUE gc_profile_record_get(void) { VALUE prof; VALUE gc_profile = rb_ary_new(); size_t i; rb_objspace_t *objspace = (&rb_objspace); if (!objspace->profile.run) { return Qnil; } for (i =0; i < objspace->profile.next_index; i++) { gc_profile_record *record = &objspace->profile.records[i]; prof = rb_hash_new(); rb_hash_aset(prof, ID2SYM(rb_intern("GC_FLAGS")), gc_info_decode(0, rb_hash_new(), record->flags)); rb_hash_aset(prof, ID2SYM(rb_intern("GC_TIME")), DBL2NUM(record->gc_time)); rb_hash_aset(prof, ID2SYM(rb_intern("GC_INVOKE_TIME")), DBL2NUM(record->gc_invoke_time)); rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_SIZE")), SIZET2NUM(record->heap_use_size)); rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_TOTAL_SIZE")), SIZET2NUM(record->heap_total_size)); rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_TOTAL_OBJECTS")), SIZET2NUM(record->heap_total_objects)); rb_hash_aset(prof, ID2SYM(rb_intern("GC_IS_MARKED")), Qtrue); #if GC_PROFILE_MORE_DETAIL rb_hash_aset(prof, ID2SYM(rb_intern("GC_MARK_TIME")), DBL2NUM(record->gc_mark_time)); rb_hash_aset(prof, ID2SYM(rb_intern("GC_SWEEP_TIME")), DBL2NUM(record->gc_sweep_time)); rb_hash_aset(prof, ID2SYM(rb_intern("ALLOCATE_INCREASE")), SIZET2NUM(record->allocate_increase)); rb_hash_aset(prof, ID2SYM(rb_intern("ALLOCATE_LIMIT")), SIZET2NUM(record->allocate_limit)); rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_PAGES")), SIZET2NUM(record->heap_use_pages)); rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_LIVE_OBJECTS")), SIZET2NUM(record->heap_live_objects)); rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_FREE_OBJECTS")), SIZET2NUM(record->heap_free_objects)); rb_hash_aset(prof, ID2SYM(rb_intern("REMOVING_OBJECTS")), SIZET2NUM(record->removing_objects)); rb_hash_aset(prof, ID2SYM(rb_intern("EMPTY_OBJECTS")), SIZET2NUM(record->empty_objects)); rb_hash_aset(prof, ID2SYM(rb_intern("HAVE_FINALIZE")), (record->flags & GPR_FLAG_HAVE_FINALIZE) ? Qtrue : Qfalse); #endif #if RGENGC_PROFILE > 0 rb_hash_aset(prof, ID2SYM(rb_intern("OLD_OBJECTS")), SIZET2NUM(record->old_objects)); rb_hash_aset(prof, ID2SYM(rb_intern("REMEMBERED_NORMAL_OBJECTS")), SIZET2NUM(record->remembered_normal_objects)); rb_hash_aset(prof, ID2SYM(rb_intern("REMEMBERED_SHADY_OBJECTS")), SIZET2NUM(record->remembered_shady_objects)); #endif rb_ary_push(gc_profile, prof); } return gc_profile; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC::Profiler.disable;F;[;[[@i6%;T;;;0;[;{;IC;"Stops the GC profiler. ;T;[o;H ;II" overload;F;J0;:GC::Profiler.disable;K0;#I" GC::Profiler.disable -> nil;T;IC;";T;[;[;I";T;0; @w&;@F;Mi;N0;[[I" ->nil;T0; @w&;[;I"DStops the GC profiler. @overload GC::Profiler.disable -> nil;T;0; @w&;@F;Ao;B;CT;Di.%;Ei2%;!@*&;"I"static VALUE gc_profile_disable(void) { rb_objspace_t *objspace = &rb_objspace; objspace->profile.run = FALSE; objspace->profile.current_record = 0; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC::Profiler.clear;F;[;[[@i#;T;;3;0;[;{;IC;"!Clears the GC profiler data. ;T;[o;H ;II" overload;F;J0;:GC::Profiler.clear;K0;#I"GC::Profiler.clear;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @&;[;I"@return [nil];T;0; @&;@F;Mi;N0;[; @&;[;I"QClears the GC profiler data. @overload GC::Profiler.clear @return [nil];T;0; @&;@F;Ao;B;CT;Di#;Ei#;!@*&;"I"dstatic VALUE gc_profile_clear(void) { rb_objspace_t *objspace = &rb_objspace; if (GC_PROFILE_RECORD_DEFAULT_SIZE * 2 < objspace->profile.size) { objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE * 2; objspace->profile.records = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size); if (!objspace->profile.records) { rb_memerror(); } } MEMZERO(objspace->profile.records, gc_profile_record, objspace->profile.size); objspace->profile.next_index = 0; objspace->profile.current_record = 0; return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC::Profiler.result;F;[;[[@i$;T;;;0;[;{;IC;"+Returns a profile data report such as: GC 1 invokes. Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms) 1 0.012 159240 212940 10647 0.00000000000001530000 ;T;[o;H ;II" overload;F;J0;:GC::Profiler.result;K0;#I"GC::Profiler.result;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @&;[;I"@return [String];T;0; @&;@F;Mi;N0;[; @&;[;I"^Returns a profile data report such as: GC 1 invokes. Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms) 1 0.012 159240 212940 10647 0.00000000000001530000 @overload GC::Profiler.result @return [String];T;0; @&;@F;Ao;B;CT;Di$;Ei$;!@*&;"I"static VALUE gc_profile_result(void) { VALUE str = rb_str_buf_new(0); gc_profile_dump_on(str, rb_str_buf_append); return str; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC::Profiler.report;F;[[@0;[[@i$;T;: report;0;[;{;IC;"OWrites the GC::Profiler.result to $stdout or the given IO object. ;T;[o;H ;II" overload;F;J0;:GC::Profiler.report;K0;#I"GC::Profiler.report;T;IC;";T;[;[;I";T;0; @&;@F;Mi;N0;[; @&o;H ;II" overload;F;J0;; ;K0;#I"GC::Profiler.report(io);T;IC;";T;[;[;I";T;0; @&;@F;Mi;N0;[[I"io;T0; @&;[;I"Writes the GC::Profiler.result to $stdout or the given IO object. @overload GC::Profiler.report @overload GC::Profiler.report(io);T;0; @&;@F;Ao;B;CT;Di$;Ei$;!@*&;"I"static VALUE gc_profile_report(int argc, VALUE *argv, VALUE self) { VALUE out; out = (!rb_check_arity(argc, 0, 1) ? rb_stdout : argv[0]); gc_profile_dump_on(out, rb_io_write); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC::Profiler.total_time;F;[;[[@i$;T;:total_time;0;[;{;IC;":The total time used for garbage collection in seconds ;T;[o;H ;II" overload;F;J0;:GC::Profiler.total_time;K0;#I"%GC::Profiler.total_time -> float;T;IC;";T;[;[;I";T;0; @&;@F;Mi;N0;[[I" ->float;T0; @&;[;I"gThe total time used for garbage collection in seconds @overload GC::Profiler.total_time -> float;T;0; @&;@F;Ao;B;CT;Di$;Ei$;!@*&;"I"hstatic VALUE gc_profile_total_time(VALUE self) { double time = 0; rb_objspace_t *objspace = &rb_objspace; if (objspace->profile.run && objspace->profile.next_index > 0) { size_t i; size_t count = objspace->profile.next_index; for (i = 0; i < count; i++) { time += objspace->profile.records[i].gc_time; } } return DBL2NUM(time); };T;#I"static VALUE;T;$T;&@*&;'IC;[;&@*&;(IC;[;&@*&;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@iE';F;: Profiler;;0;;;[;{;IC;" ;T;[;[;@;0; @*&;Mi;!@Z$;I"GC::Profiler;Fo; ; F; ;;;;I"#GC.verify_internal_consistency;F;[;[[@iN;T;: verify_internal_consistency;0;[;{;IC;"Verify internal consistency. This method is implementation specific. Now this method checks generational consistency if RGenGC is supported. ;T;[o;H ;II" overload;F;J0;; ;K0;#I" verify_internal_consistency;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @ ';[;I"@return [nil];T;0; @ ';@F;Mi;N0;[; @ ';[;I"Verify internal consistency. This method is implementation specific. Now this method checks generational consistency if RGenGC is supported. @overload verify_internal_consistency @return [nil];T;0; @ ';@F;Ao;B;CT;DiD;EiL;!@Z$;"I"i static VALUE gc_verify_internal_consistency(VALUE dummy) { rb_objspace_t *objspace = &rb_objspace; struct verify_internal_consistency_struct data = {0}; struct each_obj_args eo_args; data.objspace = objspace; gc_report(5, objspace, "gc_verify_internal_consistency: start\n"); /* check relations */ eo_args.callback = verify_internal_consistency_i; eo_args.data = (void *)&data; objspace_each_objects((VALUE)&eo_args); if (data.err_count != 0) { #if RGENGC_CHECK_MODE >= 5 objspace->rgengc.error_count = data.err_count; gc_marks_check(objspace, NULL, NULL); allrefs_dump(objspace); #endif rb_bug("gc_verify_internal_consistency: found internal inconsistency."); } /* check heap_page status */ gc_verify_heap_pages(objspace); /* check counters */ if (!is_lazy_sweeping(heap_eden) && !finalizing) { if (objspace_live_slots(objspace) != data.live_object_count) { fprintf(stderr, "heap_pages_final_slots: %d, objspace->profile.total_freed_objects: %d\n", (int)heap_pages_final_slots, (int)objspace->profile.total_freed_objects); rb_bug("inconsistent live slot number: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace_live_slots(objspace), data.live_object_count); } } #if USE_RGENGC if (!is_marking(objspace)) { if (objspace->rgengc.old_objects != data.old_object_count) { rb_bug("inconsistent old slot number: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.old_objects, data.old_object_count); } if (objspace->rgengc.uncollectible_wb_unprotected_objects != data.remembered_shady_count) { rb_bug("inconsistent old slot number: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.uncollectible_wb_unprotected_objects, data.remembered_shady_count); } } #endif if (!finalizing) { size_t list_count = 0; { VALUE z = heap_pages_deferred_final; while (z) { list_count++; z = RZOMBIE(z)->next; } } if (heap_pages_final_slots != data.zombie_object_count || heap_pages_final_slots != list_count) { rb_bug("inconsistent finalizing object count:\n" " expect %"PRIuSIZE"\n" " but %"PRIuSIZE" zombies\n" " heap_pages_deferred_final list has %"PRIuSIZE" items.", heap_pages_final_slots, data.zombie_object_count, list_count); } } gc_report(5, objspace, "gc_verify_internal_consistency: OK\n"); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"2GC.verify_transient_heap_internal_consistency;F;[;[[@i;T;:/verify_transient_heap_internal_consistency;0;[;{;IC;" ;T;[;[;@;0; @(';!@Z$;"I"static VALUE gc_verify_transient_heap_internal_consistency(VALUE dmy) { rb_transient_heap_verify(); return Qnil; };T;#I"static VALUE;T;$To; ; F; ;;;;I"GC.malloc_allocated_size;F;[;[[@iproduces: 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;Ao;B;CT;Di;Ei;!o;2 ;30;40;50;: Math;!@;7@';F0;I"Math::DomainError;T;1@7o;9;[[@'i;F;:PI;;;;;;[;{;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; @';@F;Ao;B;CT;Di;Ei;!@';I" Math::PI;F; -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;H ;II" overload;F;J0;; ;K0;#I"atan2(y, x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @';[;I"@return [Float];T;0; @';@F;Mi;N0;[[I"y;T0[I"x;T0; @';[;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; @';@F;N0;!@';"I"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; ; T; ;;;;I"Math.atan2;F;@';@';T;; ;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;H ;II" overload;F;J0;; ;K0;#I"atan2(y, x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @(;[;I"@return [Float];T;0; @(;@F;Mi;N0;[[I"y;T0[I"x;T0; @(;[;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; @(;@F;Ao;B;CT;Di(;EiC;Mi;!@';"@(;#@(;$To; ; F; ;,;;;I" Math#cos;F;[[I"x;T0;[[@'is;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;H ;II" overload;F;J0;;! ;K0;#I" cos(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @!(;[;I"@return [Float];T;0; @!(;@F;Mi;N0;[[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;N0;!@';"I"astatic VALUE math_cos(VALUE unused_obj, VALUE x) { return DBL2NUM(cos(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I" Math.cos;F;@#(;@&(;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;H ;II" overload;F;J0;;! ;K0;#I" cos(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @?(;[;I"@return [Float];T;0; @?(;@F;Mi;N0;[[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;Ao;B;CT;Did;Eip;Mi;!@';"@=(;#@>(;$To; ; F; ;,;;;I" Math#sin;F;[[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;H ;II" overload;F;J0;;" ;K0;#I" sin(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @V(;[;I"@return [Float];T;0; @V(;@F;Mi;N0;[[I"x;T0; @V(;[;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; @V(;@F;N0;!@';"I"astatic VALUE math_sin(VALUE unused_obj, VALUE x) { return DBL2NUM(sin(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I" Math.sin;F;@X(;@[(;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;H ;II" overload;F;J0;;" ;K0;#I" sin(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @t(;[;I"@return [Float];T;0; @t(;@F;Mi;N0;[[I"x;T0; @t(;[;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; @t(;@F;Ao;B;CT;Diy;Ei;Mi;!@';"@r(;#@s(;$To; ; F; ;,;;;I" Math#tan;F;[[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;H ;II" overload;F;J0;;# ;K0;#I" tan(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @(;[;I"@return [Float];T;0; @(;@F;Mi;N0;[[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;N0;!@';"I"astatic VALUE math_tan(VALUE unused_obj, VALUE x) { return DBL2NUM(tan(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I" Math.tan;F;@(;@(;T;;# ;0;@(;{;IC;"Computes the tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.tan(0) #=> 0.0;T;[o;H ;II" overload;F;J0;;# ;K0;#I" tan(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @(;[;I"@return [Float];T;0; @(;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@(;#@(;$To; ; F; ;,;;;I"Math#acos;F;[[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;H ;II" overload;F;J0;;$ ;K0;#I" acos(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @(;[;I"@return [Float];T;0; @(;@F;Mi;N0;[[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;N0;!@';"I"static VALUE math_acos(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); /* check for domain error */ if (d < -1.0 || 1.0 < d) domain_error("acos"); return DBL2NUM(acos(d)); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.acos;F;@(;@(;T;;$ ;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;H ;II" overload;F;J0;;$ ;K0;#I" acos(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @(;[;I"@return [Float];T;0; @(;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@(;#@(;$To; ; F; ;,;;;I"Math#asin;F;[[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;H ;II" overload;F;J0;;% ;K0;#I" asin(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @(;[;I"@return [Float];T;0; @(;@F;Mi;N0;[[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;N0;!@';"I"static VALUE math_asin(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); /* check for domain error */ if (d < -1.0 || 1.0 < d) domain_error("asin"); return DBL2NUM(asin(d)); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.asin;F;@(;@(;T;;% ;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;H ;II" overload;F;J0;;% ;K0;#I" asin(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @);[;I"@return [Float];T;0; @);@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@);#@);$To; ; F; ;,;;;I"Math#atan;F;[[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;H ;II" overload;F;J0;;& ;K0;#I" atan(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @*);[;I"@return [Float];T;0; @*);@F;Mi;N0;[[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;N0;!@';"I"cstatic VALUE math_atan(VALUE unused_obj, VALUE x) { return DBL2NUM(atan(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.atan;F;@,);@/);T;;& ;0;@1);{;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;H ;II" overload;F;J0;;& ;K0;#I" atan(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @H);[;I"@return [Float];T;0; @H);@F;Mi;N0;[[I"x;T0; @H);[;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; @H);@F;Ao;B;CT;Di;Ei;Mi;!@';"@F);#@G);$To; ; F; ;,;;;I"Math#cosh;F;[[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;H ;II" overload;F;J0;;' ;K0;#I" cosh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @_);[;I"@return [Float];T;0; @_);@F;Mi;N0;[[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;N0;!@';"I"cstatic VALUE math_cosh(VALUE unused_obj, VALUE x) { return DBL2NUM(cosh(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.cosh;F;@a);@d);T;;' ;0;@f);{;IC;"Computes the hyperbolic cosine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: [1, INFINITY) Math.cosh(0) #=> 1.0;T;[o;H ;II" overload;F;J0;;' ;K0;#I" cosh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @});[;I"@return [Float];T;0; @});@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@{);#@|);$To; ; F; ;,;;;I"Math#sinh;F;[[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;H ;II" overload;F;J0;;( ;K0;#I" sinh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @);[;I"@return [Float];T;0; @);@F;Mi;N0;[[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;N0;!@';"I"cstatic VALUE math_sinh(VALUE unused_obj, VALUE x) { return DBL2NUM(sinh(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.sinh;F;@);@);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;H ;II" overload;F;J0;;( ;K0;#I" sinh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @);[;I"@return [Float];T;0; @);@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@);#@);$To; ; F; ;,;;;I"Math#tanh;F;[[I"x;T0;[[@'i7;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;H ;II" overload;F;J0;;) ;K0;#I" tanh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @);[;I"@return [Float];T;0; @);@F;Mi;N0;[[I"x;T0; @);[;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; @);@F;N0;!@';"I"cstatic VALUE math_tanh(VALUE unused_obj, VALUE x) { return DBL2NUM(tanh(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.tanh;F;@);@);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;H ;II" overload;F;J0;;) ;K0;#I" tanh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @);[;I"@return [Float];T;0; @);@F;Mi;N0;[[I"x;T0; @);[;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; @);@F;Ao;B;CT;Di);Ei4;Mi;!@';"@);#@);$To; ; F; ;,;;;I"Math#acosh;F;[[I"x;T0;[[@'iK;T;: acosh;0;[;{;IC;"|Computes the inverse hyperbolic cosine of +x+. Domain: [1, INFINITY) Codomain: [0, INFINITY) Math.acosh(1) #=> 0.0 ;T;[o;H ;II" overload;F;J0;;* ;K0;#I" acosh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @);[;I"@return [Float];T;0; @);@F;Mi;N0;[[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;N0;!@';"I"static VALUE math_acosh(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); /* check for domain error */ if (d < 1.0) domain_error("acosh"); return DBL2NUM(acosh(d)); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.acosh;F;@*;@*;T;;* ;0;@*;{;IC;"|Computes the inverse hyperbolic cosine of +x+. Domain: [1, INFINITY) Codomain: [0, INFINITY) Math.acosh(1) #=> 0.0;T;[o;H ;II" overload;F;J0;;* ;K0;#I" acosh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @*;[;I"@return [Float];T;0; @*;@F;Mi;N0;[[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;Ao;B;CT;Di=;EiH;Mi;!@';"@*;#@*;$To; ; F; ;,;;;I"Math#asinh;F;[[I"x;T0;[[@'id;T;: asinh;0;[;{;IC;"Computes the inverse hyperbolic sine of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.asinh(1) #=> 0.881373587019543 ;T;[o;H ;II" overload;F;J0;;+ ;K0;#I" asinh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @3*;[;I"@return [Float];T;0; @3*;@F;Mi;N0;[[I"x;T0; @3*;[;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; @3*;@F;N0;!@';"I"estatic VALUE math_asinh(VALUE unused_obj, VALUE x) { return DBL2NUM(asinh(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.asinh;F;@5*;@8*;T;;+ ;0;@:*;{;IC;"Computes the inverse hyperbolic sine of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.asinh(1) #=> 0.881373587019543;T;[o;H ;II" overload;F;J0;;+ ;K0;#I" asinh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @Q*;[;I"@return [Float];T;0; @Q*;@F;Mi;N0;[[I"x;T0; @Q*;[;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; @Q*;@F;Ao;B;CT;DiV;Eia;Mi;!@';"@O*;#@P*;$To; ; F; ;,;;;I"Math#atanh;F;[[I"x;T0;[[@'ix;T;: atanh;0;[;{;IC;"~Computes the inverse hyperbolic tangent of +x+. Domain: (-1, 1) Codomain: (-INFINITY, INFINITY) Math.atanh(1) #=> Infinity ;T;[o;H ;II" overload;F;J0;;, ;K0;#I" atanh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @h*;[;I"@return [Float];T;0; @h*;@F;Mi;N0;[[I"x;T0; @h*;[;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; @h*;@F;N0;!@';"I"Mstatic VALUE math_atanh(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); /* check for domain error */ if (d < -1.0 || +1.0 < d) domain_error("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; ; T; ;;;;I"Math.atanh;F;@j*;@m*;T;;, ;0;@o*;{;IC;"~Computes the inverse hyperbolic tangent of +x+. Domain: (-1, 1) Codomain: (-INFINITY, INFINITY) Math.atanh(1) #=> Infinity;T;[o;H ;II" overload;F;J0;;, ;K0;#I" atanh(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @*;[;I"@return [Float];T;0; @*;@F;Mi;N0;[[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;Ao;B;CT;Dij;Eiu;Mi;!@';"@*;#@*;$To; ; F; ;,;;;I" Math#exp;F;[[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;H ;II" overload;F;J0;;;K0;#I" exp(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @*;[;I"@return [Float];T;0; @*;@F;Mi;N0;[[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;N0;!@';"I"astatic VALUE math_exp(VALUE unused_obj, VALUE x) { return DBL2NUM(exp(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I" Math.exp;F;@*;@*;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;H ;II" overload;F;J0;;;K0;#I" exp(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @*;[;I"@return [Float];T;0; @*;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@*;#@*;$To; ; F; ;,;;;I" Math#log;F;[[@0;[[@'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;H ;II" overload;F;J0;;;K0;#I" log(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @*;[;I"@return [Float];T;0; @*;@F;Mi;N0;[[I"x;T0; @*o;H ;II" overload;F;J0;;;K0;#I"log(x, base);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @*;[;I"@return [Float];T;0; @*;@F;Mi;N0;[[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;N0;!@';"I"qstatic VALUE math_log(int argc, const VALUE *argv, VALUE unused_obj) { return rb_math_log(argc, argv); };T;#I"static VALUE;T;$To; ; T; ;;;;I" Math.log;F;@*;@*;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;H ;II" overload;F;J0;;;K0;#I" log(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @+;[;I"@return [Float];T;0; @+;@F;Mi;N0;[[I"x;T0; @+o;H ;II" overload;F;J0;;;K0;#I"log(x, base);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @+;[;I"@return [Float];T;0; @+;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@*;#@*;$To; ; F; ;,;;;I"Math#log2;F;[[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;H ;II" overload;F;J0;;- ;K0;#I" log2(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @(+;[;I"@return [Float];T;0; @(+;@F;Mi;N0;[[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;N0;!@';"I"Rstatic VALUE math_log2(VALUE unused_obj, VALUE x) { size_t numbits; double d = get_double_rshift(x, &numbits); /* check for domain error */ if (d < 0.0) domain_error("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; ; T; ;;;;I"Math.log2;F;@*+;@-+;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;H ;II" overload;F;J0;;- ;K0;#I" log2(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @F+;[;I"@return [Float];T;0; @F+;@F;Mi;N0;[[I"x;T0; @F+;[;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+;@F;Ao;B;CT;Di;Ei;Mi;!@';"@D+;#@E+;$To; ; F; ;,;;;I"Math#log10;F;[[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;H ;II" overload;F;J0;;. ;K0;#I" log10(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @]+;[;I"@return [Float];T;0; @]+;@F;Mi;N0;[[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;N0;!@';"I"astatic VALUE math_log10(VALUE unused_obj, VALUE x) { size_t numbits; double d = get_double_rshift(x, &numbits); /* check for domain error */ if (d < 0.0) domain_error("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; ; T; ;;;;I"Math.log10;F;@_+;@b+;T;;. ;0;@d+;{;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;H ;II" overload;F;J0;;. ;K0;#I" log10(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @{+;[;I"@return [Float];T;0; @{+;@F;Mi;N0;[[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;Ao;B;CT;Di";Ei/;Mi;!@';"@y+;#@z+;$To; ; F; ;,;;;I"Math#sqrt;F;[[I"x;T0;[[@'ia;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;H ;II" overload;F;J0;;~;K0;#I" sqrt(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @+;[;I"@return [Float];T;0; @+;@F;Mi;N0;[[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;N0;!@';"I"Vstatic VALUE math_sqrt(VALUE unused_obj, VALUE x) { return rb_math_sqrt(x); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.sqrt;F;@+;@+;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;H ;II" overload;F;J0;;~;K0;#I" sqrt(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @+;[;I"@return [Float];T;0; @+;@F;Mi;N0;[[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;Ao;B;CT;Di@;Ei^;Mi;!@';"@+;#@+;$To; ; F; ;,;;;I"Math#cbrt;F;[[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;H ;II" overload;F;J0;;/ ;K0;#I" cbrt(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @+;[;I"@return [Float];T;0; @+;@F;Mi;N0;[[I"x;T0; @+;[;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; @+;@F;N0;!@';"I"static VALUE math_cbrt(VALUE unused_obj, VALUE x) { double f = Get_Double(x); double r = cbrt(f); #if defined __GLIBC__ if (isfinite(r)) { r = (2.0 * r + (f / r / r)) / 3.0; } #endif return DBL2NUM(r); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.cbrt;F;@+;@+;T;;/ ;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;H ;II" overload;F;J0;;/ ;K0;#I" cbrt(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @+;[;I"@return [Float];T;0; @+;@F;Mi;N0;[[I"x;T0; @+;[;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; @+;@F;Ao;B;CT;Di;Ei;Mi;!@';"@+;#@+;$To; ; F; ;,;;;I"Math#frexp;F;[[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;H ;II" overload;F;J0;;0 ;K0;#I" frexp(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @+;[;I"@return [Array];T;0; @+;@F;Mi;N0;[[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;N0;!@';"I"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; ; T; ;;;;I"Math.frexp;F;@+;@,;T;;0 ;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;H ;II" overload;F;J0;;0 ;K0;#I" frexp(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @,;[;I"@return [Array];T;0; @,;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@,;#@,;$To; ; F; ;,;;;I"Math#ldexp;F;[[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;H ;II" overload;F;J0;;1 ;K0;#I"ldexp(fraction, exponent);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @1,;[;I"@return [Float];T;0; @1,;@F;Mi;N0;[[I" fraction;T0[I" exponent;T0; @1,;[;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; @1,;@F;N0;!@';"I"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; ; T; ;;;;I"Math.ldexp;F;@3,;@8,;T;;1 ;0;@:,;{;IC;"Returns the value of +fraction+*(2**+exponent+). fraction, exponent = Math.frexp(1234) Math.ldexp(fraction, exponent) #=> 1234.0;T;[o;H ;II" overload;F;J0;;1 ;K0;#I"ldexp(fraction, exponent);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @S,;[;I"@return [Float];T;0; @S,;@F;Mi;N0;[[I" fraction;T0[I" exponent;T0; @S,;[;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; @S,;@F;Ao;B;CT;Di;Ei;Mi;!@';"@Q,;#@R,;$To; ; F; ;,;;;I"Math#hypot;F;[[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;H ;II" overload;F;J0;;2 ;K0;#I"hypot(x, y);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @l,;[;I"@return [Float];T;0; @l,;@F;Mi;N0;[[I"x;T0[I"y;T0; @l,;[;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; @l,;@F;N0;!@';"I"}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; ; T; ;;;;I"Math.hypot;F;@n,;@s,;T;;2 ;0;@u,;{;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;H ;II" overload;F;J0;;2 ;K0;#I"hypot(x, y);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @,;[;I"@return [Float];T;0; @,;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@,;#@,;$To; ; F; ;,;;;I" Math#erf;F;[[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;H ;II" overload;F;J0;;3 ;K0;#I" erf(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @,;[;I"@return [Float];T;0; @,;@F;Mi;N0;[[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;N0;!@';"I"astatic VALUE math_erf(VALUE unused_obj, VALUE x) { return DBL2NUM(erf(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I" Math.erf;F;@,;@,;T;;3 ;0;@,;{;IC;"vCalculates the error function of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.erf(0) #=> 0.0;T;[o;H ;II" overload;F;J0;;3 ;K0;#I" erf(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @,;[;I"@return [Float];T;0; @,;@F;Mi;N0;[[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;Ao;B;CT;Di;Ei;Mi;!@';"@,;#@,;$To; ; F; ;,;;;I"Math#erfc;F;[[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;H ;II" overload;F;J0;;4 ;K0;#I" erfc(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @,;[;I"@return [Float];T;0; @,;@F;Mi;N0;[[I"x;T0; @,;[;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; @,;@F;N0;!@';"I"cstatic VALUE math_erfc(VALUE unused_obj, VALUE x) { return DBL2NUM(erfc(Get_Double(x))); };T;#I"static VALUE;T;$To; ; T; ;;;;I"Math.erfc;F;@,;@,;T;;4 ;0;@,;{;IC;"}Calculates the complementary error function of x. Domain: (-INFINITY, INFINITY) Codomain: (0, 2) Math.erfc(0) #=> 1.0;T;[o;H ;II" overload;F;J0;;4 ;K0;#I" erfc(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @,;[;I"@return [Float];T;0; @,;@F;Mi;N0;[[I"x;T0; @,;[;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; @,;@F;Ao;B;CT;Di;Ei;Mi;!@';"@,;#@,;$To; ; F; ;,;;;I"Math#gamma;F;[[I"x;T0;[[@'iC;T;: gamma;0;[;{;IC;"Calculates the gamma function of x. Note that gamma(n) is 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;H ;II" overload;F;J0;;5 ;K0;#I" gamma(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @-;[;I"@return [Float];T;0; @-;@F;Mi;N0;[[I"x;T0; @-;[;I"Calculates the gamma function of x. Note that gamma(n) is 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;N0;!@';"I"4static 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)) { if (d < 0.0) domain_error("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; ; T; ;;;;I"Math.gamma;F;@-;@-;T;;5 ;0;@-;{;IC;"Calculates the gamma function of x. Note that gamma(n) is 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;H ;II" overload;F;J0;;5 ;K0;#I" gamma(x);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Float;T; @/-;[;I"@return [Float];T;0; @/-;@F;Mi;N0;[[I"x;T0; @/-;[;I" Calculates the gamma function of x. Note that gamma(n) is 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;Ao;B;CT;Di;Ei@;Mi;!@';"@--;#@.-;$To; ; F; ;,;;;I"Math#lgamma;F;[[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 same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoid overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1] ;T;[o;H ;II" overload;F;J0;;6 ;K0;#I"lgamma(x);T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I" Array;TI"-1;TI"1;T; @F-;[;I"@return [Array, -1, 1]];T;0; @F-;@F;Mi;N0;[[I"x;T0; @F-;[;I"$Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+. Math.lgamma(x) is same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoid overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1] @overload lgamma(x) @return [Array, -1, 1]];T;0; @F-;@F;N0;!@';"I"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; ; T; ;;;;I"Math.lgamma;F;@H-;@K-;T;;6 ;0;@M-;{;IC;"Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+. Math.lgamma(x) is same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoid overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1];T;[o;H ;II" overload;F;J0;;6 ;K0;#I"lgamma(x);T;IC;";T;[o;L ;II" return;F;JI"];T;0;K[I" Array;TI"-1;TI"1;T; @f-;[;I"@return [Array, -1, 1]];T;0; @f-;@F;Mi;N0;[[I"x;T0; @f-;[;I"' Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+. Math.lgamma(x) is same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoid overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1] @overload lgamma(x) @return [Array, -1, 1]];T;0; @f-;@F;Ao;B;CT;Div;Ei;Mi;!@';"@d-;#@e-;$T;&@';'IC;[;&@';(IC;[;&@';)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@'i;F;; ;;0;;;[;{;IC;" ;T;[;[;@;0; @';Mi;!@;I" Math;Fo; ;IC;[;&@-;'IC;[;&@-;(IC;[;&@-;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[[@kiG;F;: FileTest;;0;;;[;{;IC;" ;T;[;[;@;0; @-;!@;I" FileTest;F;&@;'IC;[;&@;(IC;[;&@;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{;.[;[;F;;;;0;;;[;{;IC;" ;T;[;[;@;0; @;Mi;!0;@;@:Bug::Float@ ;/@9u;@Ed;@{;@{;@m:#Numeric#singleton_method_added@m:Numeric#coerce@m:Numeric#clone@n:Numeric#dup@n:Numeric#i@:n:Numeric#+@@Un:Numeric#-@@pn:Numeric#<=>@n:Numeric#eql?@n:Numeric#fdiv@n:Numeric#div@n:Numeric#divmod@o:Numeric#%@'o:Numeric#modulo@Ao:Numeric#remainder@Zo:Numeric#abs@to:Numeric#magnitude@o:Numeric#to_int@o:Numeric#real?@o:Numeric#integer?@o:Numeric#zero?@p:Numeric#nonzero?@/p:Numeric#finite?@Kp:Numeric#infinite?@fp:Numeric#floor@p:Numeric#ceil@p:Numeric#round@p:Numeric#truncate@p:Numeric#step@p:Numeric#positive?@vq:Numeric#negative?@q:Integer.sqrt@Gd:Integer#to_s@fd:Integer#inspect@d:Integer#integer?@d:Integer#odd?@d:Integer#even?@d:Integer#allbits?@d:Integer#anybits?@d:Integer#nobits?@e:Integer#upto@;e:Integer#downto@ie:Integer#times@e:Integer#succ@e:Integer#next@e:Integer#pred@f:Integer#chr@f:Integer#ord@/f:Integer#to_i@Jf:Integer#to_int@rf:Integer#to_f@f:Integer#floor@f:Integer#ceil@f:Integer#truncate@f:Integer#round@g:Integer#<=>@1g:Integer#-@@Sg:Integer#+@ng:Integer#-@g:Integer#*@g:Integer#/@g:Integer#div@g:Integer#%@g:Integer#modulo@h:Integer#remainder@:Bug::Regexp@:"Bug::Regexp.parse_depth_limit@ :#Bug::Regexp.parse_depth_limit=@-;@ӻ:Kernel#srand@V:Kernel#rand@q:Random#initialize@ջ:Random#rand@:Random#bytes@:Random#seed@9:Random#initialize_copy@T:Random#marshal_dump@d:Random#marshal_load@r:Random#state@:Random#left@:Random#==@:Random::DEFAULT@:Random.srand@ɼ:Random.rand@:Random.bytes@ :Random.new_seed@,:Random.urandom@G:Random::Formatter@f:$Random::Formatter#random_number@h:Random::Formatter#rand@:Object::RB_WAITFD_IN@M:Object::RB_WAITFD_OUT@X:Object::RB_WAITFD_PRI@b:IO.wait_for_single_fd@:IO.kqueue_test_wait@&:Integer::SIZEOF_BDIGIT@h:Integer::BITSPERDIG@h:Integer#big_mul_normal@h:Integer#big_sq_fast@i:Integer#big_mul_balance@i:Integer#big_mul_karatsuba@i:Integer#big_mul_toom3@+i:Integer#big_mul_gmp@9i:Integer#big2str_generic@Gi:Integer#big2str_poweroftwo@Vi:Integer#big2str_gmp@di;@:Complex.rectangular@:Complex.rect@о:Complex.polar@:Kernel#Complex@:Complex#real@ :Complex#imaginary@!:Complex#imag@?:Complex#-@@\:Complex#+@r:Complex#-@:Complex#*@:Complex#/@:Complex#quo@:Complex#fdiv@:Complex#**@:Complex#==@!:Complex#coerce@@:Complex#abs@P:Complex#magnitude@n:Complex#abs2@:Complex#arg@:Complex#angle@:Complex#phase@ :Complex#rectangular@>:Complex#rect@f:Complex#polar@:Complex#conjugate@:Complex#conj@:Complex#real?@:Complex#numerator@:Complex#denominator@:Complex#hash@4:Complex#eql?@B:Complex#to_s@U:Complex#inspect@p:Complex#finite?@:Complex#infinite?@:Complex#marshal_dump@:Complex::compatible@:%Complex::compatible#marshal_load@:Complex#to_i@:Complex#to_f@ :Complex#to_r@':Complex#rationalize@=:Complex#to_c@V;@:NilClass#to_c@:Numeric#to_c@q;@:String#to_c@:Numeric#real@q:Numeric#imaginary@q:Numeric#imag@r:Numeric#abs2@,r:Numeric#arg@Br:Numeric#angle@zr:Numeric#phase@r:Numeric#rectangular@r:Numeric#rect@s:Numeric#polar@7s:Numeric#conjugate@Rs:Numeric#conj@zs:Float#arg@;u:Float#angle@su:Float#phase@u:Complex::I@q:Bug::Regexp.zero@;:Bug::Regexp.negzero@J;@t:String.try_convert@:String#initialize@.:String#initialize_copy@s:String#<=>@:String#==@:String#===@:String#eql?@ :String#hash@. :String#casecmp@I :String#casecmp?@k : String#+@ : String#*@ : String#%@ :String#[]@ :String#[]=@!:String#insert@":String#length@>":String#size@f":String#bytesize@":String#empty?@":String#=~@":String#match@":String#match?@#:String#succ@C#:String#succ!@k#:String#next@#:String#next!@#:String#upto@#:String#index@$:String#rindex@C$:String#replace@r$:String#clear@$:String#chr@$:String#getbyte@$:String#setbyte@$:String#byteslice@%:String#scrub@I%:String#scrub!@%:String#freeze@%:String#+@@%:String#-@@%:String#to_i@%:String#to_f@&:String#to_s@5&:String#to_str@]&:String#inspect@&:String#dump@&:String#undump@&:String#upcase@&:String#downcase@':String#capitalize@+':String#swapcase@V':String#upcase!@':String#downcase!@':String#capitalize!@':String#swapcase!@(:String#hex@5(:String#oct@P(:String#split@k(:String#lines@(:String#bytes@(:String#chars@(:String#codepoints@(:String#grapheme_clusters@):String#reverse@.):String#reverse!@I):String#concat@d):String#<<@):String#prepend@):String#crypt@):String#intern@):String#to_sym@*:String#ord@0*:String#include?@K*:String#start_with?@j*:String#end_with?@*:String#scan@*:String#ljust@*:String#rjust@*:String#center@+:String#sub@=+:String#gsub@+:String#chop@+:String#chomp@+:String#strip@ ,:String#lstrip@&,:String#rstrip@A,:String#delete_prefix@\,:String#delete_suffix@{,:String#sub!@,:String#gsub!@,:String#chop!@"-:String#chomp!@>-:String#strip!@^-:String#lstrip!@z-:String#rstrip!@-:String#delete_prefix!@-:String#delete_suffix!@-:String#tr@-:String#tr_s@.:String#delete@8.:String#squeeze@V.:String#count@t.:String#tr!@.:String#tr_s!@.:String#delete!@.:String#squeeze!@.:String#each_line@/:String#each_byte@G/:String#each_char@o/:String#each_codepoint@/:!String#each_grapheme_cluster@/:String#sum@/:String#slice@0:String#slice!@0:String#partition@=1:String#rpartition@k1:String#encoding@1;@G:Encoding#to_s@I:Encoding#inspect@q:Encoding#name@:Encoding#names@:Encoding#dummy?@:Encoding#ascii_compatible?@:Encoding#replicate@:Encoding.list@#:Encoding.name_list@>:Encoding.aliases@Y:Encoding.find@o:Encoding.compatible?@:Encoding#_dump@:Encoding._load@:Encoding.default_external@:Encoding.default_external=@:Encoding.default_internal@:Encoding.default_internal=@:Encoding.locale_charmap@+:String#force_encoding@1: String#b@1:String#valid_encoding?@1:String#ascii_only?@2;@:String#unicode_normalize@#2:String#unicode_normalize!@=2:String#unicode_normalized?@W2:Symbol.all_symbols@v:Symbol#==@:Symbol#===@:Symbol#inspect@:Symbol#to_s@:Symbol#id2name@:Symbol#intern@:Symbol#to_sym@-:Symbol#to_proc@J:Symbol#succ@`:Symbol#next@v:Symbol#<=>@:Symbol#casecmp@:Symbol#casecmp?@:Symbol#=~@:Symbol#[]@:Symbol#slice@_:Symbol#length@:Symbol#size@:Symbol#empty?@:Symbol#match@:Symbol#match?@H:Symbol#upcase@w:Symbol#downcase@:Symbol#capitalize@:Symbol#swapcase@:Symbol#encoding@:Integer#test_pack_raw@ri:Integer#test_pack@i:Integer.test_unpack@i:'Integer::INTEGER_PACK_MSWORD_FIRST@i:'Integer::INTEGER_PACK_LSWORD_FIRST@i:'Integer::INTEGER_PACK_MSBYTE_FIRST@i:'Integer::INTEGER_PACK_LSBYTE_FIRST@i:,Integer::INTEGER_PACK_NATIVE_BYTE_ORDER@i: Integer::INTEGER_PACK_2COMP@i:(Integer::INTEGER_PACK_LITTLE_ENDIAN@i:%Integer::INTEGER_PACK_BIG_ENDIAN@i:'Integer::INTEGER_PACK_FORCE_BIGNUM@j:#Integer::INTEGER_PACK_NEGATIVE@ j:7Integer::INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION@j:,Integer#test_numbits_2comp_without_sign@!j:*Integer#test_numbytes_2comp_with_sign@-j:Integer#big_divrem_normal@9j:Integer#big_divrem_gmp@Hj:Integer#coerce@Vj:Integer::GMP_VERSION@uj:Bug::Bignum@";@:Marshal#dump@:Marshal.dump@/:Marshal#load@D:Marshal.load@p:Marshal#restore@:Marshal.restore@:Marshal::MAJOR_VERSION@:Marshal::MINOR_VERSION@:String#str2big_poweroftwo@t2:String#str2big_normal@2:String#str2big_karatsuba@2:String#str2big_gmp@2:Math::DomainError@':Bug#bug_14834@3:Bug.bug_14834@3:Bug::ScanArgs@3:Bug::ScanArgs.lead@3:Bug::ScanArgs.opt@3:Bug::ScanArgs.lead_opt@3:Bug::ScanArgs.var@3:Bug::ScanArgs.lead_var@3:Bug::ScanArgs.opt_var@3:Bug::ScanArgs.lead_opt_var@3:Bug::ScanArgs.opt_trail@4:!Bug::ScanArgs.lead_opt_trail@4:Bug::ScanArgs.var_trail@#4:!Bug::ScanArgs.lead_var_trail@04: Bug::ScanArgs.opt_var_trail@=4:%Bug::ScanArgs.lead_opt_var_trail@J4:Bug::ScanArgs.hash@W4:Bug::ScanArgs.lead_hash@f4:Bug::ScanArgs.opt_hash@s4: Bug::ScanArgs.lead_opt_hash@4:Bug::ScanArgs.var_hash@4: Bug::ScanArgs.lead_var_hash@4:Bug::ScanArgs.opt_var_hash@4:$Bug::ScanArgs.lead_opt_var_hash@4:!Bug::ScanArgs.opt_trail_hash@4:&Bug::ScanArgs.lead_opt_trail_hash@4:!Bug::ScanArgs.var_trail_hash@4:&Bug::ScanArgs.lead_var_trail_hash@4:%Bug::ScanArgs.opt_var_trail_hash@4:*Bug::ScanArgs.lead_opt_var_trail_hash@5;@;@;@;@&;@p:Mutex#initialize@:Mutex#locked?@:Mutex#try_lock@:Mutex#lock@:Mutex#unlock@:Mutex#sleep@3:Mutex#synchronize@R:Mutex#owned?@m:Queue#initialize@:Queue#marshal_dump@:Queue#close@ :Queue#closed?@":Queue#push@;:Queue#pop@q:Queue#empty?@:Queue#clear@:Queue#length@:Queue#num_waiting@:Queue#enq@: Queue#<<@f:Queue#deq@ :Queue#shift@:Queue#size@:SizedQueue#initialize@(:SizedQueue#close@B:SizedQueue#max@X:SizedQueue#max=@f:SizedQueue#push@:SizedQueue#pop@:SizedQueue#empty?@:SizedQueue#clear@ :SizedQueue#length@:SizedQueue#num_waiting@@:SizedQueue#enq@N:SizedQueue#<<@:SizedQueue#deq@V:SizedQueue#shift@:SizedQueue#size@5:!ConditionVariable#initialize@r:#ConditionVariable#marshal_dump@:ConditionVariable#wait@:ConditionVariable#signal@: ConditionVariable#broadcast@:/Enumerator::ArithmeticSequence.__extract__@Q;@:Kernel#trap@:Signal#trap@:Signal.trap@ :Signal#list@8:Signal.list@R:Signal#signame@g:Signal.signame@:SignalException#initialize@I(:Bug.unp_st_foreach_check@p5:Bug.unp_st_foreach@5:Kernel#set_trace_func@;A@I:Thread#set_trace_func@K:Thread#add_trace_func@y;@:TracePoint.new@:TracePoint.trace@:TracePoint#__enable@:TracePoint#disable@:TracePoint#enabled?@:TracePoint#inspect@:TracePoint#event@:TracePoint#lineno@':TracePoint#path@5:TracePoint#parameters@C:TracePoint#method_id@Q:TracePoint#callee_id@_:TracePoint#defined_class@m:TracePoint#binding@{:TracePoint#self@:TracePoint#return_value@: TracePoint#raised_exception@:TracePoint#eval_script@:$TracePoint#instruction_sequence@:TracePoint.stat@:"Random::Formatter#test_select@:"Random::Formatter.test_select@:!Random::Formatter#test_fdset@ :!Random::Formatter.test_fdset@:IO#console_info@2:IO#console_attribute@?:'Random::Formatter::FOREGROUND_MASK@:'Random::Formatter::FOREGROUND_BLUE@&:(Random::Formatter::FOREGROUND_GREEN@0:&Random::Formatter::FOREGROUND_RED@::,Random::Formatter::FOREGROUND_INTENSITY@D:'Random::Formatter::BACKGROUND_MASK@N:'Random::Formatter::BACKGROUND_BLUE@X:(Random::Formatter::BACKGROUND_GREEN@b:&Random::Formatter::BACKGROUND_RED@l:,Random::Formatter::BACKGROUND_INTENSITY@v:%Random::Formatter::REVERSE_VIDEO@:Bug::Win32@5;@:Kernel#Rational@ :Rational#numerator@:Rational#denominator@ :Rational#-@@':Rational#+@=:Rational#-@\:Rational#*@{:Rational#/@:Rational#quo@:Rational#fdiv@:Rational#**@:Rational#<=>@:Rational#==@?:Rational#coerce@^:Rational#positive?@n:Rational#negative?@:Rational#abs@:Rational#magnitude@:Rational#floor@:Rational#ceil@:Rational#truncate@:Rational#round@9:Rational#to_i@X:Rational#to_f@s:Rational#to_r@:Rational#rationalize@:Rational#hash@:Rational#to_s@:Rational#inspect@:Rational#marshal_dump@:Rational::compatible@!:&Rational::compatible#marshal_load@#:Integer#gcd@j:Integer#lcm@j:Integer#gcdlcm@j:Numeric#numerator@s:Numeric#denominator@s:Numeric#quo@s:Integer#numerator@j:Integer#denominator@j:Float#numerator@u:Float#denominator@u:NilClass#to_r@:NilClass#rationalize@:Integer#to_r@k:Integer#rationalize@*k:Float#to_r@v:Float#rationalize@-v:String#to_r@2:Bug::Win32#dlntest@5:Bug::Win32.dlntest@5;@S;@;@i:Regexp.compile@k:Regexp.quote@v:Regexp.escape@:Regexp.union@:Regexp.last_match@:Regexp.try_convert@/:Regexp#initialize@N:Regexp#initialize_copy@:Regexp#hash@:Regexp#eql?@:Regexp#==@:Regexp#=~@#:Regexp#===@C: Regexp#~@b:Regexp#match@:Regexp#match?@:Regexp#to_s@:Regexp#inspect@:Regexp#source@:Regexp#casefold?@1:Regexp#options@L:Regexp#encoding@g:Regexp#fixed_encoding?@:Regexp#names@:Regexp#named_captures@:Regexp::IGNORECASE@:Regexp::EXTENDED@:Regexp::MULTILINE@:Regexp::FIXEDENCODING@:Regexp::NOENCODING@:MatchData#initialize_copy@U:MatchData#regexp@e:MatchData#names@:MatchData#size@:MatchData#length@:MatchData#offset@:MatchData#begin@ :MatchData#end@(:MatchData#to_a@G:MatchData#[]@b:MatchData#captures@:MatchData#named_captures@:MatchData#values_at@:MatchData#pre_match@:MatchData#post_match@":MatchData#to_s@=:MatchData#inspect@X:MatchData#string@s:MatchData#hash@:MatchData#eql?@:MatchData#==@:Bug::Bignum::DataError@$:Bug::Bignum#ensured@:Bug::Bignum.ensured@:Bug::Bignum#ensure_raise@:Bug::Bignum.ensure_raise@;@+;@;T@;|@;@:BasicObject#initialize@:BasicObject#==@:BasicObject#equal?@:BasicObject#!@1:BasicObject#!=@L:'BasicObject#singleton_method_added@k:)BasicObject#singleton_method_removed@x:+BasicObject#singleton_method_undefined@:Class#inherited@:Module#included@:Module#extended@:Module#prepended@:Module#method_added@:Module#method_removed@:Module#method_undefined@:Object#nil?@z:Object#===@:Object#=~@:Object#!~@:Object#eql?@:Object#hash@+:Object#<=>@7:Object#class@W:Object#singleton_class@r:Object#clone@:Object#dup@:Object#itself@:Object#yield_self@:Object#then@: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#frozen?@2:Object#to_s@M:Object#inspect@h:Object#methods@:Object#singleton_methods@:Object#protected_methods@:Object#private_methods@:Object#public_methods@:Object#instance_variables@:!Object#instance_variable_get@;:!Object#instance_variable_set@i:&Object#instance_variable_defined?@:$Object#remove_instance_variable@:Object#instance_of?@:Object#kind_of?@:Object#is_a?@@:Object#tap@i:Kernel#sprintf@B :Kernel#format@p :Kernel#Integer@ :Kernel#Float@ :Kernel#String@ :Kernel#Array@ :Kernel#Hash@ :NilClass#to_i@:NilClass#to_f@:NilClass#to_s@ :NilClass#to_a@!:NilClass#to_h@/:NilClass#inspect@=:NilClass#=~@S:NilClass#&@r:NilClass#|@:NilClass#^@:NilClass#===@:NilClass#nil?@;X@:Module#freeze@:Module#===@:Module#==@/:Module#<=>@k: Module#<@:Module#<=@: Module#>@:Module#>=@:Module#initialize_copy@:Module#to_s@!:Module#inspect@9:Module#included_modules@D:Module#include?@_:Module#name@|:Module#ancestors@:Module#attr@:Module#attr_reader@:Module#attr_writer@G:Module#attr_accessor@x:Module#initialize@:Module#initialize_clone@:Module#instance_methods@:#Module#public_instance_methods@:&Module#protected_instance_methods@:$Module#private_instance_methods@9:Module#constants@X:Module#const_get@w:Module#const_set@:Module#const_defined?@:Module#remove_const@:Module#const_missing@0:Module#class_variables@O:!Module#remove_class_variable@n:Module#class_variable_get@:Module#class_variable_set@:#Module#class_variable_defined?@:Module#public_constant@:Module#private_constant@8:Module#deprecate_constant@S:Module#singleton_class?@n:Class#allocate@:Class#new@:Class#initialize@7:Class#superclass@k;@S6:TrueClass#to_s@-:TrueClass#inspect@@:TrueClass#&@K:TrueClass#|@j:TrueClass#^@:TrueClass#===@;Y@:FalseClass#to_s@:FalseClass#inspect@:FalseClass#&@:FalseClass#|@ :FalseClass#^@M:FalseClass#===@z;Z@:Bug::Exception@5;]@:ObjectSpace::WeakMap@:GC::Profiler@*&:Bug::Exception#enc_raise@5:Bug::Exception.enc_raise@5;~@;@;@I:Kernel#syscall@> :Kernel#open@\ :Kernel#printf@ :Kernel#print@ :Kernel#putc@ :Kernel#puts@ :Kernel#gets@ :Kernel#readline@_ :Kernel#select@ :Kernel#readlines@ : Kernel#`@ : Kernel#p@ :Object#display@:IO::WaitReadable@M:IO::WaitWritable@`:IO::EAGAINWaitReadable@r:IO::EAGAINWaitWritable@: IO::EWOULDBLOCKWaitReadable@: IO::EWOULDBLOCKWaitWritable@: IO::EINPROGRESSWaitReadable@: IO::EINPROGRESSWaitWritable@̚;m@V:File.open@X: IO.new@ޚ: IO.open@:IO.sysopen@:IO.for_fd@: IO.popen@<:IO.foreach@t:IO.readlines@қ: IO.read@:IO.binread@7: IO.write@W:IO.binwrite@:IO.select@: IO.pipe@ݜ:IO.try_convert@):IO.copy_stream@I:IO#initialize@:IO#initialize_copy@:IO#reopen@: IO#print@ߝ: IO#putc@ : IO#puts@+:IO#printf@K: IO#each@i:IO#each_line@:IO#each_byte@:IO#each_char@@:IO#each_codepoint@h: IO#lines@: IO#bytes@: IO#chars@ǟ:IO#codepoints@՟:IO#syswrite@:IO#sysread@: IO#pread@ :IO#pwrite@@:IO#fileno@c: IO#to_i@: IO#to_io@: IO#fsync@:IO#fdatasync@ʠ: IO#sync@: IO#sync=@:IO#lineno@:IO#lineno=@*:IO#readlines@I:IO#__read_nonblock@:IO#__write_nonblock@:IO#readpartial@: IO#read@ء: IO#write@: IO#gets@:IO#readline@Y: IO#getc@:IO#getbyte@:IO#readchar@Т:IO#readbyte@:IO#ungetbyte@:IO#ungetc@4: IO#<<@S: IO#flush@r: IO#tell@: IO#seek@:IO::SEEK_SET@֣:IO::SEEK_CUR@:IO::SEEK_END@:IO::SEEK_DATA@:IO::SEEK_HOLE@:IO#rewind@: IO#pos@-: IO#pos=@T: IO#eof@s: IO#eof?@:IO#close_on_exec?@¤:IO#close_on_exec=@ݤ: IO#close@:IO#closed?@:IO#close_read@2:IO#close_write@M:IO#isatty@h: IO#tty?@:IO#binmode@:IO#binmode?@ҥ:IO#sysseek@:IO#advise@: IO#ioctl@2: IO#fcntl@R: IO#pid@r:IO#inspect@:IO#external_encoding@:IO#internal_encoding@æ:IO#set_encoding@ަ:IO#autoclose?@B:IO#autoclose=@];@%;@1;@=:ARGF#initializeo; ; F; ;,;;;I"ARGF#initialize;F;[[I" argv;T0;[[@i!;T;;;0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @-;@F;Ao;B;CT;Di!;Ei!;!o; ;IC;[=@-o; ; F; ;,;;;I"ARGF#initialize_copy;F;[[I" orig;T0;[[@i!;T;;];0;[;{;IC;" :nodoc: ;T;[;[;I" :nodoc:;T;0; @-;@F;Ao;B;CT;Di!;Ei!;!@-;"I"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; ; F; ;,;;;I"ARGF#to_s;F;[;[[@ip1;T;;h;0;[;{;IC;"Returns "ARGF". ;T;[o;H ;II" overload;F;J0;;h;K0;#I" to_s;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @-;[;I"@return [String];T;0; @-;@F;Mi;N0;[; @-;[;I"8Returns "ARGF". @overload to_s @return [String];T;0; o; ; F; ;,;;;I"ARGF#inspect;F;[;[[@i3;F;;i;;0;[;{;@-;!@-;"I"Kstatic VALUE argf_to_s(VALUE argf) { return rb_str_new2("ARGF"); };T;#I"static VALUE;T;@F;Ao;B;CT;Dij1;Ein1;!@-;"I"Kstatic VALUE argf_to_s(VALUE argf) { return rb_str_new2("ARGF"); };T;#@-;$T@-o; ; F; ;,;;;I"ARGF#argv;F;[;[[@i1;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;H ;II" overload;F;J0;;;K0;#I" argv;T;IC;";T;[;[;I";T;0; @-;@F;Mi;N0;[; @-;[;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;Ao;B;CT;Di1;Ei1;!@-;"I"Astatic VALUE argf_argv(VALUE argf) { return ARGF.argv; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#fileno;F;[;[[@i=.;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;H ;II" overload;F;J0;;;K0;#I" fileno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @.;[;I"@return [Integer];T;0; @.;@F;Mi;N0;[; @.o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @.;[;I"@return [Integer];T;0; @.;@F;Mi;N0;[; @.;[;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; @.;@F;Ao;B;CT;Di3.;Ei<.;!@-;"I"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; ; F; ;,;;;I"ARGF#to_i;F;[;[[@i=.;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;H ;II" overload;F;J0;;;K0;#I" fileno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-.;[;I"@return [Integer];T;0; @-.;@F;Mi;N0;[; @-.o;H ;II" overload;F;J0;;=;K0;#I" to_i;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @-.;[;I"@return [Integer];T;0; @-.;@F;Mi;N0;[; @-.;[;@).;0; @-.;@F;Ao;B;CT;Di3.;Ei<.;!@-;"I"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; ; F; ;,;;;I"ARGF#to_io;F;[;[[@iS.;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;H ;II" overload;F;J0;;;K0;#I" to_io;T;IC;";T;[;[;I";T;0; @T.;@F;Mi;N0;[; @T.;[;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; @T.;@F;Ao;B;CT;DiG.;EiP.;!@-;"I"sstatic VALUE argf_to_io(VALUE argf) { next_argv(); ARGF_FORWARD(0, 0); return ARGF.current_file; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#to_write_io;F;[;[[@i1;T;:to_write_io;0;[;{;IC;"OReturns IO instance tied to _ARGF_ for writing if inplace mode is enabled. ;T;[o;H ;II" overload;F;J0;;;K0;#I"to_write_io;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"IO;T; @j.;[;I"@return [IO];T;0; @j.;@F;Mi;N0;[; @j.;[;I"vReturns IO instance tied to _ARGF_ for writing if inplace mode is enabled. @overload to_write_io @return [IO];T;0; @j.;@F;Ao;B;CT;Di1;Ei1;!@-;"I"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; ; F; ;,;;;I"ARGF#each;F;[[@0;[[@i.0;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;H ;II" overload;F;J0;;;K0;#I"each(sep=$/);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @.;[;I"@yield [line];T;0; @.;@F;Mi;N0;[[I"sep;TI"$/;T; @.o;H ;II" overload;F;J0;;;K0;#I"each(sep=$/, limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @.;[;I"@yield [line];T;0; @.;@F;Mi;N0;[[I"sep;TI"$/;T[I" limit;T0; @.o;H ;II" overload;F;J0;;;K0;#I"each(...);T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[[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;Ao;B;CT;Di0;Ei-0;!@-;"I"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; ; F; ;,;;;I"ARGF#each_line;F;[[@0;[[@i.0;T;;w;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;H ;II" overload;F;J0;;;K0;#I"each(sep=$/);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @.;[;I"@yield [line];T;0; @.;@F;Mi;N0;[[I"sep;TI"$/;T; @.o;H ;II" overload;F;J0;;;K0;#I"each(sep=$/, limit);T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" line;T; @.;[;I"@yield [line];T;0; @.;@F;Mi;N0;[[I"sep;TI"$/;T[I" limit;T0; @.o;H ;II" overload;F;J0;;;K0;#I"each(...);T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[[I"...;T0; @.;[;@.;0; @.;@F;Ao;B;CT;Di0;Ei-0;!@-;"I"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; ; F; ;,;;;I"ARGF#each_byte;F;[;[[@i]0;T;;x;0;[;{;IC;"ARGF.each_byte {|byte| block } -> ARGF ARGF.each_byte -> an_enumerator 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;H ;II" overload;F;J0;;J;K0;#I" bytes;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" byte;T; @.;[;I"@yield [byte];T;0; @.;@F;Mi;N0;[; @.o;H ;II" overload;F;J0;;J;K0;#I" bytes;T;IC;";T;[;[;I";T;0; @.;@F;Mi;N0;[; @.;[;I" ARGF.each_byte {|byte| block } -> ARGF ARGF.each_byte -> an_enumerator 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] @overload bytes @yield [byte] @overload bytes;T;0; @.;@F;Ao;B;CT;DiE0;Ei[0;!@-;"I"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; ; F; ;,;;;I"ARGF#each_char;F;[;[[@i0;T;;y;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;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I" char;T; @/;[;I"@yield [char];T;0; @/;@F;Mi;N0;[; @/o;H ;II" overload;F;J0;;y;K0;#I"each_char;T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[; @/;[;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; @/;@F;Ao;B;CT;Dit0;Ei0;!@-;"I"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; ; F; ;,;;;I"ARGF#each_codepoint;F;[;[[@i0;T;;z;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;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[o;L ;II" yield;F;JI";T;0;K[I"codepoint;T; @@/;[;I"@yield [codepoint];T;0; @@/;@F;Mi;N0;[; @@/o;H ;II" overload;F;J0;;z;K0;#I"each_codepoint;T;IC;";T;[;[;I";T;0; @@/;@F;Mi;N0;[; @@/;[;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;Ao;B;CT;Di0;Ei0;!@-;"I"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; ; F; ;,;;;I"ARGF#lines;F;[[@0;[[@i<0;T;;I;0;[;{;IC;";This is a deprecated alias for each_line. ;T;[;[;I"each_line. ;T;0; @c/;@F;Ao;B;CT;Di80;Ei90;!@-;"I"static VALUE argf_lines(int argc, VALUE *argv, VALUE argf) { rb_warn("ARGF#lines is deprecated; use #each_line instead"); if (!rb_block_given_p()) return rb_enumeratorize(argf, ID2SYM(rb_intern("each_line")), argc, argv); return argf_each_line(argc, argv, argf); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#bytes;F;[;[[@ik0;T;;J;0;[;{;IC;";This is a deprecated alias for each_byte. ;T;[;[;I"each_byte. ;T;0; @r/;@F;Ao;B;CT;Dig0;Eih0;!@-;"I"static VALUE argf_bytes(VALUE argf) { rb_warn("ARGF#bytes is deprecated; use #each_byte instead"); if (!rb_block_given_p()) return rb_enumeratorize(argf, ID2SYM(rb_intern("each_byte")), 0, 0); return argf_each_byte(argf); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#chars;F;[;[[@i0;T;;K;0;[;{;IC;";This is a deprecated alias for each_char. ;T;[;[;I"each_char. ;T;0; @/;@F;Ao;B;CT;Di0;Ei0;!@-;"I"static VALUE argf_chars(VALUE argf) { rb_warn("ARGF#chars is deprecated; use #each_char instead"); if (!rb_block_given_p()) return rb_enumeratorize(argf, ID2SYM(rb_intern("each_char")), 0, 0); return argf_each_char(argf); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#codepoints;F;[;[[@i0;T;;L;0;[;{;IC;"@This is a deprecated alias for each_codepoint. ;T;[;[;I"AThis is a deprecated alias for each_codepoint. ;T;0; @/;@F;Ao;B;CT;Di0;Ei0;!@-;"I"static VALUE argf_codepoints(VALUE argf) { rb_warn("ARGF#codepoints is deprecated; use #each_codepoint instead"); if (!rb_block_given_p()) return rb_enumeratorize(argf, ID2SYM(rb_intern("each_codepoint")), 0, 0); return argf_each_codepoint(argf); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#read;F;[[@0;[[@i.;T;;;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;H ;II" overload;F;J0;;;K0;#I"read([length [, outbuf]]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @/;[;I"@return [String, nil];T;0; @/;@F;Mi;N0;[[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;Ao;B;CT;Di|.;Ei.;!@-;"I"tstatic 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) { len -= slen; argv[0] = INT2NUM(len); goto retry; } } return str; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#readpartial;F;[[@0;[[@i.;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;H ;II" overload;F;J0;;;K0;#I"readpartial(maxlen);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @/;[;I"@return [String];T;0; @/;@F;Mi;N0;[[I" maxlen;T0; @/o;H ;II" overload;F;J0;;;K0;#I" readpartial(maxlen, outbuf);T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[[I" maxlen;T0[I" outbuf;T0; @/;[;I"sReads 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;Ao;B;CT;Di.;Ei.;!@-;"I"{static VALUE argf_readpartial(int argc, VALUE *argv, VALUE argf) { return argf_getpartial(argc, argv, argf, Qnil, 0); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#read_nonblock;F;[[@0;[[@i /;T;;(;0;[;{;IC;"LReads at most _maxlen_ bytes from the ARGF stream in non-blocking mode. ;T;[o;H ;II" overload;F;J0;;(;K0;#I"%read_nonblock(maxlen[, options]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @/;[;I"@return [String];T;0; @/;@F;Mi;N0;[[I"maxlen[, options];T0; @/o;H ;II" overload;F;J0;;(;K0;#I"-read_nonblock(maxlen, outbuf[, options]);T;IC;";T;[;[;I";T;0; @/;@F;Mi;N0;[[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;Ao;B;CT;Di/;Ei /;!@-;"I"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; ; F; ;,;;;I"ARGF#readlines;F;[[@0;[[@i#;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;H ;II" overload;F;J0;;;K0;#I"readlines(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @0;[;I"@return [Array];T;0; @0;@F;Mi;N0;[[I"sep;TI"$/;T; @0o;H ;II" overload;F;J0;;;K0;#I"readlines(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @0;[;I"@return [Array];T;0; @0;@F;Mi;N0;[[I" limit;T0; @0o;H ;II" overload;F;J0;;;K0;#I"readlines(sep, limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @0;[;I"@return [Array];T;0; @0;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @0;[;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; @0;@F;Ao;B;CT;Di";Ei#;!@-;"I"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 = rb_funcall3(ARGF.current_file, 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; ; F; ;,;;;I"ARGF#to_a;F;[[@0;[[@i#;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;H ;II" overload;F;J0;;;K0;#I"readlines(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @N0;[;I"@return [Array];T;0; @N0;@F;Mi;N0;[[I"sep;TI"$/;T; @N0o;H ;II" overload;F;J0;;;K0;#I"readlines(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @N0;[;I"@return [Array];T;0; @N0;@F;Mi;N0;[[I" limit;T0; @N0o;H ;II" overload;F;J0;;;K0;#I"readlines(sep, limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Array;T; @N0;[;I"@return [Array];T;0; @N0;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @N0;[;@J0;0; @N0;@F;Ao;B;CT;Di";Ei#;!@-;"I"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 = rb_funcall3(ARGF.current_file, 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; ; F; ;,;;;I"ARGF#gets;F;[[@0;[[@i";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;H ;II" overload;F;J0;;;K0;#I""gets(sep=$/ [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I"sep;TI"$/[, getline_args];T; @0o;H ;II" overload;F;J0;;;K0;#I"!gets(limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I"limit[, getline_args];T0; @0o;H ;II" overload;F;J0;;;K0;#I"&gets(sep, limit [, getline_args]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @0;[;I"@return [String, nil];T;0; @0;@F;Mi;N0;[[I"sep;T0[I"limit[, getline_args];T0; @0;[;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; @0;@F;Ao;B;CT;Diq";Ei";!@-;"I"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; ; F; ;,;;;I"ARGF#readline;F;[[@0;[[@i";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;H ;II" overload;F;J0;;;K0;#I"readline(sep=$/);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @0;[;I"@return [String];T;0; @0;@F;Mi;N0;[[I"sep;TI"$/;T; @0o;H ;II" overload;F;J0;;;K0;#I"readline(limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @0;[;I"@return [String];T;0; @0;@F;Mi;N0;[[I" limit;T0; @0o;H ;II" overload;F;J0;;;K0;#I"readline(sep, limit);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @0;[;I"@return [String];T;0; @0;@F;Mi;N0;[[I"sep;T0[I" limit;T0; @0;[;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; @0;@F;Ao;B;CT;Di";Ei";!@-;"I"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; ; F; ;,;;;I"ARGF#getc;F;[;[[@i]/;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;H ;II" overload;F;J0;;;K0;#I" getc;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @ 1;[;I"@return [String, nil];T;0; @ 1;@F;Mi;N0;[; @ 1;[;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; @ 1;@F;Ao;B;CT;DiF/;Ei[/;!@-;"I"pstatic VALUE argf_getc(VALUE argf) { VALUE ch; retry: if (!next_argv()) return Qnil; if (ARGF_GENERIC_INPUT_P()) { ch = rb_funcall3(ARGF.current_file, 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; ; F; ;,;;;I"ARGF#getbyte;F;[;[[@i/;T;;5;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;H ;II" overload;F;J0;;5;K0;#I" getbyte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;TI"nil;T; @)1;[;I"@return [Integer, nil];T;0; @)1;@F;Mi;N0;[; @)1;[;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; @)1;@F;Ao;B;CT;Dis/;Ei/;!@-;"I"static VALUE argf_getbyte(VALUE argf) { VALUE ch; retry: if (!next_argv()) return Qnil; if (!RB_TYPE_P(ARGF.current_file, T_FILE)) { ch = rb_funcall3(ARGF.current_file, 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; ; F; ;,;;;I"ARGF#readchar;F;[;[[@i/;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;H ;II" overload;F;J0;;;K0;#I" readchar;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;TI"nil;T; @E1;[;I"@return [String, nil];T;0; @E1;@F;Mi;N0;[; @E1;[;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; @E1;@F;Ao;B;CT;Di/;Ei/;!@-;"I"static VALUE argf_readchar(VALUE argf) { VALUE ch; retry: if (!next_argv()) rb_eof_error(); if (!RB_TYPE_P(ARGF.current_file, T_FILE)) { ch = rb_funcall3(ARGF.current_file, 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; ; F; ;,;;;I"ARGF#readbyte;F;[;[[@i/;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;H ;II" overload;F;J0;;;K0;#I" readbyte;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @a1;[;I"@return [Integer];T;0; @a1;@F;Mi;N0;[; @a1;[;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; @a1;@F;Ao;B;CT;Di/;Ei/;!@-;"I"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; ; F; ;,;;;I"ARGF#tell;F;[;[[@i-;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;H ;II" overload;F;J0;;;K0;#I" tell;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|1;[;I"@return [Integer];T;0; @|1;@F;Mi;N0;[; @|1o;H ;II" overload;F;J0;;;K0;#I"pos;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @|1;[;I"@return [Integer];T;0; @|1;@F;Mi;N0;[; @|1;[;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; @|1;@F;Ao;B;CT;Di-;Ei-;!@-;"I"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; ; F; ;,;;;I"ARGF#seek;F;[[@0;[[@i-;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;H ;II" overload;F;J0;;;K0;#I"&seek(amount, whence=IO::SEEK_SET);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @1;[;I"@return [0];T;0; @1;@F;Mi;N0;[[I" amount;T0[I" whence;TI"IO::SEEK_SET;T; @1;[;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; @1;@F;Ao;B;CT;Di-;Ei-;!@-;"I"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; ; F; ;,;;;I"ARGF#rewind;F;[;[[@i!.;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;H ;II" overload;F;J0;;;K0;#I" rewind;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"0;T; @1;[;I"@return [0];T;0; @1;@F;Mi;N0;[; @1;[;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; @1;@F;Ao;B;CT;Di.;Ei.;!@-;"I"{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; ; F; ;,;;;I" ARGF#pos;F;[;[[@i-;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;H ;II" overload;F;J0;;;K0;#I" tell;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @1;[;I"@return [Integer];T;0; @1;@F;Mi;N0;[; @1o;H ;II" overload;F;J0;;;K0;#I"pos;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @1;[;I"@return [Integer];T;0; @1;@F;Mi;N0;[; @1;[;@1;0; @1;@F;Ao;B;CT;Di-;Ei-;!@-;"I"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; ; F; ;,;;;I"ARGF#pos=;F;[[I" offset;T0;[[@i .;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;H ;II" overload;F;J0;;;K0;#I"pos=(position);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @2;[;I"@return [Integer];T;0; @2;@F;Mi;N0;[[I" position;T0; @2;[;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; @2;@F;Ao;B;CT;Di.;Ei .;!@-;"I"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; ; F; ;,;;;I" ARGF#eof;F;[;[[@im.;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;H ;II" overload;F;J0;;;K0;#I" eof?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @&2;[;I"@return [Boolean];T;0; @&2;@F;Mi;N0;[; @&2o;H ;II" overload;F;J0;;;K0;#I"eof;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @&2;[;I"@return [Boolean];T;0; @&2;@F;Mi;N0;[; @&2;[;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; @&2;@F;Ao;B;CT;Di[.;Eik.;!@-;"I"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; ; F; ;,;;;I"ARGF#eof?;F;[;[[@im.;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;H ;II" overload;F;J0;;;K0;#I" eof?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @N2;[;I"@return [Boolean];T;0; @N2;@F;Mi;N0;[; @N2o;H ;II" overload;F;J0;;;K0;#I"eof;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @N2;[;I"@return [Boolean];T;0; @N2;@F;Mi;N0;[; @N2;[;@J2;0; @N2;@F;Ao;B;CT;Di[.;Eik.;Mi;!@-;"I"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; ; F; ;,;;;I"ARGF#binmode;F;[;[[@i 1;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;H ;II" overload;F;J0;;;K0;#I" binmode;T;IC;";T;[;[;I";T;0; @u2;@F;Mi;N0;[; @u2;[;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; @u2;@F;Ao;B;CT;Di0;Ei1;!@-;"I"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; ; F; ;,;;;I"ARGF#binmode?;F;[;[[@i 1;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;H ;II" overload;F;J0;; ;K0;#I" binmode?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @2;[;I"@return [Boolean];T;0; @2;@F;Mi;N0;[; @2;[;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; @2;@F;Ao;B;CT;Di1;Ei1;Mi;!@-;"I"Zstatic VALUE argf_binmode_p(VALUE argf) { return ARGF.binmode ? Qtrue : Qfalse; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#write;F;[[I"str;T0;[[@i1;T;;;0;[;{;IC;"%Writes _string_ if inplace mode. ;T;[o;H ;II" overload;F;J0;;;K0;#I"write(string);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @2;[;I"@return [Integer];T;0; @2;@F;Mi;N0;[[I" string;T0; @2;[;I"SWrites _string_ if inplace mode. @overload write(string) @return [Integer];T;0; @2;@F;Ao;B;CT;Di1;Ei1;!@-;"I"istatic VALUE argf_write(VALUE argf, VALUE str) { return rb_io_write(argf_write_io(argf), str); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#print;F;[[@0;[[@i;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;H ;II" overload;F;J0;;;K0;#I" print;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @2;[;I"@return [nil];T;0; @2;@F;Mi;N0;[; @2o;H ;II" overload;F;J0;;;K0;#I"print(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @2;[;I"@return [nil];T;0; @2;@F;Mi;N0;[[I"obj;T0[I"...;T0; @2;[;@;0; @2;@F;Ao;B;CT;Dil;Ei;!@-;"I"VALUE 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; } 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; ; F; ;,;;;I"ARGF#putc;F;[[I"ch;T0;[[@i;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;H ;II" overload;F;J0;;;K0;#I"putc(obj);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Object;T; @2;[;I"@return [Object];T;0; @2;@F;Mi;N0;[[I"obj;T0; @2;[;@';0; @2;@F;Ao;B;CT;Di;Ei;!@-;"I"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; ; F; ;,;;;I"ARGF#puts;F;[[@0;[[@i0;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;H ;II" overload;F;J0;;;K0;#I"puts(obj, ...);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @3;[;I"@return [nil];T;0; @3;@F;Mi;N0;[[I"obj;T0[I"...;T0; @3;[;@G;0; @3;@F;Ao;B;CT;Di;Ei-;!@-;"I"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;H ;II" overload;F;J0;;;K0;#I"'printf(format_string [, obj, ...]);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"nil;T; @.3;[;I"@return [nil];T;0; @.3;@F;Mi;N0;[[I"format_string[, obj, ...];T0; @.3;[;@e;0; @.3;@F;Ao;B;CT;Di>;EiD;!@-;"I"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; ; F; ;,;;;I"ARGF#filename;F;[;[[@i0;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;H ;II" overload;F;J0;;;K0;#I" filename;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @K3;[;I"@return [String];T;0; @K3;@F;Mi;N0;[; @K3o;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @K3;[;I"@return [String];T;0; @K3;@F;Mi;N0;[; @K3;[;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; @K3;@F;Ao;B;CT;Di0;Ei0;!@-;"I"Zstatic VALUE argf_filename(VALUE argf) { next_argv(); return ARGF.filename; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#path;F;[;[[@i0;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;H ;II" overload;F;J0;;;K0;#I" filename;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @s3;[;I"@return [String];T;0; @s3;@F;Mi;N0;[; @s3o;H ;II" overload;F;J0;;;K0;#I" path;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @s3;[;I"@return [String];T;0; @s3;@F;Mi;N0;[; @s3;[;@o3;0; @s3;@F;Ao;B;CT;Di0;Ei0;!@-;"I"Zstatic VALUE argf_filename(VALUE argf) { next_argv(); return ARGF.filename; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#file;F;[;[[@i0;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;H ;II" overload;F;J0;;;K0;#I" file;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I"File object;T; @3;[;I"@return [File object];T;0; @3;@F;Mi;N0;[; @3;[;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; @3;@F;Ao;B;CT;Di0;Ei0;!@-;"I"Zstatic VALUE argf_file(VALUE argf) { next_argv(); return ARGF.current_file; };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#skip;F;[;[[@i41;T;;J ;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;H ;II" overload;F;J0;;J ;K0;#I" skip;T;IC;";T;[;[;I";T;0; @3;@F;Mi;N0;[; @3;[;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; @3;@F;Ao;B;CT;Di&1;Ei11;!@-;"I"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; ; F; ;,;;;I"ARGF#close;F;[;[[@iO1;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;H ;II" overload;F;J0;;;K0;#I" close;T;IC;";T;[;[;I";T;0; @3;@F;Mi;N0;[; @3;[;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; @3;@F;Ao;B;CT;Di>1;EiL1;!@-;"I"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; ; F; ;,;;;I"ARGF#closed?;F;[;[[@ib1;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;H ;II" overload;F;J0;;;K0;#I" closed?;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Boolean;T; @3;[;I"@return [Boolean];T;0; @3;@F;Mi;N0;[; @3;[;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; @3;@F;Ao;B;CT;Di[1;Ei`1;Mi;!@-;"I"}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; ; F; ;,;;;I"ARGF#lineno;F;[;[[@iB!;T;;;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;H ;II" overload;F;J0;;;K0;#I" lineno;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @3;[;I"@return [Integer];T;0; @3;@F;Mi;N0;[; @3;[;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; @3;@F;Ao;B;CT;Di5!;Ei@!;!@-;"I"Nstatic VALUE argf_lineno(VALUE argf) { return INT2FIX(ARGF.lineno); };T;#I"static VALUE;T;$To; ; F; ;,;;;I"ARGF#lineno=;F;[[I"val;T0;[[@i-!;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;H ;II" overload;F;J0;;;K0;#I"lineno=(integer);T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Integer;T; @4;[;I"@return [Integer];T;0; @4;@F;Mi;N0;[[I" integer;T0; @4;[;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; @4;@F;Ao;B;CT;Di!;Ei+!;!@-;"I"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; ; F; ;,;;;I"ARGF#inplace_mode;F;[;[[@i~1;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;H ;II" overload;F;J0;;;K0;#I"inplace_mode;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" String;T; @64;[;I"@return [String];T;0; @64;@F;Mi;N0;[; @64;[;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; @64;@F;Ao;B;CT;Div1;Ei|1;!@-;"I"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; ; F; ;,;;;I"ARGF#inplace_mode=;F;[[I"val;T0;[[@i1;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;H ;II" overload;F;J0;;;K0;#I"inplace_mode=(ext);T;IC;";T;[;[;I";T;0; @Q4;@F;Mi;N0;[[I"ext;T0; @Q4;[;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; @Q4;@F;Ao;B;CT;Di1;Ei1;!@-;"I"]static VALUE argf_inplace_mode_set(VALUE argf, VALUE val) { if (rb_safe_level() >= 1 && OBJ_TAINTED(val)) rb_insecure_operation(); 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; ; F; ;,;;;I"ARGF#external_encoding;F;[;[[@i-;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;H ;II" overload;F;J0;;;K0;#I"external_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @k4;[;I"@return [Encoding];T;0; @k4;@F;Mi;N0;[; @k4;[;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; @k4;@F;Ao;B;CT;Di}-;Ei-;!@-;"I"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; ; F; ;,;;;I"ARGF#internal_encoding;F;[;[[@i-;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;H ;II" overload;F;J0;;;K0;#I"internal_encoding;T;IC;";T;[o;L ;II" return;F;JI";T;0;K[I" Encoding;T; @4;[;I"@return [Encoding];T;0; @4;@F;Mi;N0;[; @4;[;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; @4;@F;Ao;B;CT;Di-;Ei-;!@-;"I"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; ; F; ;,;;;I"ARGF#set_encoding;F;[[@0;[[@i-;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;H ;II" overload;F;J0;;;K0;#I"set_encoding(ext_enc);T;IC;";T;[;[;I";T;0; @4;@F;Mi;N0;[[I" ext_enc;T0; @4o;H ;II" overload;F;J0;;;K0;#I"$set_encoding("ext_enc:int_enc");T;IC;";T;[;[;I";T;0; @4;@F;Mi;N0;[[""ext_enc:" int_enc"; @4o;H ;II" overload;F;J0;;;K0;#I"#set_encoding(ext_enc, int_enc);T;IC;";T;[;[;I";T;0; @4;@F;Mi;N0;[[I" ext_enc;T0[I" int_enc;T0; @4o;H ;II" overload;F;J0;;;K0;#I")set_encoding("ext_enc:int_enc", opt);T;IC;";T;[;[;I";T;0; @4;@F;Mi;N0;[[""ext_enc:" int_enc"[I"opt;T0; @4o;H ;II" overload;F;J0;;;K0;#I"(set_encoding(ext_enc, int_enc, opt);T;IC;";T;[;[;I";T;0; @4;@F;Mi;N0;[[I" ext_enc;T0[I" int_enc;T0[I"opt;T0; @4;[;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; @4;@F;Ao;B;CT;Di-;Ei-;!@-;"I";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;2 ;30;40;50;;1;!@;7@C;F0;&@-;)IC;*{;IC;*{;+T;,IC;*{;+T;+T;-{@-;h;.[;[[@iU2[@i3;T;;;;0;;;[;{;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;Ao;B;CT;DiU2;Eiz2;Mi;!@;I" ARGF;F;1@<;"I"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@.:ARGF#to_i@-.:ARGF#to_io@T.:ARGF#to_write_io@j.:ARGF#each@.:ARGF#each_line@.:ARGF#each_byte@.:ARGF#each_char@/:ARGF#each_codepoint@@/:ARGF#lines@c/:ARGF#bytes@r/:ARGF#chars@/:ARGF#codepoints@/:ARGF#read@/:ARGF#readpartial@/:ARGF#read_nonblock@/:ARGF#readlines@0:ARGF#to_a@N0:ARGF#gets@0:ARGF#readline@0:ARGF#getc@ 1:ARGF#getbyte@)1:ARGF#readchar@E1:ARGF#readbyte@a1:ARGF#tell@|1:ARGF#seek@1:ARGF#rewind@1: ARGF#pos@1:ARGF#pos=@2: ARGF#eof@&2:ARGF#eof?@N2:ARGF#binmode@u2:ARGF#binmode?@2:ARGF#write@2:ARGF#print@2:ARGF#putc@2:ARGF#puts@3:ARGF#printf@.3:ARGF#filename@K3:ARGF#path@s3:ARGF#file@3:ARGF#skip@3:ARGF#close@3:ARGF#closed?@3:ARGF#lineno@3:ARGF#lineno=@4:ARGF#inplace_mode@64:ARGF#inplace_mode=@Q4:ARGF#external_encoding@k4:ARGF#internal_encoding@4:ARGF#set_encoding@4:File#initialize@f: Bug::VM@5:Bug::VM.register_at_exit@5;@T:Array#pack@V:String#unpack@2:String#unpack1@2:)Bug#tracepoint_track_objspace_events@5:)Bug.tracepoint_track_objspace_events@ 6:6Bug#tracepoint_specify_normal_and_internal_events@6:6Bug.tracepoint_specify_normal_and_internal_events@6:Kernel#load@W :Kernel#require@y :Kernel#require_relative@ :Module#autoload@:Module#autoload?@:Kernel#autoload@ :Kernel#autoload?@ :'Bug::ScanArgs#after_gc_start_hook=@5:'Bug::ScanArgs.after_gc_start_hook=@5;@:RubyVM.stat@:RubyVM::MJIT@J:RubyVM::MJIT.enabled?@L:RubyVM::MJIT.pause@]:RubyVM::MJIT.resume@i:$RubyVM.USAGE_ANALYSIS_INSN_STOP@:'RubyVM.USAGE_ANALYSIS_OPERAND_STOP@:(RubyVM.USAGE_ANALYSIS_REGISTER_STOP@:RubyVM::OPTS@:RubyVM::INSTRUCTION_NAMES@:RubyVM::DEFAULT_PARAMS@:RubyVM.SDR@:RubyVM.NSDR@;@: RubyVM.resolve_feature_path@:Bug::TypedData@%6:Bug::TypedData.check@'6:Bug::TypedData.make@66:#Test_PathToClass.path_to_classo; ; F; ;;;;I"#Test_PathToClass.path_to_class;T;[[I" path;T0;[[I"-ext/-test-/path_to_class/path_to_class.c;Ti;T;:path_to_class;0;[;{;IC;" ;T;[;[;@;0; @5;!o;2 ;30;40;50;:Test_PathToClass;!@;70;F0;"I"_static VALUE path_to_class(VALUE klass, VALUE path) { return rb_path_to_class(path); };T;#I"static VALUE;T;$T:)Test_PathToClass#associate_encoding!o; ; F; ;,;;;I")Test_PathToClass#associate_encoding!;T;[[I"enc;T0;[[@ti ;T;:associate_encoding!;0;[;{;IC;" ;T;[;[;@;0; @5;!@5;"I"qVALUE bug_str_enc_associate(VALUE str, VALUE enc) { return rb_enc_associate(str, rb_to_encoding(enc)); };T;#I" VALUE;T;$T: Test_PathToClass.rb_str_dupo; ; F; ;;;;I" Test_PathToClass.rb_str_dup;T;[[I"str;T0;[[@ti ;T;:rb_str_dup;0;[;{;IC;" ;T;[;[;@;0; @5;!@5;"I"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;$T;B@:Range#initialize@:Range#initialize_copy@ : Range#==@ :Range#===@? :Range#eql?@^ :Range#hash@} :Range#each@ :Range#step@ : Range#%@ :Range#bsearch@M :Range#begin@h :Range#end@ :Range#first@ :Range#last@ :Range#min@ :Range#max@G :Range#size@ :Range#to_a@ :Range#entries@ :Range#to_s@ :Range#inspect@ :Range#exclude_end?@: :Range#member?@U :Range#include?@ :Range#cover?@ :Test_PathToClass#ellipsizeo; ; F; ;,;;;I"Test_PathToClass#ellipsize;T;[[I"len;T0;[[I""ext/-test-/string/ellipsize.c;Ti;T;:ellipsize;0;[;{;IC;" ;T;[;[;@;0; @-5;!@5;"I"nstatic VALUE bug_str_ellipsize(VALUE str, VALUE len) { return rb_str_ellipsize(str, NUM2LONG(len)); };T;#I"static VALUE;T;$T:Test_PathToClass.capacityo; ; F; ;;;;I"Test_PathToClass.capacity;T;[[I"str;T0;[[I"!ext/-test-/string/capacity.c;Ti ;T;: capacity;0;[;{;IC;" ;T;[;[;@;0; @<5;!@5;"I"static VALUE bug_str_capacity(VALUE klass, VALUE str) { return STR_EMBED_P(str) ? INT2FIX(RSTRING_EMBED_LEN_MAX) : \ STR_SHARED_P(str) ? INT2FIX(0) : \ LONG2FIX(RSTRING(str)->as.heap.aux.capa); };T;#I"static VALUE;T;$T:&Test_PathToClass#normalize_ospatho; ; F; ;,;;;I"&Test_PathToClass#normalize_ospath;T;[;[[I""ext/-test-/string/normalize.c;Ti ;T;:normalize_ospath;0;[;{;IC;" ;T;[;[;@;0; @K5;!@5;"I"ystatic VALUE normalize_ospath(VALUE str) { return rb_str_normalize_ospath(RSTRING_PTR(str), RSTRING_LEN(str)); };T;#I"static VALUE;T;$T:Test_PathToClass.nofreeo; ; F; ;;;;I"Test_PathToClass.nofree;T;[;[[I"ext/-test-/string/nofree.c;Ti;T;: nofree;0;[;{;IC;" ;T;[;[;@;0; @X5;!@5;"I"OVALUE bug_str_nofree(VALUE self) { return rb_str_new_cstr("abcdef"); };T;#I" VALUE;T;$T:Test_PathToClass.buf_newo; ; F; ;;;;I"Test_PathToClass.buf_new;T;[[I"len;T0;[[@ti ;T;: buf_new;0;[;{;IC;" ;T;[;[;@;0; @e5;!@5;"I"fstatic VALUE bug_str_buf_new(VALUE self, VALUE len) { return rb_str_buf_new(NUM2LONG(len)); };T;#I"static VALUE;T;$T:Test_PathToClass#cstr_termo; ; F; ;,;;;I"Test_PathToClass#cstr_term;T;[;[[@0ti ;T;;;0;[;{;IC;" ;T;[;[;@;0; @s5;!@5;"I")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;$T;i@ ;@;@w;@;@: Proc.new@:Proc#call@: Proc#[]@: Proc#===@:Proc#yield@.:Proc#to_proc@<:Proc#arity@W:Proc#clone@r: Proc#dup@:Proc#hash@:Proc#to_s@:Proc#inspect@:Proc#lambda?@:Proc#binding@:Proc#curry@: Proc#<<@+: Proc#>>@J:Proc#source_location@i:Proc#parameters@:LocalJumpError#exit_value@y:LocalJumpError#reason@:Kernel#proc@ :Kernel#lambda@ :Method#==@ :Method#eql?@ :Method#hash@M :Method#clone@h :Method#call@~ :Method#===@ :Method#curry@ :Method#<<@ :Method#>>@):Method#[]@H:Method#arity@x:Method#inspect@:Method#to_s@:Method#to_proc@:Method#receiver@:Method#name@:Method#original_name@.:Method#owner@D:Method#unbind@Z:Method#source_location@p:Method#parameters@:Method#super_method@:Object#method@:Object#public_method@:Object#singleton_method@:UnboundMethod#==@:UnboundMethod#eql?@:UnboundMethod#hash@+:UnboundMethod#clone@E:UnboundMethod#arity@Z:UnboundMethod#inspect@t:UnboundMethod#to_s@:UnboundMethod#name@: UnboundMethod#original_name@:UnboundMethod#owner@:UnboundMethod#bind@:"UnboundMethod#source_location@:UnboundMethod#parameters@6:UnboundMethod#super_method@P:Module#instance_method@:"Module#public_instance_method@:Module#define_method@:#Object#define_singleton_method@;@:Binding#clone@:Binding#dup@:Binding#eval@:Binding#local_variables@:Binding#local_variable_get@ :Binding#local_variable_set@(:$Binding#local_variable_defined?@K:Binding#receiver@j:Binding#source_location@:Kernel#binding@6 :Test_PathToClass#modify!o; ; F; ;,;;;I"Test_PathToClass#modify!;T;[;[[@!ti;T;: modify!;0;[;{;IC;" ;T;[;[;@;0; @5;!@5;"I"PVALUE bug_str_modify(VALUE str) { rb_str_modify(str); return str; };T;#I" VALUE;T;$T;@:Comparable#==@:Comparable#>@;:Comparable#>=@Z:Comparable#<@y:Comparable#<=@:Comparable#between?@:Comparable#clamp@:%Test_PathToClass#enc_str_buf_cato; ; F; ;,;;;I"%Test_PathToClass#enc_str_buf_cat;T;[[I" str2;T0;[[I"(ext/-test-/string/enc_str_buf_cat.c;Ti ;T;:enc_str_buf_cat;0;[;{;IC;" ;T;[;[;@;0; @5;!@5;"I"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;$T:RubyVM::AbstractSyntaxTree@:%RubyVM::AbstractSyntaxTree::Node@;@;@;@:*RubyVM::AbstractSyntaxTree::Node#type@:2RubyVM::AbstractSyntaxTree::Node#first_lineno@ :2RubyVM::AbstractSyntaxTree::Node#first_column@':1RubyVM::AbstractSyntaxTree::Node#last_lineno@B:1RubyVM::AbstractSyntaxTree::Node#last_column@]:.RubyVM::AbstractSyntaxTree::Node#children@x:-RubyVM::AbstractSyntaxTree::Node#inspect@:Bug::String@g6;@:Kernel#eval@Q :Kernel#local_variables@o :Kernel#iterator?@ :Kernel#block_given?@ :Kernel#catch@ :Kernel#throw@ :Kernel#loop@:BasicObject#instance_eval@:BasicObject#instance_exec@:BasicObject#method_missing@:BasicObject#__send__@:Object#send@ :Object#public_send@l:Module#module_exec@$:Module#class_exec@[:Module#module_eval@:Module#class_eval@:"UncaughtThrowError#initialize@:UncaughtThrowError#tag@:UncaughtThrowError#value@:UncaughtThrowError#to_s@:Bug::String#coderange@i6:Bug::String#coderange_scan@x6;@:;@:Enumerator::Chain@<:#Enumerator::ArithmeticSequence@:Object#to_enum@:Object#enum_for@:Enumerator#initialize@u:Enumerator#initialize_copy@:Enumerator#each@:Enumerator#each_with_index@: Enumerator#each_with_object@#:Enumerator#with_index@g:Enumerator#with_object@:Enumerator#next_values@:Enumerator#peek_values@:Enumerator#next@ :Enumerator#peek@&:Enumerator#feed@A:Enumerator#rewind@^:Enumerator#inspect@t:Enumerator#size@:Enumerator#+@;1@C:Enumerable#chain@C:Enumerator::Lazy@:Enumerable#lazy@C: Enumerator::Lazy#initialize@:Enumerator::Lazy#to_enum@:Enumerator::Lazy#enum_for@7:Enumerator::Lazy#map@:Enumerator::Lazy#collect@:Enumerator::Lazy#flat_map@:$Enumerator::Lazy#collect_concat@:Enumerator::Lazy#select@:Enumerator::Lazy#find_all@:Enumerator::Lazy#filter@:Enumerator::Lazy#reject@:Enumerator::Lazy#grep@:Enumerator::Lazy#grep_v@(:Enumerator::Lazy#zip@6:Enumerator::Lazy#take@C: Enumerator::Lazy#take_while@Q:Enumerator::Lazy#drop@]: Enumerator::Lazy#drop_while@k:Enumerator::Lazy#lazy@w:Enumerator::Lazy#chunk@:"Enumerator::Lazy#slice_before@:!Enumerator::Lazy#slice_after@: Enumerator::Lazy#slice_when@:!Enumerator::Lazy#chunk_while@:Enumerator::Lazy#uniq@:Enumerator::Lazy#to_a@:Enumerator::Lazy#force@:StopIteration#result@:Enumerator::Generator@:%Enumerator::Generator#initialize@:*Enumerator::Generator#initialize_copy@ :Enumerator::Generator#each@0:Enumerator::Yielder@N:#Enumerator::Yielder#initialize@P:Enumerator::Yielder#yield@^:Enumerator::Yielder#<<@n:!Enumerator::Chain#initialize@>:&Enumerator::Chain#initialize_copy@]:Enumerator::Chain#each@m:Enumerator::Chain#size@:Enumerator::Chain#rewind@:Enumerator::Chain#inspect@:)Enumerator::ArithmeticSequence#begin@:'Enumerator::ArithmeticSequence#end@ :0Enumerator::ArithmeticSequence#exclude_end?@:(Enumerator::ArithmeticSequence#step@ :)Enumerator::ArithmeticSequence#first@):(Enumerator::ArithmeticSequence#last@U:+Enumerator::ArithmeticSequence#inspect@:&Enumerator::ArithmeticSequence#==@:'Enumerator::ArithmeticSequence#===@:(Enumerator::ArithmeticSequence#eql?@:(Enumerator::ArithmeticSequence#hash@:(Enumerator::ArithmeticSequence#each@:(Enumerator::ArithmeticSequence#size@5:Bug::String.fstring@6:Bug::String#set_len@6:Bug::String#qsort!@6:Bug#start@7:Bug.start@+7: Bug.s@17: Bug.v@@7: Bug.q@N7: Bug.call@\7:Bug.sncount@i7:(Kernel#register_sample_bug_reporter@6;q@ `:Struct.new@ `:Struct#initialize@r`:Struct#initialize_copy@`:Struct#==@`:Struct#eql?@`:Struct#hash@`:Struct#inspect@`:Struct#to_s@ a:Struct#to_a@a:Struct#to_h@@a:Struct#values@na:Struct#size@a:Struct#length@a:Struct#each@a:Struct#each_pair@b:Struct#[]@+b:Struct#[]=@Yb:Struct#select@b:Struct#filter@b:Struct#values_at@c:Struct#members@.c:Struct#dig@Ic:Thread#__runnable_sleep__@:Integer#gcd_normal@Ck:Integer#gcd_gmp@Rk:*RubyVM::InstructionSequence.iseq_load@:;@:Ripper::Version@:Ripper#initialize@:Ripper#parse@:Ripper#column@:Ripper#filename@:Ripper#lineno@:Ripper#state@::Ripper#end_seen?@V:Ripper#encoding@r:Ripper#yydebug@:Ripper#yydebug=@:Ripper#error?@:Object#assert_Qundef@[:Object#rawVALUE@p:Object#validate_object@:Ripper.dedent_string@:Ripper#dedent_string@:Ripper.lex_state_name@(;@0:Bug::String::Yield@6:#Bug::String::Yield#yield_block@6:Bug::String::Breakable@6:&Bug::String::Breakable#iter_break@6:&Bug::String::Breakable.iter_break@6:,Bug::String::Breakable#iter_break_value@6:,Bug::String::Breakable.iter_break_value@6:Bug::Iter@w7:Bug::Iter#delete!@y7:Thread::Backtrace@: 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::Hash@7;@=;@:Thread.new@+:Thread.start@;:Thread.fork@i:Thread.main@:Thread.current@:Thread.stop@‚:Thread.kill@݂:Thread.exit@:Thread.pass@ :Thread.list@(:Thread.abort_on_exception@C:Thread.abort_on_exception=@^:Thread.report_on_exception@}: Thread.report_on_exception=@:Thread.DEBUG@:Thread.DEBUG=@҃:Thread.handle_interrupt@:Thread.pending_interrupt?@ :Thread#pending_interrupt?@&:Thread#initialize@C:Thread#raise@S:Thread#join@~:Thread#value@:Thread#kill@:Thread#terminate@:Thread#exit@#:Thread#run@W:Thread#wakeup@m:Thread#[]@:Thread#[]=@:Thread#fetch@ą:Thread#key?@:Thread#keys@$:Thread#priority@?:Thread#priority=@Z:Thread#status@t:Thread#thread_variable_get@:Thread#thread_variable_set@:Thread#thread_variables@φ:Thread#thread_variable?@:Thread#alive?@ :Thread#stop?@$:Thread#abort_on_exception@?:Thread#abort_on_exception=@Z:Thread#report_on_exception@y: Thread#report_on_exception=@:Thread#safe_level@:Thread#group@·:Thread#backtrace@:Thread#backtrace_locations@:Thread#name@:Thread#name=@9:Thread#to_s@X:Thread#inspect@p:ThreadGroup#list@?:ThreadGroup#enclose@Z:ThreadGroup#enclosed?@p:ThreadGroup#add@:ThreadGroup::Default@:Marshal::InternalIVar@:%Marshal::InternalIVar#initialize@:!Marshal::InternalIVar#normal@:#Marshal::InternalIVar#internal@:Marshal::UsrMarshal@9:#Marshal::UsrMarshal#initialize@;:Marshal::UsrMarshal#value@J:%Marshal::UsrMarshal#marshal_load@V:%Marshal::UsrMarshal#marshal_dump@d:Bug::Hash.nano_new@7:Bug::Hash.timespec_new@7:Bug::Hash.timespec_now@7:%Bug::Hash.reset_leap_second_info@7:Bug::Time@O:Bug::Method@C_:Enumerable#to_a@C:Enumerable#entries@C:Enumerable#to_h@+D:Enumerable#sort@[D:Enumerable#sort_by@D:Enumerable#grep@D:Enumerable#grep_v@D:Enumerable#count@E:Enumerable#find@TE:Enumerable#detect@E:Enumerable#find_index@E:Enumerable#find_all@/F:Enumerable#select@F:Enumerable#filter@F:Enumerable#reject@AG:Enumerable#collect@iG:Enumerable#map@G:Enumerable#flat_map@G:Enumerable#collect_concat@.H:Enumerable#inject@oH:Enumerable#reduce@I:Enumerable#partition@I:Enumerable#group_by@I:Enumerable#first@I:Enumerable#all?@(J:Enumerable#any?@XJ:Enumerable#one?@J:Enumerable#none?@J:Enumerable#min@J:Enumerable#max@;K:Enumerable#minmax@K:Enumerable#min_by@K:Enumerable#max_by@L:Enumerable#minmax_by@JL:Enumerable#member?@rL:Enumerable#include?@L:Enumerable#each_with_index@L:Enumerable#reverse_each@L:Enumerable#each_entry@(M:Enumerable#each_slice@QM:Enumerable#each_cons@}M: Enumerable#each_with_object@M:Enumerable#zip@M:Enumerable#take@ N:Enumerable#take_while@(N:Enumerable#drop@PN:Enumerable#drop_while@oN:Enumerable#cycle@N:Enumerable#chunk@N:Enumerable#slice_before@N:Enumerable#slice_after@O:Enumerable#slice_when@-O:Enumerable#chunk_while@IO:Enumerable#sum@eO:Enumerable#uniq@O:Bug::ScanArgs::Stat@%5:Bug::ScanArgs::Stat#for_fd@'5:Bug::ScanArgs::Stat.for_fd@75:!Bug::ScanArgs::Stat#for_path@=5:!Bug::ScanArgs::Stat.for_path@L5:Bug::File@q_;@: Dir.open@:Dir.foreach@4 :Dir.entries@ :Dir.each_child@ :Dir.children@!:Dir#initialize@6!:Dir#fileno@f!: Dir#path@!:Dir#to_path@!:Dir#inspect@!: Dir#read@!: Dir#each@ ":Dir#each_child@3":Dir#children@[":Dir#rewind@v": Dir#tell@": Dir#seek@": Dir#pos@": Dir#pos=@":Dir#close@#:Dir.chdir@9#:Dir.getwd@k#: Dir.pwd@#:Dir.chroot@#:Dir.mkdir@#:Dir.rmdir@#:Dir.delete@4$:Dir.unlink@p$: Dir.home@$: Dir.glob@$: Dir.[]@ %:Dir.exist?@'%:Dir.exists?@C%:Dir.empty?@b%:File.fnmatch@:File.fnmatch?@̭:Bug::File::Fs@s_:Bug::File::Fs#fsname@u_:Bug::File::Fs.fsname@_:Bug::File::Fs#noatime?@_:Bug::File::Fs.noatime?@_:#Thread#__infinite_loop_dlsym__@{:Object#respond_to?@:Object#respond_to_missing?@:Module#remove_method@2:Module#undef_method@_:Module#alias_method@:Module#public@:Module#protected@:Module#private@+:Module#module_function@i:Module#method_defined?@:"Module#public_method_defined?@:#Module#private_method_defined?@:%Module#protected_method_defined?@3:Module#public_class_method@f: Module#private_class_method@:Bug::Method#rstruct_len@E_;@7: Hash.[]@7:Hash.try_convert@8:Hash#initialize@;8:Hash#initialize_copy@j8:Hash#rehash@z8:Hash#to_hash@8:Hash#to_h@8:Hash#to_a@8:Hash#inspect@8:Hash#to_s@9:Hash#to_proc@$9: Hash#==@?9: Hash#[]@^9:Hash#hash@x9:Hash#eql?@9:Hash#fetch@9: Hash#[]=@9:Hash#store@9:Hash#default@9:Hash#default=@::Hash#default_proc@4::Hash#default_proc=@O:: Hash#key@i::Hash#index@::Hash#size@::Hash#length@::Hash#empty?@::Hash#each_value@::Hash#each_key@%;:Hash#each_pair@M;:Hash#each@;:Hash#transform_keys@;:Hash#transform_keys!@;:Hash#transform_values@<:Hash#transform_values!@B<:Hash#keys@j<:Hash#values@<:Hash#values_at@<:Hash#fetch_values@<:Hash#shift@<:Hash#delete@=:Hash#delete_if@;=:Hash#keep_if@d=:Hash#select@=:Hash#select!@=:Hash#filter@>:Hash#filter!@Z>:Hash#reject@>:Hash#reject!@>:Hash#slice@>:Hash#clear@?:Hash#invert@+?:Hash#update@A?:Hash#replace@?:Hash#merge!@?:Hash#merge@=@:Hash#assoc@w@:Hash#rassoc@@:Hash#flatten@@:Hash#compact@@:Hash#compact!@@:Hash#include?@A:Hash#member?@`A:Hash#has_key?@A:Hash#has_value?@A:Hash#key?@$B:Hash#value?@oB:Hash#compare_by_identity@B:Hash#compare_by_identity?@B:Hash#any?@B: Hash#dig@C: Hash#<=@"C: Hash#<@AC: Hash#>=@`C: Hash#>@C;@%:Bug::Method#get@R_:Encoding::Converter@<:'Encoding::UndefinedConversionError@D:'Encoding::InvalidByteSequenceError@:%Encoding::ConverterNotFoundError@:String#encode@ 3:String#encode!@I3;@>;@n:#Encoding::Converter#initialize@: Encoding::Converter#inspect@:!Encoding::Converter#convpath@:(Encoding::Converter#source_encoding@ :-Encoding::Converter#destination_encoding@%:*Encoding::Converter#primitive_convert@@: Encoding::Converter#convert@:Encoding::Converter#finish@:*Encoding::Converter#primitive_errinfo@:&Encoding::Converter#insert_output@: Encoding::Converter#putback@:#Encoding::Converter#last_error@%:$Encoding::Converter#replacement@A:%Encoding::Converter#replacement=@\:Encoding::Converter#==@v:&Encoding::Converter::INVALID_MASK@:)Encoding::Converter::INVALID_REPLACE@:$Encoding::Converter::UNDEF_MASK@:'Encoding::Converter::UNDEF_REPLACE@:+Encoding::Converter::UNDEF_HEX_CHARREF@:'Encoding::Converter::PARTIAL_INPUT@:&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@%:@:Array#slice@:Array#slice!@:Array#assoc@\:Array#rassoc@{: Array#+@: Array#*@: Array#-@: Array#&@: Array#|@ :Array#max@?:Array#min@:Array#uniq@:Array#uniq!@:Array#compact@A:Array#compact!@\:Array#flatten@x:Array#flatten!@:Array#count@:Array#shuffle!@ :Array#shuffle@9:Array#sample@e:Array#cycle@:Array#permutation@:Array#combination@7:Array#repeated_permutation@j:Array#repeated_combination@:Array#product@:Array#take@:Array#take_while@%:Array#drop@R:Array#drop_while@q:Array#bsearch@:Array#bsearch_index@:Array#any?@:Array#all?@ :Array#none?@::Array#one?@j:Array#dig@:Array#sum@:Bug#postponed_job_register@c:Bug.postponed_job_register@c:#Bug#postponed_job_register_one@c:#Bug.postponed_job_register_one@c:"Bug#postponed_job_call_direct@c:"Bug.postponed_job_call_direct@ d:Bug::Struct.class2name@_;)@&;+@t&;,@J':Fiber.yield@v&:Fiber#initialize@&:Fiber#resume@&:Fiber#to_s@&:Fiber#inspect@&:Continuation#call@&:Continuation#[]@<&:Kernel#callcc@:Fiber#transfer@&:Fiber#alive?@':Fiber.current@"':Bug::Class@d:Integer#bignum?@`k:Integer#fixnum?@pk:Integer#to_bignum@k:Integer#positive_pow@k:Process::Status@)|:Process::Sys@:Process::UID@:Process::GID@:Kernel#exec@:Kernel#fork@:Kernel#exit!@:Kernel#system@:Kernel#spawn@:Kernel#sleep@A:Kernel#exit@_:Kernel#abort@:Process::WNOHANG@}:Process::WUNTRACED@}:Process.exec@ ~:Process.fork@#~:Process.spawn@,~:Process.exit!@N~:Process.exit@g~:Process.abort@~:Process.last_status@~:Process#kill@~:Process.kill@~:Process#wait@:Process.wait@Y:Process#wait2@:Process.wait2@:Process#waitpid@:Process.waitpid@7:Process#waitpid2@q:Process.waitpid2@:Process#waitall@Ҁ:Process.waitall@:Process#detach@:Process.detach@:Process::Waiter@,:Process::Waiter#pid@.:Process::Status#==@+|:Process::Status#&@J|:Process::Status#>>@i|:Process::Status#to_i@|:Process::Status#to_s@|:Process::Status#inspect@|:Process::Status#pid@|:Process::Status#stopped?@}:Process::Status#stopsig@}:Process::Status#signaled?@8}:Process::Status#termsig@S}:Process::Status#exited?@o}:Process::Status#exitstatus@}:Process::Status#success?@}:Process::Status#coredump?@}:Process#pid@:Process.pid@:Process#ppid@̈:Process.ppid@:Process#getpgrp@:Process.getpgrp@:Process#setpgrp@*:Process.setpgrp@D:Process#getpgid@Y:Process.getpgid@w:Process#setpgid@:Process.setpgid@:Process#getsid@ɉ:Process.getsid@:Process#setsid@:Process.setsid@1:Process#getpriority@F:Process.getpriority@h:Process#setpriority@:Process.setpriority@:Process::PRIO_PROCESS@Š:Process::PRIO_PGRP@Ί:Process::PRIO_USER@ڊ:Process#getrlimit@:Process.getrlimit@:Process#setrlimit@:Process.setrlimit@M:Process::RLIM_SAVED_MAX@y:Process::RLIM_INFINITY@: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@9:Process::RLIMIT_SIGPENDING@E:Process::RLIMIT_STACK@Q:Process#uid@]:Process.uid@:Process#uid=@:Process.uid=@ތ:Process#gid@:Process.gid@):Process#gid=@X:Process.gid=@v:Process#euid@:Process.euid@:Process#euid=@:Process.euid=@ :Process#egid@:Process.egid@O:Process#egid=@~:Process.egid=@:Process#initgroups@:Process.initgroups@:Process#groups@Ɏ:Process.groups@:Process#groups=@:Process.groups=@:Process#maxgroups@-:Process.maxgroups@G:Process#maxgroups=@\:Process.maxgroups=@z:Process#daemon@:Process.daemon@:Process#times@:Process.times@:Process::CLOCK_REALTIME@:Process::CLOCK_MONOTONIC@#:&Process::CLOCK_PROCESS_CPUTIME_ID@0:%Process::CLOCK_THREAD_CPUTIME_ID@=:Process::CLOCK_VIRTUAL@I:Process::CLOCK_PROF@U:!Process::CLOCK_REALTIME_FAST@a:$Process::CLOCK_REALTIME_PRECISE@m:#Process::CLOCK_REALTIME_COARSE@y:"Process::CLOCK_REALTIME_ALARM@:"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_gettime@-:Process.clock_gettime@J:Process#clock_getres@a:Process.clock_getres@~:Struct::Tms@ic:Process::UID#rid@;d@ˑ:Process::GID#rid@;h@:Process::UID#eid@;l@-:Process::GID#eid@!;p@U:"Process::UID#change_privilege@[;@y:"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?@<;@V: Process::UID#sid_available?@A;@[: Process::GID#sid_available?@k;@:Process::UID#switch@p:Process::UID.switch@}:Process::GID#switch@:Process::GID.switch@:Process::UID#from_name@;@:Process::GID#from_name@;@ƕ:Process::Sys#getuid@;e@:Process::Sys#geteuid@K;m@:Process::Sys#getgid@;i@:Process::Sys#getegid@:Process::Sys.getegid@C:Process::Sys#setuid@q;@:Process::Sys#setgid@;@ė:Process::Sys#setruid@ۗ;@:Process::Sys#setrgid@;@.:Process::Sys#seteuid@E;@c:Process::Sys#setegid@z;@:Process::Sys#setreuid@;@ј:Process::Sys#setregid@;@ :Process::Sys#setresuid@%;@K:Process::Sys#setresgid@f;@:Process::Sys#issetugid@;@:Bug::Integer@%d;.@_';/@';@7;0@';1@G(;3@(;4@(;@&;@;5@(;@{;6@;);7@O);8@|);9@);:@);=@*;>@*;?@*;@@+;A@"+;C@6+;@:!Encoding::CompatibilityError@;D@+:NameError::message@);#@K:Exception.exception@M:Exception.to_tty?@\:Exception#exception@w:Exception#initialize@:Exception#==@:Exception#to_s@:Exception#message@:Exception#full_message@:Exception#inspect@:Exception#backtrace@7:"Exception#backtrace_locations@R:Exception#set_backtrace@m:Exception#cause@:SystemExit#initialize@':SystemExit#status@':SystemExit#success?@(:KeyError#initialize@(:KeyError#receiver@(:KeyError#key@):SyntaxError#initialize@Q):NameError#initialize@):NameError#name@*:NameError#receiver@;*:NameError#local_variables@V*:NameError::message#==@):NameError::message#to_str@):NameError::message#_dump@):NameError::message._load@):NoMethodError#initialize@*:NoMethodError#args@*: NoMethodError#private_call?@*:SystemCallError#initialize@8+:SystemCallError#errno@S+:SystemCallError.===@n+:Warning#warn@a':Warning::buffer@':Warning::buffer#write@':Kernel#warn@:Bug::Integer::MyInteger@'d: Bug::Integer::MyInteger.new@)d;R@+:Num2int#NUM2SHORT@+:Num2int.NUM2SHORT@+:Num2int#NUM2USHORT@+:Num2int.NUM2USHORT@+:Num2int#NUM2INT@+:Num2int.NUM2INT@+:Num2int#NUM2UINT@+:Num2int.NUM2UINT@,:Num2int#NUM2LONG@ ,:Num2int.NUM2LONG@,:Num2int#NUM2ULONG@,:Num2int.NUM2ULONG@.,:Num2int#NUM2LL@4,:Num2int.NUM2LL@C,:Num2int#NUM2ULL@I,:Num2int.NUM2ULL@X,:Num2int#FIX2SHORT@^,:Num2int.FIX2SHORT@m,:Num2int#FIX2INT@s,:Num2int.FIX2INT@,:Num2int#FIX2UINT@,:Num2int.FIX2UINT@,:Num2int#FIX2LONG@,:Num2int.FIX2LONG@,:Num2int#FIX2ULONG@,:Num2int.FIX2ULONG@,:Kernel#raise@:Kernel#fail@.:Kernel#global_variables@:Kernel#__method__@:Kernel#__callee__@:Kernel#__dir__@:Module#include@:Module#prepend@:Module#append_features@:Module#extend_object@:Module#prepend_features@%:Module#refine@?:Module#using@\:Module.used_modules@y:Module.nesting@:Module.constants@:Object#extend@:Kernel#trace_var@:Kernel#untrace_var@:Array#__resize__@;S@,:MemoryStatus#_updateo; ; F; ;,;;;I"MemoryStatus#_update;T;[;[[@,i;T;: _update;0;[;{;IC;" ;T;[;[;@;0; @5;!o;2 ;30;40;50;:MemoryStatus;!@;70;F0;"I" static VALUE read_status(VALUE self) { VALUE size = INT2FIX(0); #if defined __APPLE__ 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 VALUE peak; PROCESS_MEMORY_COUNTERS c; c.cb = sizeof(c); if (!GetProcessMemoryInfo(GetCurrentProcess(), &c, c.cb)) return Qnil; size = SIZET2NUM(c.PagefileUsage); peak = SIZET2NUM(c.PeakWorkingSetSize); rb_struct_aset(self, INT2FIX(1), peak); #endif rb_struct_aset(self, INT2FIX(0), size); return self; };T;#I"static VALUE;T;$T:Bug.load_protect@u;_@,;`@53;a@F3:GDBM.open@,:GDBM#initialize@-:GDBM#close@>-:GDBM#closed?@Y-: GDBM#[]@t-:GDBM#fetch@-: GDBM#[]=@-:GDBM#store@-:GDBM#index@-: GDBM#key@.:GDBM#select@ .:GDBM#values_at@A.:GDBM#length@a.:GDBM#size@.:GDBM#empty?@.:GDBM#each@.:GDBM#each_value@.:GDBM#each_key@/:GDBM#each_pair@/:GDBM#keys@8/:GDBM#values@S/:GDBM#shift@n/:GDBM#delete@/:GDBM#delete_if@/:GDBM#reject!@/:GDBM#reject@/:GDBM#clear@0:GDBM#invert@20:GDBM#update@M0:GDBM#replace@g0:GDBM#reorganize@0:GDBM#sync@0:GDBM#cachesize=@0:GDBM#fastmode=@0:GDBM#syncmode=@0:GDBM#include?@1:GDBM#has_key?@Q1:GDBM#member?@1:GDBM#has_value?@1:GDBM#key?@2:GDBM#value?@`2:GDBM#to_a@2:GDBM#to_hash@2:GDBM::READER@2:GDBM::WRITER@2:GDBM::WRCREAT@2:GDBM::NEWDB@2:GDBM::FAST@2:GDBM::SYNC@2:GDBM::NOLOCK@ 3:GDBM::VERSION@3;@W3:Kernel#BigDecimal@5:BigDecimal.mode@Y3:BigDecimal.limit@h3:BigDecimal.double_fig@w3:BigDecimal._load@3:#BigDecimal.save_exception_mode@3:"BigDecimal.save_rounding_mode@3:BigDecimal.save_limit@3:BigDecimal::VERSION@3:BigDecimal::BASE@3:BigDecimal::EXCEPTION_ALL@3:BigDecimal::EXCEPTION_NaN@4:#BigDecimal::EXCEPTION_INFINITY@4:$BigDecimal::EXCEPTION_UNDERFLOW@4:#BigDecimal::EXCEPTION_OVERFLOW@(4:%BigDecimal::EXCEPTION_ZERODIVIDE@44:BigDecimal::ROUND_MODE@@4:BigDecimal::ROUND_UP@L4:BigDecimal::ROUND_DOWN@X4:BigDecimal::ROUND_HALF_UP@d4: BigDecimal::ROUND_HALF_DOWN@p4:BigDecimal::ROUND_CEILING@|4:BigDecimal::ROUND_FLOOR@4: BigDecimal::ROUND_HALF_EVEN@4:BigDecimal::SIGN_NaN@4:#BigDecimal::SIGN_POSITIVE_ZERO@4:#BigDecimal::SIGN_NEGATIVE_ZERO@4:%BigDecimal::SIGN_POSITIVE_FINITE@4:%BigDecimal::SIGN_NEGATIVE_FINITE@4:'BigDecimal::SIGN_POSITIVE_INFINITE@4:'BigDecimal::SIGN_NEGATIVE_INFINITE@4:BigDecimal::INFINITY@4:BigDecimal::NAN@5:BigDecimal#initialize_copy@ 5:BigDecimal#precs@5:BigDecimal#add@75:BigDecimal#sub@I5:BigDecimal#mult@[5:BigDecimal#div@m5:BigDecimal#hash@|5:BigDecimal#to_s@5:BigDecimal#to_i@5:BigDecimal#to_int@5:BigDecimal#to_r@5:BigDecimal#split@5:BigDecimal#+@5:BigDecimal#-@5:BigDecimal#+@@5:BigDecimal#-@@ 6:BigDecimal#*@#6:BigDecimal#/@26:BigDecimal#quo@@6:BigDecimal#%@M6:BigDecimal#modulo@[6:BigDecimal#remainder@h6:BigDecimal#divmod@v6:BigDecimal#clone@6: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@ 7:BigDecimal#power@7:BigDecimal#**@*7:BigDecimal#<=>@D7:BigDecimal#==@T7:BigDecimal#===@d7:BigDecimal#eql?@s7:BigDecimal#<@7:BigDecimal#<=@7:BigDecimal#>@7:BigDecimal#>=@7:BigDecimal#zero?@7:BigDecimal#nonzero?@7:BigDecimal#coerce@7:BigDecimal#inspect@7:BigDecimal#exponent@8:BigDecimal#sign@8:BigDecimal#nan?@!8:BigDecimal#infinite?@28:BigDecimal#finite?@C8:BigDecimal#truncate@T8:BigDecimal#_dump@c8;@8:BigMath.exp@8:BigMath.log@8:String#to_d@x3;@8;@w>: DBM.open@8:DBM#initialize@8:DBM#close@9:DBM#closed?@9: DBM#[]@69:DBM#fetch@U9: DBM#[]=@n9:DBM#store@9:DBM#index@9: DBM#key@9:DBM#select@9:DBM#values_at@ ::DBM#length@-:: DBM#size@U::DBM#empty?@|:: DBM#each@::DBM#each_value@::DBM#each_key@::DBM#each_pair@:: DBM#keys@;:DBM#values@1;:DBM#shift@L;:DBM#delete@g;:DBM#delete_if@;:DBM#reject!@;:DBM#reject@;:DBM#clear@ <:DBM#invert@<:DBM#update@:<:DBM#replace@T<:DBM#include?@n<:DBM#has_key?@<:DBM#member?@=:DBM#has_value?@P=: DBM#key?@~=:DBM#value?@=: DBM#to_a@=:DBM#to_hash@>:DBM::READER@,>:DBM::WRITER@8>:DBM::WRCREAT@D>:DBM::NEWDB@P>:DBM::VERSION@\>;@>:Fiddle::Closure@>:Fiddle::Closure#initialize@>:Fiddle::Closure#to_i@>: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_FLOAT@+?:Fiddle::TYPE_DOUBLE@7?:Fiddle::TYPE_SIZE_T@C?:Fiddle::TYPE_SSIZE_T@O?:Fiddle::TYPE_PTRDIFF_T@[?:Fiddle::TYPE_INTPTR_T@g?:Fiddle::TYPE_UINTPTR_T@s?:Fiddle::ALIGN_VOIDP@?:Fiddle::ALIGN_CHAR@?:Fiddle::ALIGN_SHORT@?:Fiddle::ALIGN_INT@?:Fiddle::ALIGN_LONG@?:Fiddle::ALIGN_LONG_LONG@?:Fiddle::ALIGN_FLOAT@?:Fiddle::ALIGN_DOUBLE@?:Fiddle::ALIGN_SIZE_T@?:Fiddle::ALIGN_SSIZE_T@?:Fiddle::ALIGN_PTRDIFF_T@?:Fiddle::ALIGN_INTPTR_T@@:Fiddle::ALIGN_UINTPTR_T@@:Fiddle::WINDOWS@@:Fiddle::SIZEOF_VOIDP@&@:Fiddle::SIZEOF_CHAR@2@:Fiddle::SIZEOF_SHORT@>@:Fiddle::SIZEOF_INT@J@:Fiddle::SIZEOF_LONG@V@:Fiddle::SIZEOF_LONG_LONG@b@:Fiddle::SIZEOF_FLOAT@n@:Fiddle::SIZEOF_DOUBLE@z@:Fiddle::SIZEOF_SIZE_T@@:Fiddle::SIZEOF_SSIZE_T@@:Fiddle::SIZEOF_PTRDIFF_T@@:Fiddle::SIZEOF_INTPTR_T@@:Fiddle::SIZEOF_UINTPTR_T@@:Fiddle::RUBY_FREE@@: Fiddle::BUILD_RUBY_PLATFORM@@:Fiddle#dlwrap@@:Fiddle.dlwrap@@:Fiddle#dlunwrap@A:Fiddle.dlunwrap@A:Fiddle#malloc@0A:Fiddle.malloc@IA:Fiddle#realloc@[A:Fiddle.realloc@xA:Fiddle#free@A:Fiddle.free@A:Fiddle::Handle@A:Fiddle::Handle.sym@A:Fiddle::Handle.[]@A:Fiddle::Handle::NEXT@A:Fiddle::Handle::DEFAULT@A: Fiddle::Handle::RTLD_GLOBAL@A:Fiddle::Handle::RTLD_LAZY@A:Fiddle::Handle::RTLD_NOW@ B:Fiddle::Handle#initialize@B:Fiddle::Handle#to_i@5B:Fiddle::Handle#close@KB:Fiddle::Handle#sym@aB:Fiddle::Handle#[]@qB:!Fiddle::Handle#disable_close@B: Fiddle::Handle#enable_close@B:"Fiddle::Handle#close_enabled?@B;@B;@B:Fiddle::Pointer.to_ptr@B:Fiddle::Pointer.[]@C:Fiddle::Pointer#initialize@D:Fiddle::Pointer#to_s@WD:Fiddle::Pointer#to_str@D:Fiddle::Pointer#inspect@D:Fiddle::Pointer#<=>@D:Fiddle::Pointer#==@D:Fiddle::Pointer#eql?@E:Fiddle::Pointer#+@FE:Fiddle::Pointer#-@`E:Fiddle::Pointer#[]@zE:Fiddle::Pointer#[]=@E:Fiddle::Pointer#size@E:Fiddle::Pointer#size=@E:Fiddle::NULL@ F:)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@B:5ObjectSpace#trace_object_allocations_debug_start@R:5ObjectSpace.trace_object_allocations_debug_start@_:&ObjectSpace#allocation_sourcefile@e:&ObjectSpace.allocation_sourcefile@:&ObjectSpace#allocation_sourceline@:&ObjectSpace.allocation_sourceline@:&ObjectSpace#allocation_class_path@:&ObjectSpace.allocation_class_path@:%ObjectSpace#allocation_method_id@:%ObjectSpace.allocation_method_id@":&ObjectSpace#allocation_generation@9:&ObjectSpace.allocation_generation@X:ObjectSpace#memsize_of@p:ObjectSpace.memsize_of@: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@B:ObjectSpace.count_nodes@_:$ObjectSpace#count_tdata_objects@v:$ObjectSpace.count_tdata_objects@:$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@D:"ObjectSpace.internal_class_of@c:"ObjectSpace#internal_super_of@{:"ObjectSpace.internal_super_of@:'ObjectSpace::InternalObjectWrapper@:,ObjectSpace::InternalObjectWrapper#type@:/ObjectSpace::InternalObjectWrapper#inspect@::ObjectSpace::InternalObjectWrapper#internal_object_id@:ObjectSpace#dump@:ObjectSpace.dump@+:ObjectSpace#dump_all@b:ObjectSpace.dump_all@;@F:Readline#readline@F:Readline.readline@F:Readline.input=@F:Readline.output=@F:Readline.completion_proc=@G:Readline.completion_proc@*G:%Readline.quoting_detection_proc=@EG:$Readline.quoting_detection_proc@_G:#Readline.completion_case_fold=@zG:"Readline.completion_case_fold@G:Readline.line_buffer@G:Readline.point@G:Readline.point=@G:Readline.set_screen_size@G:Readline.get_screen_size@"H:Readline.vi_editing_mode@=H:Readline.vi_editing_mode?@XH: Readline.emacs_editing_mode@sH:!Readline.emacs_editing_mode?@H:*Readline.completion_append_character=@H:)Readline.completion_append_character@H:(Readline.completion_quote_character@H:*Readline.basic_word_break_characters=@H:)Readline.basic_word_break_characters@I:.Readline.completer_word_break_characters=@0I:-Readline.completer_word_break_characters@JI:%Readline.basic_quote_characters=@gI:$Readline.basic_quote_characters@I:)Readline.completer_quote_characters=@I:(Readline.completer_quote_characters@I:(Readline.filename_quote_characters=@I:'Readline.filename_quote_characters@I:Readline.refresh_line@ J:Readline.pre_input_hook=@'J:Readline.pre_input_hook@AJ:Readline.insert_text@\J:Readline.delete_text@{J:Readline.redisplay@J:Readline.special_prefixes=@J:Readline.special_prefixes@J:Readline::HISTORY@K:'Readline::FILENAME_COMPLETION_PROC@K:'Readline::USERNAME_COMPLETION_PROC@K:Readline::VERSION@)K;@DK:OpenSSL::OpenSSLError@FK:OpenSSL::PKey@K:OpenSSL::PKey::PKeyError@K:OpenSSL::PKey::PKey@K:OpenSSL::PKey#read@#L;@OL:#OpenSSL::PKey::PKey#initialize@K:OpenSSL::PKey::PKey#sign@K:OpenSSL::PKey::PKey#verify@K:OpenSSL::PKey::DSAError@uL:OpenSSL::PKey::DSA@L: OpenSSL::PKey::DSA.generate@L:"OpenSSL::PKey::DSA#initialize@L:'OpenSSL::PKey::DSA#initialize_copy@L:OpenSSL::PKey::DSA#public?@L: OpenSSL::PKey::DSA#private?@L:OpenSSL::PKey::DSA#to_text@M:OpenSSL::PKey::DSA#export@+M:OpenSSL::PKey::DSA#to_pem@oM:OpenSSL::PKey::DSA#to_s@dM:OpenSSL::PKey::DSA#to_der@wM:"OpenSSL::PKey::DSA#public_key@M:OpenSSL::PKey::DSA#syssign@M:!OpenSSL::PKey::DSA#sysverify@M:OpenSSL::PKey::DSA#set_pqg@M:OpenSSL::PKey::DSA#set_key@N:OpenSSL::PKey::DSA#params@N:OpenSSL::PKey::RSAError@LN:OpenSSL::PKey::RSA@`N: OpenSSL::PKey::RSA.generate@bN:"OpenSSL::PKey::RSA#initialize@N:'OpenSSL::PKey::RSA#initialize_copy@N:OpenSSL::PKey::RSA#public?@N: OpenSSL::PKey::RSA#private?@N:OpenSSL::PKey::RSA#to_text@N:OpenSSL::PKey::RSA#export@O:OpenSSL::PKey::RSA#to_pem@WO:OpenSSL::PKey::RSA#to_s@LO:OpenSSL::PKey::RSA#to_der@_O:"OpenSSL::PKey::RSA#public_key@zO:&OpenSSL::PKey::RSA#public_encrypt@O:&OpenSSL::PKey::RSA#public_decrypt@O:'OpenSSL::PKey::RSA#private_encrypt@O:'OpenSSL::PKey::RSA#private_decrypt@P: OpenSSL::PKey::RSA#sign_pss@LP:"OpenSSL::PKey::RSA#verify_pss@rP:OpenSSL::PKey::RSA#set_key@P:#OpenSSL::PKey::RSA#set_factors@P:&OpenSSL::PKey::RSA#set_crt_params@P:OpenSSL::PKey::RSA#params@P:OpenSSL::PKey::ECError@Q:OpenSSL::PKey::EC@+Q:OpenSSL::PKey::EC::Group@-Q:OpenSSL::PKey::EC::Point@kS:$OpenSSL::PKey::EC::Group::Error@/Q:$OpenSSL::PKey::EC::Point::Error@mS:#OpenSSL::PKey::EC::NAMED_CURVE@T:&OpenSSL::PKey::EC::EXPLICIT_CURVE@T:%OpenSSL::PKey::EC.builtin_curves@T:OpenSSL::PKey::EC.generate@T:!OpenSSL::PKey::EC#initialize@U:&OpenSSL::PKey::EC#initialize_copy@PU:OpenSSL::PKey::EC#group@^U:OpenSSL::PKey::EC#group=@tU:"OpenSSL::PKey::EC#private_key@U:#OpenSSL::PKey::EC#private_key=@U:!OpenSSL::PKey::EC#public_key@U:"OpenSSL::PKey::EC#public_key=@U:OpenSSL::PKey::EC#private?@U:OpenSSL::PKey::EC#public?@V:#OpenSSL::PKey::EC#private_key?@V:"OpenSSL::PKey::EC#public_key?@3V:$OpenSSL::PKey::EC#generate_key!@>V:#OpenSSL::PKey::EC#generate_key@VV: OpenSSL::PKey::EC#check_key@aV:%OpenSSL::PKey::EC#dh_compute_key@|V:$OpenSSL::PKey::EC#dsa_sign_asn1@V:&OpenSSL::PKey::EC#dsa_verify_asn1@V:OpenSSL::PKey::EC#export@V:OpenSSL::PKey::EC#to_pem@W:OpenSSL::PKey::EC#to_der@W:OpenSSL::PKey::EC#to_text@-W:(OpenSSL::PKey::EC::Group#initialize@@Q:-OpenSSL::PKey::EC::Group#initialize_copy@Q:"OpenSSL::PKey::EC::Group#eql?@Q: OpenSSL::PKey::EC::Group#==@Q:'OpenSSL::PKey::EC::Group#generator@Q:+OpenSSL::PKey::EC::Group#set_generator@Q:#OpenSSL::PKey::EC::Group#order@ R:&OpenSSL::PKey::EC::Group#cofactor@R:(OpenSSL::PKey::EC::Group#curve_name@5R:'OpenSSL::PKey::EC::Group#asn1_flag@PR:(OpenSSL::PKey::EC::Group#asn1_flag=@kR:3OpenSSL::PKey::EC::Group#point_conversion_form@R:4OpenSSL::PKey::EC::Group#point_conversion_form=@R:"OpenSSL::PKey::EC::Group#seed@R:#OpenSSL::PKey::EC::Group#seed=@R:$OpenSSL::PKey::EC::Group#degree@R:$OpenSSL::PKey::EC::Group#to_pem@ S:$OpenSSL::PKey::EC::Group#to_der@&S:%OpenSSL::PKey::EC::Group#to_text@AS:(OpenSSL::PKey::EC::Point#initialize@~S:-OpenSSL::PKey::EC::Point#initialize_copy@S:"OpenSSL::PKey::EC::Point#eql?@S: OpenSSL::PKey::EC::Point#==@S:'OpenSSL::PKey::EC::Point#infinity?@S:'OpenSSL::PKey::EC::Point#on_curve?@S:*OpenSSL::PKey::EC::Point#make_affine!@T:%OpenSSL::PKey::EC::Point#invert!@+T:.OpenSSL::PKey::EC::Point#set_to_infinity!@FT:-OpenSSL::PKey::EC::Point#to_octet_string@aT:!OpenSSL::PKey::EC::Point#mul@T:OpenSSL::PKCS7@UY:OpenSSL::PKCS7::PKCS7Error@WY:OpenSSL::PKCS7.read_smime@hY:OpenSSL::PKCS7.write_smime@Y:OpenSSL::PKCS7.sign@Y:OpenSSL::PKCS7.encrypt@Y:#OpenSSL::PKCS7#initialize_copy@Y:OpenSSL::PKCS7#initialize@Y:OpenSSL::PKCS7#type=@ Z:OpenSSL::PKCS7#type@%Z:OpenSSL::PKCS7#detached=@AZ:OpenSSL::PKCS7#detached@OZ:OpenSSL::PKCS7#detached?@[Z:OpenSSL::PKCS7#cipher=@jZ:OpenSSL::PKCS7#add_signer@xZ:OpenSSL::PKCS7#signers@Z:!OpenSSL::PKCS7#add_recipient@Z:OpenSSL::PKCS7#recipients@Z:#OpenSSL::PKCS7#add_certificate@Z:!OpenSSL::PKCS7#certificates=@Z: OpenSSL::PKCS7#certificates@Z:OpenSSL::PKCS7#add_crl@Z:OpenSSL::PKCS7#crls=@Z:OpenSSL::PKCS7#crls@Z:OpenSSL::PKCS7#add_data@Z:OpenSSL::PKCS7#data=@[:OpenSSL::PKCS7#verify@[:OpenSSL::PKCS7#decrypt@[:OpenSSL::PKCS7#to_pem@,[:OpenSSL::PKCS7#to_s@6[:OpenSSL::PKCS7#to_der@@[:OpenSSL::PKCS7::SignerInfo@L[:OpenSSL::PKCS7::Signer@[:*OpenSSL::PKCS7::SignerInfo#initialize@N[:&OpenSSL::PKCS7::SignerInfo#issuer@`[:$OpenSSL::PKCS7::SignerInfo#name@j[:&OpenSSL::PKCS7::SignerInfo#serial@t[:+OpenSSL::PKCS7::SignerInfo#signed_time@[:"OpenSSL::PKCS7::RecipientInfo@[:-OpenSSL::PKCS7::RecipientInfo#initialize@[:)OpenSSL::PKCS7::RecipientInfo#issuer@[:)OpenSSL::PKCS7::RecipientInfo#serial@[:*OpenSSL::PKCS7::RecipientInfo#enc_key@[:OpenSSL::Netscape::SPKI@: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@1\:#OpenSSL::X509::Request#to_text@G\:#OpenSSL::X509::Request#version@S\:$OpenSSL::X509::Request#version=@_\:#OpenSSL::X509::Request#subject@m\:$OpenSSL::X509::Request#subject=@y\:/OpenSSL::X509::Request#signature_algorithm@\:&OpenSSL::X509::Request#public_key@\:'OpenSSL::X509::Request#public_key=@\: OpenSSL::X509::Request#sign@\:"OpenSSL::X509::Request#verify@\:&OpenSSL::X509::Request#attributes@\:'OpenSSL::X509::Request#attributes=@\:)OpenSSL::X509::Request#add_attribute@\:OpenSSL::X509::Name@]:OpenSSL::X509::NameError@^:#OpenSSL::X509::Name#initialize@]:(OpenSSL::X509::Name#initialize_copy@?]:"OpenSSL::X509::Name#add_entry@M]:OpenSSL::X509::Name#to_s@s]: OpenSSL::X509::Name#to_utf8@]: OpenSSL::X509::Name#inspect@]:OpenSSL::X509::Name#to_a@]:OpenSSL::X509::Name#cmp@]:OpenSSL::X509::Name#<=>@ ^:OpenSSL::X509::Name#eql?@^:OpenSSL::X509::Name#hash@5^:!OpenSSL::X509::Name#hash_old@P^:OpenSSL::X509::Name#to_der@k^:-OpenSSL::X509::Name::DEFAULT_OBJECT_TYPE@^:.OpenSSL::X509::Name::OBJECT_TYPE_TEMPLATE@^: OpenSSL::X509::Name::COMPAT@^:!OpenSSL::X509::Name::RFC2253@^:!OpenSSL::X509::Name::ONELINE@^:#OpenSSL::X509::Name::MULTILINE@^:OpenSSL::Random@h:!OpenSSL::Random::RandomError@h:OpenSSL::Random#seed@h:OpenSSL::Random.seed@i:OpenSSL::Random#random_add@1i:OpenSSL::Random.random_add@Si:%OpenSSL::Random#load_random_file@li:%OpenSSL::Random.load_random_file@i:&OpenSSL::Random#write_random_file@i:&OpenSSL::Random.write_random_file@i:!OpenSSL::Random#random_bytes@i:!OpenSSL::Random.random_bytes@i:!OpenSSL::Random#pseudo_bytes@i:!OpenSSL::Random.pseudo_bytes@i:OpenSSL::Random#egd@j:OpenSSL::Random.egd@"j:OpenSSL::Random#egd_bytes@9j:OpenSSL::Random.egd_bytes@[j:OpenSSL::Random#status?@tj:OpenSSL::Random.status?@j:OpenSSL::HMACError@j:OpenSSL::HMAC@j:OpenSSL::HMAC.digest@j:OpenSSL::HMAC.hexdigest@j:OpenSSL::HMAC#initialize@k:"OpenSSL::HMAC#initialize_copy@/k:OpenSSL::HMAC#reset@=k:OpenSSL::HMAC#update@Xk:OpenSSL::HMAC#<<@tk:OpenSSL::HMAC#digest@k:OpenSSL::HMAC#hexdigest@k:OpenSSL::HMAC#inspect@k:OpenSSL::HMAC#to_s@k:OpenSSL::Cipher@k:!OpenSSL::Cipher::CipherError@k:$OpenSSL::Cipher#initialize_copy@k:OpenSSL::Cipher#ciphers@k;@ l:OpenSSL::Cipher#initialize@l:OpenSSL::Cipher#reset@7l:OpenSSL::Cipher#encrypt@Rl:OpenSSL::Cipher#decrypt@nl:#OpenSSL::Cipher#pkcs5_keyivgen@l:OpenSSL::Cipher#update@l:OpenSSL::Cipher#final@l:OpenSSL::Cipher#name@l:OpenSSL::Cipher#key=@m:OpenSSL::Cipher#auth_data=@$m:OpenSSL::Cipher#auth_tag=@Cm:OpenSSL::Cipher#auth_tag@bm:"OpenSSL::Cipher#auth_tag_len=@m:#OpenSSL::Cipher#authenticated?@m:OpenSSL::Cipher#key_len=@m:OpenSSL::Cipher#key_len@m:OpenSSL::Cipher#iv=@m:OpenSSL::Cipher#iv_len=@n:OpenSSL::Cipher#iv_len@1n:OpenSSL::Cipher#block_size@Ln:OpenSSL::Cipher#padding=@gn:OpenSSL::PKCS12@n:!OpenSSL::PKCS12::PKCS12Error@n:OpenSSL::PKCS12.create@n:$OpenSSL::PKCS12#initialize_copy@n:OpenSSL::PKCS12#initialize@n:OpenSSL::PKCS12#to_der@o:OpenSSL::KDF@ o:OpenSSL::KDF::KDFError@"o:OpenSSL::KDF#pbkdf2_hmac@3o:OpenSSL::KDF.pbkdf2_hmac@\o:OpenSSL::KDF#scrypt@o:OpenSSL::KDF.scrypt@o:OpenSSL::KDF#hkdf@o:OpenSSL::KDF.hkdf@o:OpenSSL::ConfigError@)p:OpenSSL::Config@>p:)OpenSSL::Config::DEFAULT_CONFIG_FILE@@p: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@G_:OpenSSL::X509::CRL#issuer=@S_:#OpenSSL::X509::CRL#last_update@c_:$OpenSSL::X509::CRL#last_update=@o_:#OpenSSL::X509::CRL#next_update@}_:$OpenSSL::X509::CRL#next_update=@_:OpenSSL::X509::CRL#revoked@_: OpenSSL::X509::CRL#revoked=@_:#OpenSSL::X509::CRL#add_revoked@_:OpenSSL::X509::CRL#sign@_: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::SSL@Zp:OpenSSL::ExtConfig@y:OpenSSL::SSL::SSLError@\p:'OpenSSL::SSL::SSLErrorWaitReadable@pp:'OpenSSL::SSL::SSLErrorWaitWritable@p:OpenSSL::SSL::SSLContext@p:.OpenSSL::ExtConfig::HAVE_TLSEXT_HOST_NAME@y:)OpenSSL::SSL::SSLContext#ssl_timeout@p:*OpenSSL::SSL::SSLContext#ssl_timeout=@p:6OpenSSL::SSL::SSLContext#set_minmax_proto_version@p:%OpenSSL::SSL::SSLContext#ciphers@p:&OpenSSL::SSL::SSLContext#ciphers=@p:*OpenSSL::SSL::SSLContext#ecdh_curves=@p:,OpenSSL::SSL::SSLContext#security_level@q:-OpenSSL::SSL::SSLContext#security_level=@-q:2OpenSSL::SSL::SSLContext#enable_fallback_scsv@Gq:-OpenSSL::SSL::SSLContext#add_certificate@bq:#OpenSSL::SSL::SSLContext#setup@q:$OpenSSL::SSL::SSLContext#freeze@q:0OpenSSL::SSL::SSLContext::SESSION_CACHE_OFF@q:3OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT@q:3OpenSSL::SSL::SSLContext::SESSION_CACHE_SERVER@q:1OpenSSL::SSL::SSLContext::SESSION_CACHE_BOTH@q::OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_AUTO_CLEAR@q:?OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_LOOKUP@q:>OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE@q:8OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL@r:)OpenSSL::SSL::SSLContext#session_add@ r:,OpenSSL::SSL::SSLContext#session_remove@'r:0OpenSSL::SSL::SSLContext#session_cache_mode@Ar:1OpenSSL::SSL::SSLContext#session_cache_mode=@\r:0OpenSSL::SSL::SSLContext#session_cache_size@{r:1OpenSSL::SSL::SSLContext#session_cache_size=@r:1OpenSSL::SSL::SSLContext#session_cache_stats@r:,OpenSSL::SSL::SSLContext#flush_sessions@r:%OpenSSL::SSL::SSLContext#options@r:&OpenSSL::SSL::SSLContext#options=@r:OpenSSL::SSL::SSLSocket@s:(OpenSSL::ExtConfig::OPENSSL_NO_SOCK@y:'OpenSSL::SSL::SSLSocket#initialize@ s:$OpenSSL::SSL::SSLSocket#connect@Ps:-OpenSSL::SSL::SSLSocket#connect_nonblock@ks:#OpenSSL::SSL::SSLSocket#accept@s:,OpenSSL::SSL::SSLSocket#accept_nonblock@s:$OpenSSL::SSL::SSLSocket#sysread@s:-OpenSSL::SSL::SSLSocket#sysread_nonblock@s:%OpenSSL::SSL::SSLSocket#syswrite@ t:.OpenSSL::SSL::SSLSocket#syswrite_nonblock@?t:!OpenSSL::SSL::SSLSocket#stop@]t:!OpenSSL::SSL::SSLSocket#cert@xt:&OpenSSL::SSL::SSLSocket#peer_cert@t:,OpenSSL::SSL::SSLSocket#peer_cert_chain@t:(OpenSSL::SSL::SSLSocket#ssl_version@t:#OpenSSL::SSL::SSLSocket#cipher@t:"OpenSSL::SSL::SSLSocket#state@u:$OpenSSL::SSL::SSLSocket#pending@u:,OpenSSL::SSL::SSLSocket#session_reused?@7u:%OpenSSL::SSL::SSLSocket#session=@Pu:*OpenSSL::SSL::SSLSocket#verify_result@ju:&OpenSSL::SSL::SSLSocket#client_ca@u:&OpenSSL::SSL::SSLSocket#hostname=@u:$OpenSSL::SSL::SSLSocket#tmp_key@u:*OpenSSL::SSL::SSLSocket#alpn_protocol@u:)OpenSSL::SSL::SSLSocket#npn_protocol@u:OpenSSL::SSL::VERIFY_NONE@v:OpenSSL::SSL::VERIFY_PEER@%v:.OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT@/v:%OpenSSL::SSL::VERIFY_CLIENT_ONCE@9v:OpenSSL::SSL::OP_ALL@Cv:+OpenSSL::SSL::OP_LEGACY_SERVER_CONNECT@Mv:$OpenSSL::SSL::OP_TLSEXT_PADDING@Wv:,OpenSSL::SSL::OP_SAFARI_ECDHE_ECDSA_BUG@av:&OpenSSL::SSL::OP_ALLOW_NO_DHE_KEX@kv:1OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS@uv:OpenSSL::SSL::OP_NO_TICKET@v:@{:OpenSSL::BN#ucmp@{:OpenSSL::BN#eql?@{:OpenSSL::BN#hash@|:OpenSSL::BN#==@|:OpenSSL::BN#===@&|:OpenSSL::BN#zero?@.|:OpenSSL::BN#one?@D|:OpenSSL::BN#odd?@Z|:OpenSSL::BN#negative?@p|:OpenSSL::BN.rand@||:OpenSSL::BN.pseudo_rand@|:OpenSSL::BN.rand_range@|:"OpenSSL::BN.pseudo_rand_range@|:OpenSSL::BN.generate_prime@|:OpenSSL::BN#prime?@|: OpenSSL::BN#prime_fasttest?@|:OpenSSL::BN#set_bit!@}:OpenSSL::BN#clear_bit!@3}:OpenSSL::BN#bit_set?@M}:OpenSSL::BN#mask_bits!@Y}:OpenSSL::BN#<<@b}:OpenSSL::BN#>>@w}:OpenSSL::BN#lshift!@}:OpenSSL::BN#rshift!@}:OpenSSL::BN#to_s@}:OpenSSL::BN#to_i@}:OpenSSL::BN#to_int@~:OpenSSL::BN#to_bn@~:OpenSSL::BN#coerce@~:OpenSSL::BN#mod_inverse@(~:OpenSSL::Engine@L~:!OpenSSL::Engine::EngineError@N~;p@e~;r@~;t@~;v@~:OpenSSL::Engine#id@~:OpenSSL::Engine#name@~:OpenSSL::Engine#finish@:OpenSSL::Engine#cipher@:OpenSSL::Engine#digest@::%OpenSSL::Engine#load_private_key@Y:$OpenSSL::Engine#load_public_key@{: OpenSSL::Engine#set_default@:OpenSSL::Engine#ctrl_cmd@:OpenSSL::Engine#cmds@:OpenSSL::Engine#inspect@:"OpenSSL::X509::AttributeError@D`:OpenSSL::X509::Attribute@U`:(OpenSSL::X509::Attribute#initialize@W`:-OpenSSL::X509::Attribute#initialize_copy@p`:"OpenSSL::X509::Attribute#oid=@~`:!OpenSSL::X509::Attribute#oid@`:$OpenSSL::X509::Attribute#value=@`:#OpenSSL::X509::Attribute#value@`:$OpenSSL::X509::Attribute#to_der@`:OpenSSL::X509::StoreError@a:OpenSSL::X509::Store@#a:$OpenSSL::X509::Store#initialize@%a:*OpenSSL::X509::Store#verify_callback=@ 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; @5;@F;Ao;B;CT;Di*;EiA;!o;2 ;30;40;50;;t;!@;70;F0;"I"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; @: NKF#nkf@ : NKF.nkf@-:NKF#guess@F:NKF.guess@d:NKF::AUTO@{:NKF::NOCONV@:NKF::UNKNOWN@:NKF::BINARY@:NKF::ASCII@: NKF::JIS@: NKF::EUC@:NKF::SJIS@:NKF::UTF8@˞:NKF::UTF16@՞:NKF::UTF32@ߞ:NKF::VERSION@:NKF::NKF_VERSION@:NKF::NKF_RELEASE_DATE@: IO#raw@: IO#raw!@:IO#cooked@̧:IO#cooked!@: IO#getch@: IO#echo=@: IO#echo?@9:IO#noecho@T:IO#winsize@o:IO#winsize=@:IO#iflush@:IO#oflush@:IO#ioflush@ƨ: IO#beep@ܨ: IO#goto@:IO#cursor@:IO#cursor=@:IO#pressed?@:IO#getpass@#:IO.console@B:IO::generic_readable@j:IO::generic_readable#getch@l:!IO::generic_readable#getpass@: IO#nread@:IO#ready?@Ȫ: IO#wait@:IO#wait_readable@:IO#wait_writable@5:IO#nonblock?@[:IO#nonblock=@w:IO#nonblock@; @; @:SDBM.open@:SDBM#initialize@M:SDBM#close@i:SDBM#closed?@: SDBM#[]@:SDBM#fetch@: SDBM#[]=@:SDBM#store@:SDBM#index@:: SDBM#key@J:SDBM#select@d:SDBM#values_at@:SDBM#length@:SDBM#size@͠:SDBM#empty?@:SDBM#each@:SDBM#each_value@I:SDBM#each_key@l:SDBM#each_pair@:SDBM#keys@ȡ:SDBM#values@:SDBM#shift@:SDBM#delete@:SDBM#delete_if@I:SDBM#reject!@}:SDBM#reject@:SDBM#clear@Ѣ:SDBM#invert@:SDBM#update@:SDBM#replace@&:SDBM#has_key?@E:SDBM#include?@:SDBM#key?@ܣ:SDBM#member?@':SDBM#has_value?@r:SDBM#value?@:SDBM#to_a@ͤ:SDBM#to_hash@; @):Fcntl::F_DUPFD@+:Fcntl::F_GETFD@8:Fcntl::F_GETLK@D:Fcntl::F_SETFD@P:Fcntl::F_GETFL@\:Fcntl::F_SETFL@h:Fcntl::F_SETLK@t:Fcntl::F_SETLKW@:Fcntl::FD_CLOEXEC@:Fcntl::F_RDLCK@:Fcntl::F_UNLCK@:Fcntl::F_WRLCK@: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@4:PTY::ChildExited@~:Ripper::EXPR_BEG@H:Ripper::EXPR_END@T:Ripper::EXPR_ENDARG@`:Ripper::EXPR_ENDFN@l:Ripper::EXPR_ARG@x:Ripper::EXPR_CMDARG@:Ripper::EXPR_MID@:Ripper::EXPR_FNAME@:Ripper::EXPR_DOT@:Ripper::EXPR_CLASS@:Ripper::EXPR_LABEL@:Ripper::EXPR_LABELED@:Ripper::EXPR_FITEM@:Ripper::EXPR_VALUE@:Ripper::EXPR_BEG_ANY@:Ripper::EXPR_ARG_ANY@:Ripper::EXPR_END_ANY@:Ripper::EXPR_NONE@; @P:Coverage#start@R:Coverage.start@n:Coverage#result@:Coverage.result@:Coverage#peek_result@:Coverage.peek_result@٦:Coverage#running?@:Coverage.running?@; @,:Racc::Parser@.:"Racc::Parser#_racc_do_parse_c@0:!Racc::Parser#_racc_yyparse_c@A:.Racc::Parser::Racc_Runtime_Core_Version_C@U:)Racc::Parser::Racc_Runtime_Core_Id_C@_:Racc::CparseParams@x;@:Pathname#initialize@:Pathname#freeze@:Pathname#taint@ŧ:Pathname#untaint@:Pathname#==@:Pathname#===@ :Pathname#eql?@:Pathname#<=>@,:Pathname#hash@<:Pathname#to_s@J:Pathname#to_path@r:Pathname#inspect@:Pathname#sub@:Pathname#sub_ext@:Pathname#realpath@ƨ:Pathname#realdirpath@ը:Pathname#each_line@:Pathname#read@I:Pathname#binread@x:Pathname#readlines@:Pathname#write@թ:Pathname#binwrite@:Pathname#sysopen@;:Pathname#atime@Y:Pathname#birthtime@o:Pathname#ctime@:Pathname#mtime@:Pathname#chmod@:Pathname#lchmod@ɪ:Pathname#chown@:Pathname#lchown@:Pathname#fnmatch@:Pathname#fnmatch?@F:Pathname#ftype@v:Pathname#make_link@:Pathname#open@:Pathname#readlink@:Pathname#rename@ë:Pathname#stat@ӫ:Pathname#lstat@:Pathname#make_symlink@:Pathname#truncate@ :Pathname#utime@:Pathname#basename@+:Pathname#dirname@::Pathname#extname@H:Pathname#expand_path@V:Pathname#split@e:Pathname#blockdev?@s:Pathname#chardev?@:Pathname#executable?@:Pathname#executable_real?@:Pathname#exist?@:Pathname#grpowned?@Ȭ:Pathname#directory?@٬:Pathname#file?@:Pathname#pipe?@:Pathname#socket?@ :Pathname#owned?@:Pathname#readable?@.:Pathname#world_readable?@?:Pathname#readable_real?@P:Pathname#setuid?@a:Pathname#setgid?@r:Pathname#size@:Pathname#size?@:Pathname#sticky?@:Pathname#symlink?@:Pathname#writable?@ĭ:Pathname#world_writable?@խ:Pathname#writable_real?@:Pathname#zero?@:Pathname#empty?@:Pathname.glob@:Pathname.getwd@(:Pathname.pwd@6:Pathname#glob@C:Pathname#entries@R:Pathname#mkdir@`:Pathname#rmdir@o:Pathname#opendir@}:Pathname#each_entry@:Pathname#unlink@:Pathname#delete@:Kernel#Pathname@T;@î:Digest::Instance@Ů:Digest::Class@:Digest#bubblebabble@Q:Digest.bubblebabble@`:Digest::Class.bubblebabble@:"Digest::Instance#bubblebabble@Ǯ:Digest::SHA1@h:Digest::MD5@F:Digest::RMD160@^:Digest::Base@:Digest#hexencode@v:Digest.hexencode@:Digest::Instance#update@֮:Digest::Instance#<<@:Digest::Instance#finish@:Digest::Instance#reset@7:#Digest::Instance#digest_length@M:"Digest::Instance#block_length@h:Digest::Instance#==@:Digest::Instance#inspect@:Digest::Instance#new@̯:Digest::Instance#digest@:Digest::Instance#digest!@ :Digest::Instance#hexdigest@(: Digest::Instance#hexdigest!@S:Digest::Instance#to_s@n:Digest::Instance#length@:Digest::Instance#size@:Digest::Class#initialize@; @ ; @%:!Digest::Base#initialize_copy@:Digest::Base#reset@:Digest::Base#update@:Digest::Base#<<@ͱ:Digest::Base#finish@:Digest::Base#digest_length@:Digest::Base#block_length@; @:Syslog::Constants@:Syslog::Option@:Syslog::Facility@ɳ:Syslog::Level@ڳ:Syslog::Macros@:Syslog#open@<:Syslog.open@X:Syslog#reopen@n:Syslog.reopen@:Syslog#open!@:Syslog.open!@:Syslog#opened?@Ѵ:Syslog.opened?@:Syslog#ident@:Syslog.ident@ :Syslog#options@:Syslog.options@ :Syslog#facility@(:Syslog.facility@5:Syslog#log@=:Syslog.log@Y:Syslog#close@o:Syslog.close@|:Syslog#mask@:Syslog.mask@:Syslog#mask=@:Syslog.mask=@:Syslog.inspect@ĵ:Syslog#instance@ҵ:Syslog.instance@ߵ:Syslog::Macros#LOG_MASK@:Syslog::Macros#LOG_UPTO@:Syslog::Macros.included@:Syslog::Constants.included@; @:Zlib::ZStream@:Zlib::Deflate@M:Zlib::Inflate@:Zlib::GzipFile@:Zlib::GzipWriter@ٹ:Zlib::GzipReader@:Zlib::Error@:Zlib::StreamEnd@:Zlib::NeedDict@:Zlib::DataError@:Zlib::StreamError@ͼ:Zlib::MemError@:Zlib::BufError@:Zlib::VersionError@ :Zlib#zlib_version@:Zlib.zlib_version@*:Zlib#adler32@2:Zlib.adler32@@:Zlib#adler32_combine@H:Zlib.adler32_combine@[:Zlib#crc32@c:Zlib.crc32@q:Zlib#crc32_combine@y:Zlib.crc32_combine@: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@5:Zlib::ZStream#data_type@C:Zlib::ZStream#adler@Q:Zlib::ZStream#finished?@_:Zlib::ZStream#stream_end?@p:Zlib::ZStream#closed?@:Zlib::ZStream#ended?@: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@O:Zlib.deflate@:Zlib::Deflate#initialize@^:"Zlib::Deflate#initialize_copy@m:Zlib::Deflate#deflate@}:Zlib::Deflate#<<@: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?@U:!Zlib::Inflate#set_dictionary@f:Zlib::NO_COMPRESSION@:Zlib::BEST_SPEED@:Zlib::BEST_COMPRESSION@&:Zlib::DEFAULT_COMPRESSION@2:Zlib::FILTERED@>:Zlib::HUFFMAN_ONLY@J:Zlib::RLE@V:Zlib::FIXED@b:Zlib::DEFAULT_STRATEGY@n:Zlib::MAX_WBITS@z:Zlib::DEF_MEM_LEVEL@:Zlib::MAX_MEM_LEVEL@:Zlib::NO_FLUSH@:Zlib::SYNC_FLUSH@:Zlib::FULL_FLUSH@:Zlib::FINISH@¾:Zlib::GzipFile::Error@: Zlib::GzipFile::Error#input@:"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@5:Zlib::GzipFile#level@C:Zlib::GzipFile#os_code@Q:Zlib::GzipFile#orig_name@_:Zlib::GzipFile#comment@m:Zlib::GzipReader#lineno@:Zlib::GzipReader#lineno=@:Zlib::GzipWriter#mtime=@۹: Zlib::GzipWriter#orig_name=@:Zlib::GzipWriter#comment=@:Zlib::GzipFile#close@{:Zlib::GzipFile#finish@:Zlib::GzipFile#closed?@:Zlib::GzipReader#eof@:Zlib::GzipReader#eof?@:Zlib::GzipFile#sync@:Zlib::GzipFile#sync=@:Zlib::GzipReader#pos@":Zlib::GzipWriter#pos@ :Zlib::GzipReader#tell@0:Zlib::GzipWriter#tell@; @&: Zlib::GzipWriter#initialize@J:Zlib::GzipWriter#flush@l:Zlib::GzipWriter#write@:Zlib::GzipWriter#putc@:Zlib::GzipWriter#<<@:Zlib::GzipWriter#printf@:Zlib::GzipWriter#print@:Zlib::GzipWriter#puts@ƺ:Zlib::GzipReader.open@=: Zlib::GzipReader#initialize@L:Zlib::GzipReader#rewind@[:Zlib::GzipReader#unused@i:Zlib::GzipReader#read@w:!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#bytes@:Zlib::GzipReader#ungetc@:Zlib::GzipReader#ungetbyte@:Zlib::GzipReader#gets@:Zlib::GzipReader#readline@&:Zlib::GzipReader#each@5:Zlib::GzipReader#each_line@D:Zlib::GzipReader#lines@R:Zlib::GzipReader#readlines@a:'Zlib::GzipReader#external_encoding@p:Zlib.gzip@ξ:Zlib.gunzip@:Zlib::OS_CODE@:Zlib::OS_MSDOS@:Zlib::OS_AMIGA@):Zlib::OS_VMS@5:Zlib::OS_UNIX@A:Zlib::OS_ATARI@M:Zlib::OS_OS2@Y:Zlib::OS_MACOS@e:Zlib::OS_TOPS20@q:Zlib::OS_WIN32@}:Zlib::OS_VMCMS@:Zlib::OS_ZSYSTEM@:Zlib::OS_CPM@:Zlib::OS_QDOS@:Zlib::OS_RISCOS@:Zlib::OS_UNKNOWN@ſ;D @:Psych::Visitors@:Psych::Visitors::Visitor@:Psych::Visitors::YAMLTree@:-Psych::Visitors::YAMLTree#private_iv_get@:Psych::Handler@i:Psych::Emitter@z:Psych::Emitter#initialize@|: Psych::Emitter#start_stream@:Psych::Emitter#end_stream@:"Psych::Emitter#start_document@: Psych::Emitter#end_document@:Psych::Emitter#scalar@:"Psych::Emitter#start_sequence@1: Psych::Emitter#end_sequence@W:!Psych::Emitter#start_mapping@m: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=@9:Psych::ClassLoader@b:Psych::Visitors::ToRuby@*:,Psych::Visitors::ToRuby#build_exception@,:"Psych::ClassLoader#path2class@d:Psych.libyaml_version@:Psych::Parser@:Psych::Parser::ANY@:Psych::Parser::UTF8@:Psych::Parser::UTF16LE@:Psych::Parser::UTF16BE@:Psych::Parser#parse@:Psych::Parser#mark@;\ @ :StringScanner::Error@":StringScanner#initialize@4:"StringScanner#initialize_copy@P:!StringScanner.must_C_version@p:StringScanner#reset@:StringScanner#terminate@:StringScanner#clear@:StringScanner#string@:StringScanner#string=@:StringScanner#concat@:StringScanner#<<@ :StringScanner#pos@/:StringScanner#pos=@=:StringScanner#charpos@W:StringScanner#pointer@e:StringScanner#pointer=@r:StringScanner#scan@:StringScanner#skip@:StringScanner#match?@:StringScanner#check@:StringScanner#scan_full@:StringScanner#scan_until@:StringScanner#skip_until@7:StringScanner#exist?@Q:StringScanner#check_until@n:StringScanner#search_full@:StringScanner#getch@:StringScanner#get_byte@:StringScanner#getbyte@:StringScanner#peek@:StringScanner#peep@:StringScanner#unscan@:%StringScanner#beginning_of_line?@ :StringScanner#eos?@:StringScanner#empty?@.:StringScanner#rest?@?:StringScanner#matched?@P:StringScanner#matched@a:StringScanner#matched_size@o:StringScanner#[]@}:StringScanner#pre_match@:StringScanner#post_match@:StringScanner#size@:StringScanner#captures@:StringScanner#values_at@:StringScanner#rest@:StringScanner#rest_size@:StringScanner#restsize@:StringScanner#inspect@+;_ @K:StringIO.new@M:StringIO.open@\:StringIO#initialize@{:StringIO#initialize_copy@:StringIO#reopen@:StringIO#string@:StringIO#string=@:StringIO#lineno@:StringIO#lineno=@:StringIO#binmode@>:StringIO#close@Y:StringIO#close_read@t:StringIO#close_write@:StringIO#closed?@:StringIO#closed_read?@:StringIO#closed_write?@:StringIO#eof@:StringIO#eof?@#:StringIO#fcntl@J:StringIO#flush@]:StringIO#fsync@p:StringIO#pos@:StringIO#pos=@:StringIO#rewind@:StringIO#seek@:StringIO#sync@ :StringIO#sync=@&:StringIO#tell@@:StringIO#each@I:StringIO#each_line@:StringIO#lines@:StringIO#each_byte@:StringIO#bytes@:StringIO#each_char@):StringIO#chars@Q:StringIO#each_codepoint@_:StringIO#codepoints@:StringIO#getc@:StringIO#ungetc@:StringIO#ungetbyte@:StringIO#getbyte@:StringIO#gets@ :StringIO#readlines@M:StringIO#read@:StringIO#write@:StringIO#putc@:StringIO#isatty@:StringIO#tty?@:StringIO#pid@*:StringIO#fileno@B:StringIO#size@Z:StringIO#length@:StringIO#truncate@:StringIO#external_encoding@:StringIO#internal_encoding@:StringIO#set_encoding@:"IO::generic_readable#readchar@:"IO::generic_readable#readbyte@ɩ:"IO::generic_readable#readline@:!IO::generic_readable#sysread@%:%IO::generic_readable#readpartial@R:'IO::generic_readable#read_nonblock@~:IO::generic_writable@˫:IO::generic_writable#<<@ͫ:IO::generic_writable#print@֫: IO::generic_writable#printf@߫:IO::generic_writable#puts@:"IO::generic_writable#syswrite@:(IO::generic_writable#write_nonblock@;e @(:CGI::Escape@*:CGI::Util@:CGI::Escape#escapeHTML@,:CGI::Escape#unescapeHTML@L:CGI::Escape#escape@k:CGI::Escape#unescape@;g @:UDPSocket#initialize@:UDPSocket#connect@:UDPSocket#bind@:UDPSocket#send@7:"UDPSocket#__recvfrom_nonblock@p; @:UNIXServer#initialize@:UNIXServer#accept@:!UNIXServer#__accept_nonblock@:UNIXServer#sysaccept@:UNIXServer#listen@; @:UNIXSocket#initialize@:UNIXSocket#path@8:UNIXSocket#addr@N:UNIXSocket#peeraddr@i:UNIXSocket#recvfrom@:UNIXSocket#send_io@:UNIXSocket#recv_io@:UNIXSocket.socketpair@:UNIXSocket.pair@ ; @K:TCPServer#accept@M: TCPServer#__accept_nonblock@d:TCPServer#sysaccept@t:TCPServer#initialize@:TCPServer#listen@; @:Addrinfo#initialize@:Addrinfo#inspect@[:Addrinfo#inspect_sockaddr@v:Addrinfo.getaddrinfo@:Addrinfo.ip@ :Addrinfo.tcp@#:Addrinfo.udp@A:Addrinfo.unix@_:Addrinfo#afamily@x:Addrinfo#pfamily@:Addrinfo#socktype@:Addrinfo#protocol@:Addrinfo#canonname@:Addrinfo#ipv4?@:Addrinfo#ipv6?@:Addrinfo#unix?@6:Addrinfo#ip?@Q:Addrinfo#ip_unpack@l: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?@Q:Addrinfo#ipv6_v4compat?@b: Addrinfo#ipv6_mc_nodelocal?@s: 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@;:Addrinfo#marshal_dump@f:Addrinfo#marshal_load@t; @:TCPSocket.gethostbyname@:TCPSocket#initialize@;m @O:&BasicSocket.do_not_reverse_lookup@Q:'BasicSocket.do_not_reverse_lookup=@m:BasicSocket.for_fd@:BasicSocket#close_read@:BasicSocket#close_write@:BasicSocket#shutdown@:BasicSocket#setsockopt@:BasicSocket#getsockopt@:BasicSocket#getsockname@::BasicSocket#getpeername@P:BasicSocket#getpeereid@f:BasicSocket#local_address@: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@5:BasicSocket#__sendmsg@>:#BasicSocket#__sendmsg_nonblock@S:BasicSocket#__recvmsg@i:#BasicSocket#__recvmsg_nonblock@}; @:Socket#initialize@:Socket#connect@:Socket#__connect_nonblock@:Socket#bind@:Socket#listen@:Socket#accept@ :Socket#__accept_nonblock@;:Socket#sysaccept@K:Socket#recvfrom@f:Socket#__recvfrom_nonblock@:Socket.socketpair@:Socket.pair@:Socket.gethostname@:Socket.gethostbyname@ :Socket.gethostbyaddr@?:Socket.getservbyname@X:Socket.getservbyport@}:Socket.getaddrinfo@:Socket.getnameinfo@:Socket.sockaddr_in@:Socket.pack_sockaddr_in@:Socket.unpack_sockaddr_in@':Socket.sockaddr_un@F:Socket.pack_sockaddr_un@j:Socket.unpack_sockaddr_un@:Socket.ip_address_list@:Socket::Ifaddr@:Socket::Ifaddr#inspect@:Socket::Ifaddr#name@:Socket::Ifaddr#ifindex@:Socket::Ifaddr#flags@:Socket::Ifaddr#addr@1:Socket::Ifaddr#netmask@G:Socket::Ifaddr#broadaddr@]:Socket::Ifaddr#dstaddr@s:Socket::Ifaddr#vhid@:Socket.getifaddrs@; @ :SOCKSSocket#initialize@ :SOCKSSocket#close@ ; @ ;h @:IPSocket#inspect@:IPSocket#addr@:IPSocket#peeraddr@:IPSocket#recvfrom@:IPSocket.getaddress@":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@F:#Socket::Constants::SOCK_PACKET@:Socket::AF_UNSPEC@R:!Socket::Constants::AF_UNSPEC@:Socket::PF_UNSPEC@^:!Socket::Constants::PF_UNSPEC@(:Socket::AF_INET@j:Socket::Constants::AF_INET@4:Socket::PF_INET@v:Socket::Constants::PF_INET@@:Socket::AF_INET6@: Socket::Constants::AF_INET6@L:Socket::PF_INET6@: Socket::Constants::PF_INET6@X:Socket::AF_UNIX@:Socket::Constants::AF_UNIX@d:Socket::PF_UNIX@:Socket::Constants::PF_UNIX@p:Socket::AF_AX25@:Socket::Constants::AF_AX25@|:Socket::PF_AX25@:Socket::Constants::PF_AX25@:Socket::AF_IPX@: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@6:Socket::Constants::PF_PUP@:Socket::AF_CHAOS@B: Socket::Constants::AF_CHAOS@ :Socket::PF_CHAOS@N: Socket::Constants::PF_CHAOS@:Socket::AF_NS@Z:Socket::Constants::AF_NS@$:Socket::PF_NS@f:Socket::Constants::PF_NS@0:Socket::AF_ISO@r:Socket::Constants::AF_ISO@<:Socket::PF_ISO@~:Socket::Constants::PF_ISO@H:Socket::AF_OSI@:Socket::Constants::AF_OSI@T:Socket::PF_OSI@:Socket::Constants::PF_OSI@`:Socket::AF_ECMA@:Socket::Constants::AF_ECMA@l:Socket::PF_ECMA@:Socket::Constants::PF_ECMA@x:Socket::AF_DATAKIT@:"Socket::Constants::AF_DATAKIT@:Socket::PF_DATAKIT@:"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_DLI@:Socket::Constants::AF_DLI@:Socket::PF_DLI@&:Socket::Constants::PF_DLI@:Socket::AF_LAT@2:Socket::Constants::AF_LAT@:Socket::PF_LAT@>:Socket::Constants::PF_LAT@:Socket::AF_HYLINK@J:!Socket::Constants::AF_HYLINK@:Socket::PF_HYLINK@V:!Socket::Constants::PF_HYLINK@ :Socket::AF_ROUTE@b: Socket::Constants::AF_ROUTE@,:Socket::PF_ROUTE@n: Socket::Constants::PF_ROUTE@8:Socket::AF_LINK@z:Socket::Constants::AF_LINK@D:Socket::PF_LINK@:Socket::Constants::PF_LINK@P:Socket::AF_COIP@:Socket::Constants::AF_COIP@\:Socket::PF_COIP@:Socket::Constants::PF_COIP@h:Socket::AF_CNT@:Socket::Constants::AF_CNT@t: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@:Socket::AF_SYSTEM@":!Socket::Constants::AF_SYSTEM@:Socket::PF_SYSTEM@,:!Socket::Constants::PF_SYSTEM@:Socket::AF_NETBIOS@6:"Socket::Constants::AF_NETBIOS@:Socket::PF_NETBIOS@B:"Socket::Constants::PF_NETBIOS@ :Socket::AF_PPP@N:Socket::Constants::AF_PPP@:Socket::PF_PPP@Z:Socket::Constants::PF_PPP@$:Socket::AF_ATM@f:Socket::Constants::AF_ATM@0:Socket::PF_ATM@r:Socket::Constants::PF_ATM@<:Socket::AF_NETGRAPH@~:#Socket::Constants::AF_NETGRAPH@H:Socket::PF_NETGRAPH@:#Socket::Constants::PF_NETGRAPH@T:Socket::AF_MAX@:Socket::Constants::AF_MAX@`:Socket::PF_MAX@:Socket::Constants::PF_MAX@l:Socket::AF_PACKET@:!Socket::Constants::AF_PACKET@x: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::PF_KEY@:Socket::Constants::PF_KEY@:Socket::MSG_OOB@:Socket::Constants::MSG_OOB@:Socket::MSG_PEEK@: Socket::Constants::MSG_PEEK@:Socket::MSG_DONTROUTE@:%Socket::Constants::MSG_DONTROUTE@:Socket::MSG_EOR@ :Socket::Constants::MSG_EOR@:Socket::MSG_TRUNC@,:!Socket::Constants::MSG_TRUNC@:Socket::MSG_CTRUNC@8:"Socket::Constants::MSG_CTRUNC@:Socket::MSG_WAITALL@D:#Socket::Constants::MSG_WAITALL@:Socket::MSG_DONTWAIT@P:$Socket::Constants::MSG_DONTWAIT@:Socket::MSG_EOF@\:Socket::Constants::MSG_EOF@&:Socket::MSG_FLUSH@h:!Socket::Constants::MSG_FLUSH@2:Socket::MSG_HOLD@t: Socket::Constants::MSG_HOLD@>:Socket::MSG_SEND@: Socket::Constants::MSG_SEND@J:Socket::MSG_HAVEMORE@:$Socket::Constants::MSG_HAVEMORE@V:Socket::MSG_RCVMORE@:#Socket::Constants::MSG_RCVMORE@b:Socket::MSG_COMPAT@:"Socket::Constants::MSG_COMPAT@n:Socket::MSG_PROXY@:!Socket::Constants::MSG_PROXY@z:Socket::MSG_FIN@:Socket::Constants::MSG_FIN@:Socket::MSG_SYN@:Socket::Constants::MSG_SYN@:Socket::MSG_CONFIRM@:#Socket::Constants::MSG_CONFIRM@:Socket::MSG_RST@:Socket::Constants::MSG_RST@:Socket::MSG_ERRQUEUE@:$Socket::Constants::MSG_ERRQUEUE@:Socket::MSG_NOSIGNAL@:$Socket::Constants::MSG_NOSIGNAL@:Socket::MSG_MORE@: Socket::Constants::MSG_MORE@:Socket::MSG_FASTOPEN@ :$Socket::Constants::MSG_FASTOPEN@:Socket::SOL_SOCKET@:"Socket::Constants::SOL_SOCKET@:Socket::SOL_IP@":Socket::Constants::SOL_IP@:Socket::SOL_IPX@.:Socket::Constants::SOL_IPX@:Socket::SOL_AX25@:: Socket::Constants::SOL_AX25@:Socket::SOL_ATALK@F:!Socket::Constants::SOL_ATALK@:Socket::SOL_TCP@R:Socket::Constants::SOL_TCP@:Socket::SOL_UDP@^:Socket::Constants::SOL_UDP@(:Socket::IPPROTO_IP@j:"Socket::Constants::IPPROTO_IP@4:Socket::IPPROTO_ICMP@v:$Socket::Constants::IPPROTO_ICMP@@:Socket::IPPROTO_IGMP@:$Socket::Constants::IPPROTO_IGMP@L:Socket::IPPROTO_GGP@:#Socket::Constants::IPPROTO_GGP@X:Socket::IPPROTO_TCP@:#Socket::Constants::IPPROTO_TCP@d:Socket::IPPROTO_EGP@:#Socket::Constants::IPPROTO_EGP@p: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@:Socket::IPPROTO_ND@:"Socket::Constants::IPPROTO_ND@:Socket::IPPROTO_TP@:"Socket::Constants::IPPROTO_TP@:Socket::IPPROTO_XTP@:#Socket::Constants::IPPROTO_XTP@:Socket::IPPROTO_EON@:#Socket::Constants::IPPROTO_EON@:Socket::IPPROTO_BIP@:#Socket::Constants::IPPROTO_BIP@:Socket::IPPROTO_AH@:"Socket::Constants::IPPROTO_AH@:Socket::IPPROTO_DSTOPTS@(:'Socket::Constants::IPPROTO_DSTOPTS@:Socket::IPPROTO_ESP@4:#Socket::Constants::IPPROTO_ESP@:Socket::IPPROTO_FRAGMENT@@:(Socket::Constants::IPPROTO_FRAGMENT@ :Socket::IPPROTO_HOPOPTS@L:'Socket::Constants::IPPROTO_HOPOPTS@:Socket::IPPROTO_ICMPV6@X:&Socket::Constants::IPPROTO_ICMPV6@":Socket::IPPROTO_IPV6@d:$Socket::Constants::IPPROTO_IPV6@.:Socket::IPPROTO_NONE@p:$Socket::Constants::IPPROTO_NONE@::Socket::IPPROTO_ROUTING@|:'Socket::Constants::IPPROTO_ROUTING@F:Socket::IPPROTO_RAW@:#Socket::Constants::IPPROTO_RAW@R:Socket::IPPROTO_MAX@:#Socket::Constants::IPPROTO_MAX@^:Socket::IPPORT_RESERVED@:'Socket::Constants::IPPORT_RESERVED@j: Socket::IPPORT_USERRESERVED@:+Socket::Constants::IPPORT_USERRESERVED@v:Socket::INADDR_ANY@:"Socket::Constants::INADDR_ANY@:Socket::INADDR_BROADCAST@:(Socket::Constants::INADDR_BROADCAST@:Socket::INADDR_LOOPBACK@:'Socket::Constants::INADDR_LOOPBACK@: Socket::INADDR_UNSPEC_GROUP@:+Socket::Constants::INADDR_UNSPEC_GROUP@:"Socket::INADDR_ALLHOSTS_GROUP@:-Socket::Constants::INADDR_ALLHOSTS_GROUP@:#Socket::INADDR_MAX_LOCAL_GROUP@:.Socket::Constants::INADDR_MAX_LOCAL_GROUP@:Socket::INADDR_NONE@:#Socket::Constants::INADDR_NONE@:Socket::IP_OPTIONS@ :"Socket::Constants::IP_OPTIONS@:Socket::IP_HDRINCL@:"Socket::Constants::IP_HDRINCL@:Socket::IP_TOS@$:Socket::Constants::IP_TOS@:Socket::IP_TTL@0:Socket::Constants::IP_TTL@:Socket::IP_RECVOPTS@<:#Socket::Constants::IP_RECVOPTS@:Socket::IP_RECVRETOPTS@H:&Socket::Constants::IP_RECVRETOPTS@:Socket::IP_RECVDSTADDR@T:&Socket::Constants::IP_RECVDSTADDR@:Socket::IP_RETOPTS@`:"Socket::Constants::IP_RETOPTS@*:Socket::IP_MINTTL@l:!Socket::Constants::IP_MINTTL@6:Socket::IP_DONTFRAG@x:#Socket::Constants::IP_DONTFRAG@B:Socket::IP_SENDSRCADDR@:&Socket::Constants::IP_SENDSRCADDR@N:Socket::IP_ONESBCAST@:$Socket::Constants::IP_ONESBCAST@Z:Socket::IP_RECVTTL@:"Socket::Constants::IP_RECVTTL@f:Socket::IP_RECVIF@:!Socket::Constants::IP_RECVIF@r: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@:Socket::IP_MULTICAST_LOOP@:)Socket::Constants::IP_MULTICAST_LOOP@:Socket::IP_ADD_MEMBERSHIP@:)Socket::Constants::IP_ADD_MEMBERSHIP@:Socket::IP_DROP_MEMBERSHIP@:*Socket::Constants::IP_DROP_MEMBERSHIP@:%Socket::IP_DEFAULT_MULTICAST_TTL@:0Socket::Constants::IP_DEFAULT_MULTICAST_TTL@:&Socket::IP_DEFAULT_MULTICAST_LOOP@:1Socket::Constants::IP_DEFAULT_MULTICAST_LOOP@:Socket::IP_MAX_MEMBERSHIPS@ :*Socket::Constants::IP_MAX_MEMBERSHIPS@:Socket::IP_ROUTER_ALERT@,:'Socket::Constants::IP_ROUTER_ALERT@:Socket::IP_PKTINFO@8:"Socket::Constants::IP_PKTINFO@:Socket::IP_PKTOPTIONS@D:%Socket::Constants::IP_PKTOPTIONS@:Socket::IP_MTU_DISCOVER@P:'Socket::Constants::IP_MTU_DISCOVER@:Socket::IP_RECVERR@\:"Socket::Constants::IP_RECVERR@&:Socket::IP_RECVTOS@h:"Socket::Constants::IP_RECVTOS@2:Socket::IP_MTU@t:Socket::Constants::IP_MTU@>:Socket::IP_FREEBIND@:#Socket::Constants::IP_FREEBIND@J:Socket::IP_IPSEC_POLICY@:'Socket::Constants::IP_IPSEC_POLICY@V:Socket::IP_XFRM_POLICY@:&Socket::Constants::IP_XFRM_POLICY@b:Socket::IP_PASSSEC@:"Socket::Constants::IP_PASSSEC@l:Socket::IP_TRANSPARENT@:&Socket::Constants::IP_TRANSPARENT@x: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@:Socket::IP_UNBLOCK_SOURCE@:)Socket::Constants::IP_UNBLOCK_SOURCE@:Socket::IP_BLOCK_SOURCE@:'Socket::Constants::IP_BLOCK_SOURCE@:%Socket::IP_ADD_SOURCE_MEMBERSHIP@:0Socket::Constants::IP_ADD_SOURCE_MEMBERSHIP@:&Socket::IP_DROP_SOURCE_MEMBERSHIP@:1Socket::Constants::IP_DROP_SOURCE_MEMBERSHIP@:Socket::IP_MSFILTER@:#Socket::Constants::IP_MSFILTER@:Socket::MCAST_JOIN_GROUP@:(Socket::Constants::MCAST_JOIN_GROUP@:Socket::MCAST_BLOCK_SOURCE@&:*Socket::Constants::MCAST_BLOCK_SOURCE@:!Socket::MCAST_UNBLOCK_SOURCE@2:,Socket::Constants::MCAST_UNBLOCK_SOURCE@:Socket::MCAST_LEAVE_GROUP@>:)Socket::Constants::MCAST_LEAVE_GROUP@:$Socket::MCAST_JOIN_SOURCE_GROUP@J:/Socket::Constants::MCAST_JOIN_SOURCE_GROUP@:%Socket::MCAST_LEAVE_SOURCE_GROUP@V:0Socket::Constants::MCAST_LEAVE_SOURCE_GROUP@ :Socket::MCAST_MSFILTER@b:&Socket::Constants::MCAST_MSFILTER@,:Socket::MCAST_EXCLUDE@n:%Socket::Constants::MCAST_EXCLUDE@8:Socket::MCAST_INCLUDE@z:%Socket::Constants::MCAST_INCLUDE@D:Socket::SO_DEBUG@: Socket::Constants::SO_DEBUG@P:Socket::SO_REUSEADDR@:$Socket::Constants::SO_REUSEADDR@\:Socket::SO_REUSEPORT@:$Socket::Constants::SO_REUSEPORT@h:Socket::SO_TYPE@:Socket::Constants::SO_TYPE@t: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@:Socket::SO_SNDBUFFORCE@:&Socket::Constants::SO_SNDBUFFORCE@:Socket::SO_RCVBUFFORCE@:&Socket::Constants::SO_RCVBUFFORCE@:Socket::SO_KEEPALIVE@ :$Socket::Constants::SO_KEEPALIVE@:Socket::SO_OOBINLINE@:$Socket::Constants::SO_OOBINLINE@:Socket::SO_NO_CHECK@":#Socket::Constants::SO_NO_CHECK@:Socket::SO_PRIORITY@.:#Socket::Constants::SO_PRIORITY@:Socket::SO_LINGER@::!Socket::Constants::SO_LINGER@:Socket::SO_PASSCRED@F:#Socket::Constants::SO_PASSCRED@:Socket::SO_PEERCRED@R:#Socket::Constants::SO_PEERCRED@:Socket::SO_RCVLOWAT@^:#Socket::Constants::SO_RCVLOWAT@(:Socket::SO_SNDLOWAT@j:#Socket::Constants::SO_SNDLOWAT@4:Socket::SO_RCVTIMEO@v:#Socket::Constants::SO_RCVTIMEO@@:Socket::SO_SNDTIMEO@:#Socket::Constants::SO_SNDTIMEO@L:Socket::SO_ACCEPTCONN@:%Socket::Constants::SO_ACCEPTCONN@X:Socket::SO_USELOOPBACK@:&Socket::Constants::SO_USELOOPBACK@d:Socket::SO_ACCEPTFILTER@:'Socket::Constants::SO_ACCEPTFILTER@p: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@:Socket::SO_NKE@:Socket::Constants::SO_NKE@:Socket::SO_NOSIGPIPE@:$Socket::Constants::SO_NOSIGPIPE@:'Socket::SO_SECURITY_AUTHENTICATION@:2Socket::Constants::SO_SECURITY_AUTHENTICATION@:-Socket::SO_SECURITY_ENCRYPTION_TRANSPORT@:8Socket::Constants::SO_SECURITY_ENCRYPTION_TRANSPORT@:+Socket::SO_SECURITY_ENCRYPTION_NETWORK@:6Socket::Constants::SO_SECURITY_ENCRYPTION_NETWORK@:Socket::SO_BINDTODEVICE@:'Socket::Constants::SO_BINDTODEVICE@:Socket::SO_ATTACH_FILTER@$:(Socket::Constants::SO_ATTACH_FILTER@:Socket::SO_DETACH_FILTER@0:(Socket::Constants::SO_DETACH_FILTER@:Socket::SO_GET_FILTER@<:%Socket::Constants::SO_GET_FILTER@:Socket::SO_PEERNAME@H:#Socket::Constants::SO_PEERNAME@:Socket::SO_TIMESTAMP@T:$Socket::Constants::SO_TIMESTAMP@:Socket::SO_TIMESTAMPNS@`:&Socket::Constants::SO_TIMESTAMPNS@*:Socket::SO_BINTIME@l:"Socket::Constants::SO_BINTIME@6:Socket::SO_RECVUCRED@x:$Socket::Constants::SO_RECVUCRED@B:Socket::SO_MAC_EXEMPT@:%Socket::Constants::SO_MAC_EXEMPT@N:Socket::SO_ALLZONES@:#Socket::Constants::SO_ALLZONES@Z:Socket::SO_PEERSEC@:"Socket::Constants::SO_PEERSEC@f:Socket::SO_PASSSEC@:"Socket::Constants::SO_PASSSEC@r: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@:Socket::SO_RXQ_OVFL@:#Socket::Constants::SO_RXQ_OVFL@:Socket::SO_WIFI_STATUS@:&Socket::Constants::SO_WIFI_STATUS@:Socket::SO_PEEK_OFF@:#Socket::Constants::SO_PEEK_OFF@:Socket::SO_NOFCS@: Socket::Constants::SO_NOFCS@:Socket::SO_LOCK_FILTER@:&Socket::Constants::SO_LOCK_FILTER@: Socket::SO_SELECT_ERR_QUEUE@ :+Socket::Constants::SO_SELECT_ERR_QUEUE@:Socket::SO_BUSY_POLL@,:$Socket::Constants::SO_BUSY_POLL@:Socket::SO_MAX_PACING_RATE@8:*Socket::Constants::SO_MAX_PACING_RATE@:Socket::SO_BPF_EXTENSIONS@D:)Socket::Constants::SO_BPF_EXTENSIONS@:Socket::SOPRI_INTERACTIVE@P:)Socket::Constants::SOPRI_INTERACTIVE@:Socket::SOPRI_NORMAL@\:$Socket::Constants::SOPRI_NORMAL@&:Socket::SOPRI_BACKGROUND@h:(Socket::Constants::SOPRI_BACKGROUND@2:Socket::IPX_TYPE@t: Socket::Constants::IPX_TYPE@>:Socket::TCP_NODELAY@~:#Socket::Constants::TCP_NODELAY@H:Socket::TCP_MAXSEG@:"Socket::Constants::TCP_MAXSEG@T:Socket::TCP_CORK@: Socket::Constants::TCP_CORK@`:Socket::TCP_DEFER_ACCEPT@:(Socket::Constants::TCP_DEFER_ACCEPT@l:Socket::TCP_INFO@: Socket::Constants::TCP_INFO@x:Socket::TCP_KEEPCNT@:#Socket::Constants::TCP_KEEPCNT@:Socket::TCP_KEEPIDLE@:$Socket::Constants::TCP_KEEPIDLE@:Socket::TCP_KEEPINTVL@:%Socket::Constants::TCP_KEEPINTVL@:Socket::TCP_LINGER2@:#Socket::Constants::TCP_LINGER2@:Socket::TCP_MD5SIG@:"Socket::Constants::TCP_MD5SIG@:Socket::TCP_NOOPT@:!Socket::Constants::TCP_NOOPT@:Socket::TCP_NOPUSH@:"Socket::Constants::TCP_NOPUSH@:Socket::TCP_QUICKACK@:$Socket::Constants::TCP_QUICKACK@:Socket::TCP_SYNCNT@:"Socket::Constants::TCP_SYNCNT@:Socket::TCP_WINDOW_CLAMP@&:(Socket::Constants::TCP_WINDOW_CLAMP@:Socket::TCP_FASTOPEN@2:$Socket::Constants::TCP_FASTOPEN@:Socket::TCP_CONGESTION@>:&Socket::Constants::TCP_CONGESTION@:$Socket::TCP_COOKIE_TRANSACTIONS@J:/Socket::Constants::TCP_COOKIE_TRANSACTIONS@:Socket::TCP_QUEUE_SEQ@V:%Socket::Constants::TCP_QUEUE_SEQ@ :Socket::TCP_REPAIR@b:"Socket::Constants::TCP_REPAIR@,:Socket::TCP_REPAIR_OPTIONS@n:*Socket::Constants::TCP_REPAIR_OPTIONS@8:Socket::TCP_REPAIR_QUEUE@z:(Socket::Constants::TCP_REPAIR_QUEUE@D:Socket::TCP_THIN_DUPACK@:'Socket::Constants::TCP_THIN_DUPACK@P:%Socket::TCP_THIN_LINEAR_TIMEOUTS@:0Socket::Constants::TCP_THIN_LINEAR_TIMEOUTS@\:Socket::TCP_TIMESTAMP@:%Socket::Constants::TCP_TIMESTAMP@h:Socket::TCP_USER_TIMEOUT@:(Socket::Constants::TCP_USER_TIMEOUT@t: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@:Socket::EAI_FAMILY@:"Socket::Constants::EAI_FAMILY@:Socket::EAI_MEMORY@:"Socket::Constants::EAI_MEMORY@:Socket::EAI_NODATA@ :"Socket::Constants::EAI_NODATA@:Socket::EAI_NONAME@:"Socket::Constants::EAI_NONAME@:Socket::EAI_OVERFLOW@":$Socket::Constants::EAI_OVERFLOW@:Socket::EAI_SERVICE@.:#Socket::Constants::EAI_SERVICE@:Socket::EAI_SOCKTYPE@::$Socket::Constants::EAI_SOCKTYPE@:Socket::EAI_SYSTEM@F:"Socket::Constants::EAI_SYSTEM@:Socket::EAI_BADHINTS@R:$Socket::Constants::EAI_BADHINTS@:Socket::EAI_PROTOCOL@^:$Socket::Constants::EAI_PROTOCOL@(:Socket::EAI_MAX@j:Socket::Constants::EAI_MAX@4:Socket::AI_PASSIVE@v:"Socket::Constants::AI_PASSIVE@@:Socket::AI_CANONNAME@:$Socket::Constants::AI_CANONNAME@L:Socket::AI_NUMERICHOST@:&Socket::Constants::AI_NUMERICHOST@X:Socket::AI_NUMERICSERV@:&Socket::Constants::AI_NUMERICSERV@d:Socket::AI_MASK@:Socket::Constants::AI_MASK@p: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@:Socket::AI_DEFAULT@:"Socket::Constants::AI_DEFAULT@:Socket::NI_MAXHOST@:"Socket::Constants::NI_MAXHOST@:Socket::NI_MAXSERV@:"Socket::Constants::NI_MAXSERV@:Socket::NI_NOFQDN@:!Socket::Constants::NI_NOFQDN@:Socket::NI_NUMERICHOST@:&Socket::Constants::NI_NUMERICHOST@:Socket::NI_NAMEREQD@:#Socket::Constants::NI_NAMEREQD@:Socket::NI_NUMERICSERV@*:&Socket::Constants::NI_NUMERICSERV@:Socket::NI_DGRAM@6: Socket::Constants::NI_DGRAM@:Socket::SHUT_RD@B:Socket::Constants::SHUT_RD@ :Socket::SHUT_WR@N:Socket::Constants::SHUT_WR@:Socket::SHUT_RDWR@Z:!Socket::Constants::SHUT_RDWR@$:Socket::IPV6_JOIN_GROUP@f:'Socket::Constants::IPV6_JOIN_GROUP@0:Socket::IPV6_LEAVE_GROUP@r:(Socket::Constants::IPV6_LEAVE_GROUP@<: Socket::IPV6_MULTICAST_HOPS@~:+Socket::Constants::IPV6_MULTICAST_HOPS@H:Socket::IPV6_MULTICAST_IF@:)Socket::Constants::IPV6_MULTICAST_IF@T: Socket::IPV6_MULTICAST_LOOP@:+Socket::Constants::IPV6_MULTICAST_LOOP@`:Socket::IPV6_UNICAST_HOPS@:)Socket::Constants::IPV6_UNICAST_HOPS@l:Socket::IPV6_V6ONLY@:#Socket::Constants::IPV6_V6ONLY@x:Socket::IPV6_CHECKSUM@:%Socket::Constants::IPV6_CHECKSUM@:Socket::IPV6_DONTFRAG@:%Socket::Constants::IPV6_DONTFRAG@:Socket::IPV6_DSTOPTS@:$Socket::Constants::IPV6_DSTOPTS@:Socket::IPV6_HOPLIMIT@:%Socket::Constants::IPV6_HOPLIMIT@:Socket::IPV6_HOPOPTS@:$Socket::Constants::IPV6_HOPOPTS@:Socket::IPV6_NEXTHOP@:$Socket::Constants::IPV6_NEXTHOP@:Socket::IPV6_PATHMTU@:$Socket::Constants::IPV6_PATHMTU@:Socket::IPV6_PKTINFO@:$Socket::Constants::IPV6_PKTINFO@:Socket::IPV6_RECVDSTOPTS@:(Socket::Constants::IPV6_RECVDSTOPTS@:Socket::IPV6_RECVHOPLIMIT@&:)Socket::Constants::IPV6_RECVHOPLIMIT@:Socket::IPV6_RECVHOPOPTS@2:(Socket::Constants::IPV6_RECVHOPOPTS@:Socket::IPV6_RECVPKTINFO@>:(Socket::Constants::IPV6_RECVPKTINFO@:Socket::IPV6_RECVRTHDR@J:&Socket::Constants::IPV6_RECVRTHDR@:Socket::IPV6_RECVTCLASS@V:'Socket::Constants::IPV6_RECVTCLASS@ :Socket::IPV6_RTHDR@b:"Socket::Constants::IPV6_RTHDR@,:Socket::IPV6_RTHDRDSTOPTS@n:)Socket::Constants::IPV6_RTHDRDSTOPTS@8:Socket::IPV6_RTHDR_TYPE_0@z:)Socket::Constants::IPV6_RTHDR_TYPE_0@D:Socket::IPV6_RECVPATHMTU@:(Socket::Constants::IPV6_RECVPATHMTU@P:Socket::IPV6_TCLASS@:#Socket::Constants::IPV6_TCLASS@\:Socket::IPV6_USE_MIN_MTU@:(Socket::Constants::IPV6_USE_MIN_MTU@h:Socket::INET_ADDRSTRLEN@:'Socket::Constants::INET_ADDRSTRLEN@t: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@:Socket::SCM_TIMESTAMP@:%Socket::Constants::SCM_TIMESTAMP@:Socket::SCM_TIMESTAMPNS@:'Socket::Constants::SCM_TIMESTAMPNS@:Socket::SCM_TIMESTAMPING@ :(Socket::Constants::SCM_TIMESTAMPING@:Socket::SCM_BINTIME@:#Socket::Constants::SCM_BINTIME@:Socket::SCM_CREDENTIALS@":'Socket::Constants::SCM_CREDENTIALS@:Socket::SCM_CREDS@.:!Socket::Constants::SCM_CREDS@:Socket::SCM_UCRED@::!Socket::Constants::SCM_UCRED@:Socket::SCM_WIFI_STATUS@F:'Socket::Constants::SCM_WIFI_STATUS@:Socket::LOCAL_PEERCRED@R:&Socket::Constants::LOCAL_PEERCRED@:Socket::LOCAL_CREDS@^:#Socket::Constants::LOCAL_CREDS@(:Socket::LOCAL_CONNWAIT@j:&Socket::Constants::LOCAL_CONNWAIT@4:Socket::IFF_802_1Q_VLAN@v:'Socket::Constants::IFF_802_1Q_VLAN@@:Socket::IFF_ALLMULTI@:$Socket::Constants::IFF_ALLMULTI@L:Socket::IFF_ALTPHYS@:#Socket::Constants::IFF_ALTPHYS@X:Socket::IFF_AUTOMEDIA@:%Socket::Constants::IFF_AUTOMEDIA@d:Socket::IFF_BONDING@:#Socket::Constants::IFF_BONDING@p: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@: Socket::IFF_DISABLE_NETPOLL@:+Socket::Constants::IFF_DISABLE_NETPOLL@:Socket::IFF_DONT_BRIDGE@:'Socket::Constants::IFF_DONT_BRIDGE@:Socket::IFF_DORMANT@:#Socket::Constants::IFF_DORMANT@:Socket::IFF_DRV_OACTIVE@:'Socket::Constants::IFF_DRV_OACTIVE@:Socket::IFF_DRV_RUNNING@:'Socket::Constants::IFF_DRV_RUNNING@:Socket::IFF_DYING@:!Socket::Constants::IFF_DYING@:Socket::IFF_DYNAMIC@*:#Socket::Constants::IFF_DYNAMIC@:Socket::IFF_EBRIDGE@6:#Socket::Constants::IFF_EBRIDGE@:Socket::IFF_ECHO@B: Socket::Constants::IFF_ECHO@ :Socket::IFF_ISATAP@N:"Socket::Constants::IFF_ISATAP@:Socket::IFF_LINK0@Z:!Socket::Constants::IFF_LINK0@$:Socket::IFF_LINK1@f:!Socket::Constants::IFF_LINK1@0:Socket::IFF_LINK2@r:!Socket::Constants::IFF_LINK2@<:!Socket::IFF_LIVE_ADDR_CHANGE@~:,Socket::Constants::IFF_LIVE_ADDR_CHANGE@H:Socket::IFF_LOOPBACK@:$Socket::Constants::IFF_LOOPBACK@T:Socket::IFF_LOWER_UP@:$Socket::Constants::IFF_LOWER_UP@`:Socket::IFF_MACVLAN_PORT@:(Socket::Constants::IFF_MACVLAN_PORT@l:Socket::IFF_MASTER@:"Socket::Constants::IFF_MASTER@x: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@:Socket::IFF_MONITOR@:#Socket::Constants::IFF_MONITOR@:Socket::IFF_MULTICAST@:%Socket::Constants::IFF_MULTICAST@:Socket::IFF_NOARP@:!Socket::Constants::IFF_NOARP@:Socket::IFF_NOTRAILERS@:&Socket::Constants::IFF_NOTRAILERS@:Socket::IFF_OACTIVE@:#Socket::Constants::IFF_OACTIVE@:Socket::IFF_OVS_DATAPATH@:(Socket::Constants::IFF_OVS_DATAPATH@:Socket::IFF_POINTOPOINT@&:'Socket::Constants::IFF_POINTOPOINT@:Socket::IFF_PORTSEL@2:#Socket::Constants::IFF_PORTSEL@:Socket::IFF_PPROMISC@>:$Socket::Constants::IFF_PPROMISC@:Socket::IFF_PROMISC@J:#Socket::Constants::IFF_PROMISC@:Socket::IFF_RENAMING@V:$Socket::Constants::IFF_RENAMING@ :Socket::IFF_ROUTE@b:!Socket::Constants::IFF_ROUTE@,:Socket::IFF_RUNNING@n:#Socket::Constants::IFF_RUNNING@8:Socket::IFF_SIMPLEX@z:#Socket::Constants::IFF_SIMPLEX@D:Socket::IFF_SLAVE@:!Socket::Constants::IFF_SLAVE@P:Socket::IFF_SLAVE_INACTIVE@:*Socket::Constants::IFF_SLAVE_INACTIVE@\:Socket::IFF_SLAVE_NEEDARP@:)Socket::Constants::IFF_SLAVE_NEEDARP@h:Socket::IFF_SMART@:!Socket::Constants::IFF_SMART@t: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@:Socket::IFF_UP@:Socket::Constants::IFF_UP@:Socket::IFF_WAN_HDLC@:$Socket::Constants::IFF_WAN_HDLC@:!Socket::IFF_XMIT_DST_RELEASE@ :,Socket::Constants::IFF_XMIT_DST_RELEASE@:Socket::IFF_VOLATILE@:$Socket::Constants::IFF_VOLATILE@:Socket::IFF_CANTCHANGE@":&Socket::Constants::IFF_CANTCHANGE@; @2 :Date::MONTHNAMES@4 :Date::ABBR_MONTHNAMES@@ :Date::DAYNAMES@L :Date::ABBR_DAYNAMES@X :Date::ITALY@d :Date::ENGLAND@p :Date::JULIAN@| :Date::GREGORIAN@ :Date.valid_jd?@ :Date.valid_ordinal?@ :Date.valid_civil?@ :Date.valid_date?@ :Date.valid_commercial?@A :Date.julian_leap?@d :Date.gregorian_leap?@ :Date.leap?@ :Date.new!@ : Date.jd@ :Date.ordinal@ :Date.civil@ :Date.commercial@D :Date.weeknum@^ :Date.nth_kday@k :Date.today@x :Date._strptime@ :Date.strptime@ :Date._parse@ :Date.parse@ :Date._iso8601@:Date.iso8601@#:Date._rfc3339@=:Date.rfc3339@\:Date._xmlschema@v:Date.xmlschema@:Date._rfc2822@:Date._rfc822@:Date.rfc2822@ :Date.rfc822@/:Date._httpdate@S:Date.httpdate@r:Date._jisx0301@:Date.jisx0301@:Date#initialize@:Date#initialize_copy@:Date#fill@: Date#ajd@:Date#amjd@: Date#jd@: Date#mjd@5: Date#ld@P:Date#year@k:Date#yday@: Date#mon@:Date#month@:Date#mday@: Date#day@:Date#day_fraction@?:Date#cwyear@U:Date#cweek@p:Date#cwday@:Date#wnum0@:Date#wnum1@:Date#wday@:Date#sunday?@:Date#monday?@:Date#tuesday?@:Date#wednesday?@*:Date#thursday?@E:Date#friday?@`:Date#saturday?@{:Date#nth_kday?@:Date#hour@: Date#min@:Date#minute@: Date#sec@:Date#second@:Date#julian?@:Date#gregorian?@:Date#leap?@:Date#start@6:Date#new_start@Q:Date#italy@k:Date#england@:Date#julian@:Date#gregorian@: Date#+@: Date#-@:Date#next_day@:Date#prev_day@:Date#next@+:Date#succ@I: Date#>>@f: Date#<<@:Date#next_month@:Date#prev_month@:Date#next_year@:Date#prev_year@:Date#step@:Date#upto@1:Date#downto@_: Date#<=>@: Date#===@:Date#eql?@:Date#hash@:Date#to_s@:Date#inspect_raw@ :Date#inspect@:Date#strftime@1:Date#asctime@P:Date#ctime@x:Date#iso8601@:Date#xmlschema@:Date#rfc3339@:Date#rfc2822@ :Date#rfc822@1:Date#httpdate@X:Date#jisx0301@s:Date#marshal_dump_old@:Date#marshal_dump@:Date#marshal_load@:Date._load@; @y:DateTime.jd@{:DateTime.ordinal@:DateTime.civil@:DateTime.new@:DateTime.commercial@:DateTime.weeknum@:DateTime.nth_kday@:DateTime.now@,:DateTime._strptime@F:DateTime.strptime@e:DateTime.parse@:DateTime.iso8601@:DateTime.rfc3339@:DateTime.xmlschema@:DateTime.rfc2822@:DateTime.rfc822@ :DateTime.httpdate@0:DateTime.jisx0301@J:DateTime#hour@d:DateTime#min@:DateTime#minute@:DateTime#sec@:DateTime#second@:DateTime#sec_fraction@:DateTime#second_fraction@;:DateTime#offset@X:DateTime#zone@n:DateTime#new_offset@:DateTime#to_s@:DateTime#strftime@:DateTime#iso8601@:DateTime#xmlschema@ :DateTime#rfc3339@::DateTime#jisx0301@Y;2@O:Time#to_time@O:Time#to_date@P:Time#to_datetime@-P:Date#to_time@:Date#to_date@:Date#to_datetime@:DateTime#to_time@x:DateTime#to_date@:DateTime#to_datetime@:Date.test_civil@:Date.test_ordinal@":Date.test_commercial@.:Date.test_weeknum@::Date.test_nth_kday@F:Date.test_unit_conv@R:Date.test_all@^:Socket::AncillaryData@.:%Socket::AncillaryData#initialize@0:"Socket::AncillaryData#inspect@V:!Socket::AncillaryData#family@q: Socket::AncillaryData#level@:Socket::AncillaryData#type@:Socket::AncillaryData#data@:#Socket::AncillaryData#cmsg_is?@;z @:Socket::AncillaryData#int@&;| @A:&Socket::AncillaryData#unix_rights@^:$Socket::AncillaryData#timestamp@z; @:%Socket::AncillaryData#ip_pktinfo@; @:'Socket::AncillaryData#ipv6_pktinfo@:,Socket::AncillaryData#ipv6_pktinfo_addr@:/Socket::AncillaryData#ipv6_pktinfo_ifindex@(:Socket::Option@P:Socket::Option#initialize@R:Socket::Option#family@y:Socket::Option#level@:Socket::Option#optname@:Socket::Option#data@:Socket::Option#inspect@; @ :Socket::Option#int@3 ; @N :Socket::Option#byte@t ; @ :Socket::Option#bool@ ; @ :Socket::Option#linger@ ; @ :&Socket::Option#ipv4_multicast_ttl@# ; @> :'Socket::Option#ipv4_multicast_loop@X :Socket::Option#unpack@s :Socket::Option#to_s@ ; @:PTY#getpty@:PTY.getpty@,:PTY#spawn@|:PTY.spawn@:PTY.check@!: PTY.open@U:PTY::ChildExited#status@:Etc::Group@:Struct::Group@c:Group.eacho; ; F; ;;;;I"Group.each;T;[;[[@xci2;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; @5;@F;Ao;B;CT;Di;Ei1;!o;2 ;30;40;50;;u;!@;70;F0;"I"sstatic VALUE etc_each_group(VALUE obj) { RETURN_ENUMERATOR(obj, 0, 0); each_group(); return obj; };T;#I"static VALUE;T;$T; @:JSON::Ext@: JSON::Ext::Generator::State@:+JSON::Ext::Generator::State.from_state@:+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@7:'JSON::Ext::Generator::State#space=@M:-JSON::Ext::Generator::State#space_before@g:.JSON::Ext::Generator::State#space_before=@}:*JSON::Ext::Generator::State#object_nl@:+JSON::Ext::Generator::State#object_nl=@:)JSON::Ext::Generator::State#array_nl@:*JSON::Ext::Generator::State#array_nl=@:,JSON::Ext::Generator::State#max_nesting@:-JSON::Ext::Generator::State#max_nesting=@ :0JSON::Ext::Generator::State#check_circular?@' :+JSON::Ext::Generator::State#allow_nan?@@ :,JSON::Ext::Generator::State#ascii_only?@Y :&JSON::Ext::Generator::State#depth@r :'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@J!:+JSON::Ext::Generator::GeneratorMethods@s!:3JSON::Ext::Generator::GeneratorMethods::Object@u!:;JSON::Ext::Generator::GeneratorMethods::Object#to_json@w!:1JSON::Ext::Generator::GeneratorMethods::Hash@!:9JSON::Ext::Generator::GeneratorMethods::Hash#to_json@!:2JSON::Ext::Generator::GeneratorMethods::Array@!::JSON::Ext::Generator::GeneratorMethods::Array#to_json@!:4JSON::Ext::Generator::GeneratorMethods::Integer@!:JSON::Ext::Generator::GeneratorMethods::TrueClass#to_json@=#:7JSON::Ext::Generator::GeneratorMethods::FalseClass@e#:?JSON::Ext::Generator::GeneratorMethods::FalseClass#to_json@g#:5JSON::Ext::Generator::GeneratorMethods::NilClass@#:=JSON::Ext::Generator::GeneratorMethods::NilClass#to_json@#:!JSON::Ext::Parser#initialize@#:JSON::Ext::Parser#parse@#:JSON::Ext::Parser#source@$:Digest::DigestError@:Digest#initialize@:Digest#initialize_copy@в:Digest#reset@޲:Digest#update@:Digest#<<@:Digest#finish@ :Digest#digest_length@<:Digest#block_length@W:Digest#name@r:OpenSSL::Digest@O:!OpenSSL::Digest::DigestError@Q:ASN1EndOfContent#to_dero; ; F; ;,;;;I"ASN1EndOfContent#to_der;T;[;[[@vKi[;T;; ;0;[;{;IC;" ;T;[;[;@;0; @5;!o;2 ;30;40;50;;;!@;70;F0;"I"Wstatic VALUE ossl_asn1eoc_to_der(VALUE self) { return rb_str_new("\0\0", 2); };T;#I"static VALUE;T;$T:OpenSSL::Netscape@z:!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=@:!OpenSSL::Netscape::SPKI#sign@-:#OpenSSL::Netscape::SPKI#verify@K:&OpenSSL::Netscape::SPKI#challenge@j:'OpenSSL::Netscape::SPKI#challenge=@:Fiddle::Function@,F:Fiddle::Function::DEFAULT@.F:Fiddle::Function::STDCALL@;F:Fiddle::Function#call@GF: Fiddle::Function#initialize@YF:Relay.with_funcall2o; ; F; ;;;;I"Relay.with_funcall2;T;[[@0;[[I"!ext/-test-/funcall/funcall.c;Ti ;T;:with_funcall2;0;[;{;IC;" ;T;[;[;@;0; @5;!o;2 ;30;40;50;: Relay;!@;70;F0;"I"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_blocko; ; F; ;;;;I"%Relay.with_funcall_passing_block;T;[[@0;[[@5i;T;:with_funcall_passing_block;0;[;{;IC;" ;T;[;[;@;0; @5;!o;2 ;30;40;50;;!;!@;70;F0;"I"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: TestFuncall.extra_args_nameo; ; F; ;;;;I" TestFuncall.extra_args_name;T;[;[[@5i;T;:extra_args_name;0;[;{;IC;" ;T;[;[;@;0; @5;!o;2 ;30;40;50;:TestFuncall;!@;70;F0;"I"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: Marshal::UsrMarshal::compat@p:-Marshal::UsrMarshal::compat#marshal_load@r: Bug::Integer#modify_expand!@t:Bug::Integer#cstr_unterm@)t: Bug::Integer#cstr_term_char@8t:(Bug::Integer#unterminated_substring@Dt:Bug::Integer.cstr_term@Tt:Bug::Integer.cstr_unterm@bt: Bug::Integer.cstr_term_char@rt:Bug::Integer.cstr_noembed@t: Bug::Integer.cstr_embedded?@t:#Bug::Integer.rb_str_new_frozen@t:Bug::Integer.external_new@t: Bug::Integer.shared_string?@t:&Bug::Integer.sharing_with_shared?@t: Bug::Integer.encoding_index@t;y@Z$: GC.start@\$:GC.enable@$:GC.disable@$:GC.stress@$:GC.stress=@%: GC.count@/%: GC.stat@J%:GC.latest_gc_info@%:GC#garbage_collect@%:GC::INTERNAL_CONSTANTS@&; @,&; @G&; @_&; @w&; @&; @&; @&; @&:ObjectSpace#each_object@:ObjectSpace.each_object@2: ObjectSpace#garbage_collect@X: ObjectSpace.garbage_collect@:!ObjectSpace#define_finalizer@":!ObjectSpace.define_finalizer@=:#ObjectSpace#undefine_finalizer@R:#ObjectSpace.undefine_finalizer@k:ObjectSpace#_id2ref@}:ObjectSpace._id2ref@:BasicObject#__id__@H:Object#object_id@:ObjectSpace#count_objects@:ObjectSpace.count_objects@:ObjectSpace::WeakMap#[]=@:ObjectSpace::WeakMap#[]@:"ObjectSpace::WeakMap#include?@:!ObjectSpace::WeakMap#member?@:ObjectSpace::WeakMap#key?@:!ObjectSpace::WeakMap#inspect@:ObjectSpace::WeakMap#each@&:#ObjectSpace::WeakMap#each_pair@4:"ObjectSpace::WeakMap#each_key@A:$ObjectSpace::WeakMap#each_value@O:ObjectSpace::WeakMap#keys@]: ObjectSpace::WeakMap#values@k:ObjectSpace::WeakMap#size@y: ObjectSpace::WeakMap#length@:"ObjectSpace::WeakMap#finalize@:#GC.verify_internal_consistency@ ':2GC.verify_transient_heap_internal_consistency@(':GC.malloc_allocated_size@4':GC.malloc_allocations@O':GC.add_stress_to_class@j':GC.remove_stress_to_class@': GC::OPTS@':SignalException#signo@m(:Interrupt#initialize@(; @': Math::PI@': Math::E@':Math#atan2@':Math.atan2@(: Math#cos@!(: Math.cos@?(: Math#sin@V(: Math.sin@t(: Math#tan@(: Math.tan@(:Math#acos@(:Math.acos@(:Math#asin@(:Math.asin@):Math#atan@*):Math.atan@H):Math#cosh@_):Math.cosh@}):Math#sinh@):Math.sinh@):Math#tanh@):Math.tanh@):Math#acosh@):Math.acosh@*:Math#asinh@3*:Math.asinh@Q*:Math#atanh@h*:Math.atanh@*: Math#exp@*: Math.exp@*: Math#log@*: Math.log@+:Math#log2@(+:Math.log2@F+:Math#log10@]+:Math.log10@{+:Math#sqrt@+:Math.sqrt@+:Math#cbrt@+:Math.cbrt@+:Math#frexp@+:Math.frexp@,:Math#ldexp@1,:Math.ldexp@S,:Math#hypot@l,:Math.hypot@,: Math#erf@,: Math.erf@,:Math#erfc@,:Math.erfc@,:Math#gamma@-:Math.gamma@/-:Math#lgamma@F-:Math.lgamma@f-:(RubyVM::InstructionSequence#inspect@H:'RubyVM::InstructionSequence#disasm@W:,RubyVM::InstructionSequence#disassemble@:%RubyVM::InstructionSequence#to_a@:%RubyVM::InstructionSequence#eval@:*RubyVM::InstructionSequence#to_binary@;@;@:%RubyVM::InstructionSequence#path@/:.RubyVM::InstructionSequence#absolute_path@=:&RubyVM::InstructionSequence#label@K:+RubyVM::InstructionSequence#base_label@Y:-RubyVM::InstructionSequence#first_lineno@g:-RubyVM::InstructionSequence#trace_points@u:+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@*:0RubyVM::InstructionSequence.compile_option=@@:'RubyVM::InstructionSequence.disasm@Z:,RubyVM::InstructionSequence.disassemble@:#RubyVM::InstructionSequence.of@:File.directory?@Բ:File.exist?@:File.exists?@:File.readable?@/:File.readable_real?@N:File.world_readable?@m:File.writable?@:File.writable_real?@:File.world_writable?@˳:File.executable?@:File.executable_real?@ :File.file?@):File.zero?@H:File.empty?@g:File.size?@:File.size@:File.owned?@Ĵ:File.grpowned?@:File.pipe?@:File.symlink?@!:File.socket?@@:File.blockdev?@_:File.chardev?@~:File.setuid?@:File.setgid?@:File.sticky?@۵:File.identical?@:File.stat@:File.lstat@7:File.ftype@Q:File.atime@p:File.mtime@:File.ctime@:File.birthtime@Ͷ:File.utime@:File.chmod@:File.chown@2:File.lchmod@V:File.lchown@x:File.lutime@:File.link@:File.symlink@:File.readlink@:File.unlink@ :File.delete@Q:File.rename@:File.umask@:File.truncate@ϸ:File.mkfifo@:File.expand_path@:File.absolute_path@,:File.realpath@E:File.realdirpath@^:File.basename@w:File.dirname@:File.extname@:File.path@ɹ:File::Separator@:File::SEPARATOR@:File.split@:File.join@:File::ALT_SEPARATOR@@:File::PATH_SEPARATOR@M: IO#stat@:File#lstat@Y:File#atime@o:File#mtime@:File#ctime@:File#birthtime@:File#size@ۺ:File#chmod@:File#chown@:File#truncate@8:File#flock@W:File::Constants@/:File::Constants::RDONLY@1:File::Constants::WRONLY@=:File::Constants::RDWR@I:File::Constants::APPEND@U:File::Constants::CREAT@a:File::Constants::EXCL@m:File::Constants::NONBLOCK@y:File::Constants::TRUNC@:File::Constants::NOCTTY@:File::Constants::BINARY@:"File::Constants::SHARE_DELETE@:File::Constants::SYNC@:File::Constants::DSYNC@:File::Constants::RSYNC@ͬ:File::Constants::NOFOLLOW@٬:File::Constants::NOATIME@:File::Constants::DIRECT@:File::Constants::TMPFILE@:File::Constants::LOCK_SH@ :File::Constants::LOCK_EX@:File::Constants::LOCK_UN@!:File::Constants::LOCK_NB@-:File::Constants::NULL@9:File#path@w:File#to_path@:Kernel#test@e:File::Stat#initialize@:File::Stat#initialize_copy@:File::Stat#<=>@,:File::Stat#dev@N:File::Stat#dev_major@i:File::Stat#dev_minor@:File::Stat#ino@:File::Stat#mode@:File::Stat#nlink@ծ:File::Stat#uid@:File::Stat#gid@ :File::Stat#rdev@&:File::Stat#rdev_major@B:File::Stat#rdev_minor@]:File::Stat#size@x:File::Stat#blksize@:File::Stat#blocks@:File::Stat#atime@˯:File::Stat#mtime@:File::Stat#ctime@:File::Stat#birthtime@:File::Stat#inspect@7:File::Stat#ftype@R:File::Stat#directory?@m:File::Stat#readable?@:File::Stat#readable_real?@:File::Stat#world_readable?@:File::Stat#writable?@ڰ:File::Stat#writable_real?@:File::Stat#world_writable?@:File::Stat#executable?@,: File::Stat#executable_real?@G:File::Stat#file?@b:File::Stat#zero?@}:File::Stat#size?@:File::Stat#owned?@:File::Stat#grpowned?@α:File::Stat#pipe?@:File::Stat#symlink?@:File::Stat#socket?@:File::Stat#blockdev?@::File::Stat#chardev?@U:File::Stat#setuid?@p:File::Stat#setgid?@:File::Stat#sticky?@: Time.now@YP: Time.at@tP: Time.utc@Q: Time.gm@ S:Time.local@T:Time.mktime@ V:Time#to_i@W:Time#to_f@W:Time#to_r@W: Time#<=>@W:Time#eql?@W:Time#hash@X:Time#initialize@6X:Time#initialize_copy@sX:Time#localtime@X:Time#gmtime@X: Time#utc@X:Time#getlocal@X:Time#getgm@7Y:Time#getutc@_Y:Time#ctime@Y:Time#asctime@Y:Time#to_s@Y:Time#inspect@Y:Time#to_a@$Z: Time#+@?Z: Time#-@^Z:Time#succ@Z:Time#round@Z: Time#sec@Z: Time#min@Z:Time#hour@Z:Time#mday@[: Time#day@,[: Time#mon@S[:Time#month@{[:Time#year@[:Time#wday@[:Time#yday@[:Time#isdst@[:Time#dst?@\:Time#zone@B\:Time#gmtoff@]\:Time#gmt_offset@\:Time#utc_offset@\:Time#utc?@\:Time#gmt?@"]:Time#sunday?@I]:Time#monday?@d]:Time#tuesday?@]:Time#wednesday?@]:Time#thursday?@]:Time#friday?@]:Time#saturday?@]:Time#tv_sec@^:Time#tv_usec@-^:Time#usec@U^:Time#tv_nsec@|^:Time#nsec@^:Time#subsec@^:Time#strftime@^:Time#_dump@_:Time#marshal_dump@_:Time#marshal_load@"_:Integer#abs@k:Integer#magnitude@k:Integer#===@k:Integer#==@k:Integer#>@ l:Integer#>=@)l:Integer#<@Hl:Integer#<=@gl:Integer#~@l:Integer#&@l:Integer#|@l:Integer#^@l:Integer#[]@l:Integer#<<@m:Integer#>>@=m:Integer#size@\m:Integer#bit_length@wm:Integer#digits@m:Object::Fixnum@&:Float::ROUNDS@Fv:Float::RADIX@Rv:Float::MANT_DIG@^v:Float::DIG@jv:Float::MIN_EXP@vv:Float::MAX_EXP@v:Float::MIN_10_EXP@v:Float::MAX_10_EXP@v:Float::MIN@v:Float::MAX@v:Float::EPSILON@v:Float::INFINITY@v:Float::NAN@v:Float#to_s@v:Float#inspect@v:Float#coerce@w: Float#-@@$w: Float#+@?w: Float#-@^w: Float#*@}w: Float#/@w:Float#quo@w:Float#fdiv@w: Float#%@x:Float#modulo@Dx:Float#divmod@qx: Float#**@x: Float#==@x:Float#===@x:Float#<=>@x: Float#>@x: Float#>=@y: Float#<@!y: Float#<=@@y:Float#eql?@_y:Float#hash@ky:Float#to_f@y:Float#abs@y:Float#magnitude@y:Float#zero?@y:Float#to_i@ z:Float#to_int@3z:Float#floor@Zz:Float#ceil@yz:Float#round@z:Float#truncate@z:Float#nan?@z:Float#infinite?@z:Float#finite?@{:Float#next_float@{:Float#prev_float@+{:Float#positive?@F{:Float#negative?@a{