ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
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+, Struct::Customer; ;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 ::new:;T@o;
;[I"Ejoe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
;TI"fjoe # => #
;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 == to compare member values.;To;;[I"
#eql?;T;[o;;[I"8Returns whether a given object is equal to +self+, ;TI"2using eql? 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"