📁 File Manager Pro
v10.0.3 | PHP: 8.1.34
Server: Apache
2026-06-21 20:25:52
📂
/ (Root)
/
opt
/
alt
/
ruby31
/
share
/
ri
/
system
/
Struct
📍 /opt/alt/ruby31/share/ri/system/Struct
🔄 Refresh
✏️
Editing: cdesc-Struct.ri
Read Only
U:RDoc::NormalClass[iI"Struct:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[ : @fileI"$ext/json/lib/json/add/struct.rb;T:0@omit_headings_from_table_of_contents_below0o;;[5o:RDoc::Markup::Paragraph;[I"G\Class \Struct provides a convenient way to create a simple class ;TI"%that can store and fetch values.;To:RDoc::Markup::BlankLine o;;[I"MThis example creates a subclass of +Struct+, <tt>Struct::Customer</tt>; ;TI"@the first argument, a string, is the name of the subclass; ;TI"Othe other arguments, symbols, determine the _members_ of the new subclass.;T@o:RDoc::Markup::Verbatim;[ I">Customer = Struct.new('Customer', :name, :address, :zip) ;TI"1Customer.name # => "Struct::Customer" ;TI"$Customer.class # => Class ;TI"%Customer.superclass # => Struct ;T:@format0o;;[I"JCorresponding to each member are two methods, a writer and a reader, ;TI"!that store and fetch values:;T@o; ;[I"/methods = Customer.instance_methods false ;TI"Dmethods # => [:zip, :address=, :zip=, :address, :name, :name=] ;T;0o;;[I"1An instance of the subclass may be created, ;TI"@and its members assigned values, via method <tt>::new</tt>:;T@o; ;[I"Ejoe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) ;TI"fjoe # => #<struct Struct::Customer name="Joe Smith", address="123 Maple, Anytown NC", zip=12345> ;T;0o;;[I"+The member values may be managed thus:;T@o; ;[I""joe.name # => "Joe Smith" ;TI"joe.name = 'Joseph Smith' ;TI"%joe.name # => "Joseph Smith" ;T;0o;;[I"UAnd thus; note that member name may be expressed as either a string or a symbol:;T@o; ;[I"%joe[:name] # => "Joseph Smith" ;TI"&joe[:name] = 'Joseph Smith, Jr.' ;TI"*joe['name'] # => "Joseph Smith, Jr." ;T;0o;;[I"See Struct::new.;T@S:RDoc::Markup::Heading: leveli: textI"What's Here;T@o;;[I"-First, what's elsewhere. \Class \Struct:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o;;[I"PInherits from {class Object}[Object.html#class-Object-label-What-27s+Here].;To;;0;[o;;[I"ZIncludes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], ;TI"1which provides dozens of additional methods.;T@o;;[I">Here, class \Struct provides methods that are useful for:;T@o;;;;[o;;0;[o;;[I"]{Creating a Struct Subclass}[#class-Struct-label-Methods+for+Creating+a+Struct+Subclass];To;;0;[o;;[I"9{Querying}[#class-Struct-label-Methods+for+Querying];To;;0;[o;;[I";{Comparing}[#class-Struct-label-Methods+for+Comparing];To;;0;[o;;[I"9{Fetching}[#class-Struct-label-Methods+for+Fetching];To;;0;[o;;[I";{Assigning}[#class-Struct-label-Methods+for+Assigning];To;;0;[o;;[I";{Iterating}[#class-Struct-label-Methods+for+Iterating];To;;0;[o;;[I"={Converting}[#class-Struct-label-Methods+for+Converting];T@S;;i;I"+Methods for Creating a Struct Subclass;T@o;;: NOTE;[o;;[I" ::new;T;[o;;[I"'Returns a new subclass of \Struct.;T@S;;i;I"Methods for Querying;T@o;;;;[o;;[I" #hash;T;[o;;[I"#Returns the integer hash code.;To;;[I"#length, #size;T;[o;;[I"#Returns the number of members.;T@S;;i;I"Methods for Comparing;T@o;;;;[o;;[I"{#==}[#method-i-3D-3D];T;[o;;[I"8Returns whether a given object is equal to +self+, ;TI"0using <tt>==</tt> to compare member values.;To;;[I" #eql?;T;[o;;[I"8Returns whether a given object is equal to +self+, ;TI"2using <tt>eql?</tt> to compare member values.;T@S;;i;I"Methods for Fetching;T@o;;;;[o;;[I"#[];T;[o;;[I";Returns the value associated with a given member name.;To;;[I"!#to_a, #values, #deconstruct;T;[o;;[I"5Returns the member values in +self+ as an array.;To;;[I"#deconstruct_keys;T;[o;;[I",Returns a hash of the name/value pairs ;TI"for given member names.;To;;[I" #dig;T;[o;;[I"<Returns the object in nested objects that is specified ;TI"5by a given member name and additional arguments.;To;;[I" #members;T;[o;;[I"*Returns an array of the member names.;To;;[I"#select, #filter;T;[o;;[I"4Returns an array of member values from +self+, ;TI"$as selected by the given block.;To;;[I"#values_at;T;[o;;[I"?Returns an array containing values for given member names.;T@S;;i;I"Methods for Assigning;T@o;;;;[o;;[I" #[]=;T;[o;;[I"2Assigns a given value to a given member name.;T@S;;i;I"Methods for Iterating;T@o;;;;[o;;[I" #each;T;[o;;[I"/Calls a given block with each member name.;To;;[I"#each_pair;T;[o;;[I":Calls a given block with each member name/value pair.;T@S;;i;I"Methods for Converting;T@o;;;;[o;;[I"#inspect, #to_s;T;[o;;[I"/Returns a string representation of +self+.;To;;[I" #to_h;T;[o;;[I"=Returns a hash of the member name/value pairs in +self+.;T; I" struct.c;T; 0; 0; 0[ [U:RDoc::Constant[i I"Passwd;TI"Struct::Passwd;T:public0o;;[ o;;[I"Passwd;T@o;;[I"<Passwd is a Struct that contains the following members:;T@o;;;;[o;;[I" name;T;[o;;[I";contains the short login name of the user as a String.;To;;[I"passwd;T;[o;;[I">contains the encrypted password of the user as a String. ;TI"Kan 'x' is returned if shadow passwords are in use. An '*' is returned ;TI"0if the user cannot log in using a password.;To;;[I"uid;T;[o;;[I"4contains the integer user ID (uid) of the user.;To;;[I"gid;T;[o;;[I"Econtains the integer group ID (gid) of the user's primary group.;To;;[I"dir;T;[o;;[I"Econtains the path to the home directory of the user as a String.;To;;[I" shell;T;[o;;[I"Bcontains the path to the login shell of the user as a String.;T@S;;i;I"WThe following members below are optional, and must be compiled with special flags:;T@o;;;;[o;;[I" gecos;T;[o;;[ I"?contains a longer String description of the user, such as ;TI"Ja full name. Some Unix systems provide structured information in the ;TI"0gecos field, but this is system-dependent. ;TI"8must be compiled with +HAVE_STRUCT_PASSWD_PW_GECOS+;To;;[I"change;T;[o;;[I"Wpassword change time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_CHANGE+;To;;[I" quota;T;[o;;[I"Mquota value(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_QUOTA+;To;;[I"age;T;[o;;[I"Lpassword age(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_AGE+;To;;[I" class;T;[o;;[I"Ruser access class(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_CLASS+;To;;[I"comment;T;[o;;[I"Jcomment(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_COMMENT+;To;;[I"expire;T;[o;;[I"Zaccount expiration time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_EXPIRE+;T; I"ext/etc/etc.c;T; 0@�@cRDoc::NormalClass0U;[i I" Group;TI"Struct::Group;T;0o;;[o;;[I" Group;T@o;;[I"QGroup is a Struct that is only available when compiled with +HAVE_GETGRENT+.;T@o;;[I"/The struct contains the following members:;T@o;;;;[ o;;[I" name;T;[o;;[I"0contains the name of the group as a String.;To;;[I"passwd;T;[o;;[ I"<contains the encrypted password as a String. An 'x' is ;TI"Ireturned if password access to the group is not available; an empty ;TI"Istring is returned if no password is needed to obtain membership of ;TI"the group.;T@o;;[I"9Must be compiled with +HAVE_STRUCT_GROUP_GR_PASSWD+.;To;;[I"gid;T;[o;;[I"3contains the group's numeric ID as an integer.;To;;[I"mem;T;[o;;[I"Dis an Array of Strings containing the short login names of the ;TI"members of the group.;T; @�; 0@�@@�0[[I"Enumerable;To;;[ ; @; 0I" struct.c;T[[I" class;T[[;[ [:protected[ [:private[ [I"json_create;TI"$ext/json/lib/json/add/struct.rb;T[I"keyword_init?;T@�[I"members;T@�[I"new;T@�[I" instance;T[[;[ [;[ [;[[I"==;T@�[I"[];T@�[I"[]=;T@�[I"as_json;T@�[I"deconstruct;T@�[I"deconstruct_keys;T@�[I"dig;T@�[I" each;T@�[I"each_pair;T@�[I" eql?;T@�[I"filter;T@�[I" hash;T@�[I"inspect;T@�[I"length;T@�[I"members;T@�[I"select;T@�[I" size;T@�[I" to_a;T@�[I" to_h;T@�[I"to_json;T@�[I" to_s;T@�[I"values;T@�[I"values_at;T@�[ [U:RDoc::Context::Section[i 0o;;[ ; 0; 0[ I"ext/etc/etc.c;TI"$ext/json/lib/json/add/struct.rb;TI"lib/pp.rb;TI" struct.c;T@cRDoc::TopLevel
💾 Save Changes
❌ Cancel